[SERVER-48367] envp may be unreliable in global initializers Created: 21/May/20  Updated: 29/Oct/23  Resolved: 23/Jun/20

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.7.0, 4.4.13

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
Problem/Incident
causes SERVER-50322 Fix libfuzzertests compile Closed
Tested
tested by SERVER-48605 options_parser_test.cpp is a beast Backlog
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.4
Sprint: Service arch 2020-06-01, Service arch 2020-06-15, Service arch 2020-06-29
Participants:
Linked BF Score: 50

 Description   

Hypothetical cause of BF-17563.

We clone the envp we got from main(argv,argc,env) into the InitializerContext.
I believe it may be corrupted by static initializers by the time main runs.
We can use environ instead. A better fix would be to change idiom so that InitializerContext provides a getenv accessor instead of a full snapshot of the environment. Nobody should need to see everything in the environment, they can pick out the keys they're interested in one by one. That's safer than a snapshot.



 Comments   
Comment by Githook User [ 31/Jan/22 ]

Author:

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

Message: SERVER-48367 Remove all _envp usage

(cherry picked from commit c08a726e61157ae501c28cf7e222e16d49954fbf)

SERVER-48367 fix embedded runGlobalInitializers call

(cherry picked from commit eed07779f77fd43ace5d6bf1eb12a117e0434089)
Branch: v4.4
https://github.com/mongodb/mongo/commit/66eb732e4cf9a9961b745e2d44d62147fbe60247

Comment by Githook User [ 31/Jan/22 ]

Author:

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

Message: SERVER-48367 remove all references to envp

(cherry picked from commit f0243899a74e5c98cf29a463493b2f06bbddfc38)
Branch: v4.4
https://github.com/10gen/mongo-enterprise-modules/commit/1509dcb09c40ed37f93ca671b615b2b95c2ed189

Comment by Githook User [ 23/Jun/20 ]

Author:

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

Message: SERVER-48367 fix embedded runGlobalInitializers call
Branch: master
https://github.com/mongodb/mongo/commit/eed07779f77fd43ace5d6bf1eb12a117e0434089

Comment by Githook User [ 11/Jun/20 ]

Author:

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

Message: SERVER-48367 Remove all _envp usage
Branch: master
https://github.com/mongodb/mongo/commit/c08a726e61157ae501c28cf7e222e16d49954fbf

Comment by Githook User [ 11/Jun/20 ]

Author:

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

Message: SERVER-48367 remove all references to envp
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/f0243899a74e5c98cf29a463493b2f06bbddfc38

Comment by Billy Donahue [ 05/Jun/20 ]

CR https://mongodbcr.appspot.com/615970005/

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