-
Type: Bug
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: JavaScript, Security
-
None
-
Server Security
-
ALL
-
Platforms 2018-05-07
-
16
Attempting to acquire a LockManager lock while holding a mutex is prone to deadlock. The AuthorizationManager::getAuthorizationVersion() function constructs a CacheGuard which acquires the AuthorizationManager::_cacheMutex. While holding the mutex, it calls AuthorizationManager::getStoredAuthorizationVersion(), which attempts to acquire the global lock as part of constructing AutoGetCollectionForReadCommand in AuthzManagerExternalStateMongod::findOne(). Edit: As noted in SERVER-24083, the AuthorizationManager::_cacheMutex is released as part of AuthorizationManager::beginFetchPhase() ; however, a thread must wait if another thread is already calling into AuthorizationManager::getStoredAuthorizationVersion().
A thread running the db.eval() with nolock=false (thus holding the global X lock) would therefore deadlock if it ran any command that constructed a CacheGuard and attempted to acquire the AuthorizationManager::_cacheMutex.
The doc comment for the AuthorizationManager::CacheGuard class describes this general issue; however, it appears we are missing code to enforce it doesn't happen in practice.
NOTE: It is not safe to enter fetch phase while holding a database lock. Fetch phase operations are allowed to acquire database locks themselves, so entering fetch while holding a database lock may lead to deadlock.
https://github.com/mongodb/mongo/blob/r3.7.2/src/mongo/db/auth/authorization_manager.cpp#L167-L169
- depends on
-
SERVER-33662 Remove deprecated db.eval command
- Closed
- is related to
-
SERVER-12497 role_management_helpers and user_management_helpers deadlocked with eval
- Closed
-
SERVER-26101 DBDirectClient isn't safe to auth
- Closed
-
SERVER-26257 DBDirectClient should not support auth
- Closed
-
SERVER-31552 Authorization User Cache should be able to hold select users in memory
- Closed
- related to
-
SERVER-35986 Stop running eval command in parallel suite on older branches
- Closed