[SERVER-46071] Server parameters with AtomicWord<int> do not handle out of bound values gracefully Created: 10/Feb/20  Updated: 29/Oct/23  Resolved: 21/Feb/20

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: 4.2.3, 4.3.3
Fix Version/s: 4.3.4

Type: Bug Priority: Major - P3
Reporter: William Schultz (Inactive) Assignee: Sara Golemon
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Problem/Incident
causes SERVER-51231 suspicious long long to double conver... Closed
Related
related to SERVER-48076 implicit conversion from 'long long' ... Closed
related to SERVER-48079 implicit conversion from 'long long' ... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Steps To Reproduce:

let rst = new ReplSetTest({nodes: 1});
rst.startSet();
rst.initiate();
 
let primary = rst.getPrimary();
assert.commandFailedWithCode(
    primary.adminCommand({setParameter: 1, oplogFetcherSteadyStateMaxFetcherRestarts: NaN}),
    ErrorCodes.BadValue);
assert.commandFailedWithCode(
    primary.adminCommand({setParameter: 1, oplogFetcherInitialSyncMaxFetcherRestarts: NaN}),
    ErrorCodes.BadValue);
rst.stopSet();

Sprint: Security 2020-02-24
Participants:
Linked BF Score: 95

 Description   

Some server parameters are backed by an AtomicWord<int> type. These types do not gracefully handle input values outside the range of representable int values when we try to coerce the arguments here. Our undefined behavior builders manifest this as a runtime error when trying to set a parameter to NaN, for example. See the attached repro for a few examples of server parameters with this issue. This may be a general issue for any numeric server parameters that do not use a BSONElement::safeNumberLong deserializer.



 Comments   
Comment by Sara Golemon [ 21/Feb/20 ]

This changes how invalid values are reported to the user.  Previously, invalid values may result in under-defined behavior. Now the user gets a useful error.

Comment by Githook User [ 21/Feb/20 ]

Author:

{'username': 'sgolemon', 'name': 'Sara Golemon', 'email': 'sara.golemon@mongodb.com'}

Message: SERVER-46071 Handle nan/inf/out-of-range inputs to integral set parameter values
Branch: master
https://github.com/mongodb/mongo/commit/7d5a7b2afe99c12ff8260835bb6d80cbdc0ef48d

Generated at Thu Feb 08 05:10:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.