[SERVER-43641] platform/random.h causing bugs, upgrade overdue Created: 25/Sep/19  Updated: 29/Oct/23  Resolved: 09/Oct/19

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.3.1

Type: Bug Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
backported by SERVER-51803 Please backport SERVER-43641 Closed
Depends
Duplicate
duplicates SERVER-25659 InputStreamSecureRandom should open t... Closed
Gantt Dependency
has to be done after SERVER-43767 free_mon_controller_test relies on sp... Closed
has to be done after SERVER-43778 db_repl_coordinator_test relies on sp... Closed
Problem/Incident
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Dev Tools 2019-10-07, Dev Tools 2019-10-21
Participants:
Linked BF Score: 12

 Description   

Working hypothesis for BF-13608 is that it may have been caused by a badly calculated PseudoRandom sampling operation.

Without changing the underlying fundamentals or the API, we can make all these PseudoRandom and SecureRandom operations do what they claim to do, relying on vetted stdlib <random> facilities.



 Comments   
Comment by Githook User [ 10/Oct/19 ]

Author:

{'username': 'benety', 'email': 'benety@mongodb.com', 'name': 'Benety Goh'}

Message: SERVER-43641 fix test
Branch: master
https://github.com/mongodb/mongo/commit/424c1eb4c8cc50219d2a741741275dfdc3ecf3fa

Comment by Billy Donahue [ 09/Oct/19 ]

we'll try this again!

Comment by Githook User [ 09/Oct/19 ]

Author:

{'username': 'BillyDonahue', 'email': 'billy.donahue@mongodb.com', 'name': 'Billy Donahue'}

Message: SERVER-43641 upgrade random.h

This reverts commit a40b196bd3cecd0b66a6323f57e6f08efe0af392.
Branch: master
https://github.com/mongodb/mongo/commit/e1f433d2c47f623ceb5d1d1aee7605fefb71b846

Comment by Githook User [ 02/Oct/19 ]

Author:

{'name': 'James Wahlin', 'username': 'jameswahlin', 'email': 'james.wahlin@mongodb.com'}

Message: Revert "SERVER-43641 upgrade random.h"

This reverts commit 96da177c6ae7b7ed0f29983ad033d8a59524b0b2.
Branch: master
https://github.com/mongodb/mongo/commit/a40b196bd3cecd0b66a6323f57e6f08efe0af392

Comment by James Wahlin [ 02/Oct/19 ]

Reopening as this change will be reverted. db_free_mon_test and db_repl_coordinator_test are failing consistently on the required builders post commit.

Comment by Githook User [ 02/Oct/19 ]

Author:

{'name': 'Billy Donahue', 'username': 'BillyDonahue', 'email': 'billy.donahue@mongodb.com'}

Message: SERVER-43641 upgrade random.h

Respecify PseudoRandom and SecureRandom as template instances of
a `mongo::RandomBase<Urbg>` (Urbg is a UniformRandomBitGenerator).
They will only vary in which algorithm they use for their source
bits, and should otherwise support the same exact operations (e.g.
`nextCanonicalDouble`).

Fix range and stats errors in the implementations of those
RandomBase methods, and specify them in terms of the vetted
`<random>` facilities.

Test uniformity of nextInt32(max), which uses an inappropriate
( x % max) operation. Verify that refactor fixes this issue.

Just keep a shared urandom file descriptor open.

SecureRandom add fill, remove create, fix callers

Obsoletes SERVER-43643 Re: SecureRandom 8kiB buffering
Branch: master
https://github.com/mongodb/mongo/commit/96da177c6ae7b7ed0f29983ad033d8a59524b0b2

Comment by Billy Donahue [ 25/Sep/19 ]

Demo of how PseudoRandom::nextInt32() is non-uniformly distributed.
https://gist.github.com/BillyDonahue/53fa229d311cc6ac1f5ab21bd588e11f

Comment by Billy Donahue [ 25/Sep/19 ]

https://mongodbcr.appspot.com/511160003

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