[SERVER-78828] LDAP host timing data can be inconsistent during sorting Created: 10/Jul/23 Updated: 29/Oct/23 Resolved: 17/Jul/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.1.0-rc0, 7.0.0-rc8, 4.4.24, 5.0.20, 6.0.9 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Varun Ravichandran | Assignee: | Varun Ravichandran |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Backport Requested: |
v7.0, v6.0, v5.0, v4.4
|
||||||||
| Sprint: | Security 2023-07-24 | ||||||||
| Participants: | |||||||||
| Description |
|
When LDAP connection pooling is enabled, the server tracks the average latency for operations on each LDAP host and stores it in a struct called LDAPHostTimingData. This structure is shared between all PooledLDAPConnections that are connected to that particular host and a global LDAPPoolTimingData struct that maintains an unordered map of shared_ptrs to this timing data. When these shared_ptrs are accessed via the LDAPPoolTimingData map, they are synchronized via a mutex. They are only used in this context for reads. However, writes to each LDAPHostTimingData occur from within the PooledLDAPConnections themselves, which do not use that mutex to synchronize their writes with reads. As a result, it is possible for the comparator used in this stable sort to become inconsistent as values are updated while the comparator is being called by the sorting algorithm. std::stable_sort causes undefined behavior if the comparator does not return deterministic answers throughout the lifetime of the sort, and it's very possible that this is responsible for some crashes that have been seen during this sort in HELP tickets. |
| Comments |
| Comment by Githook User [ 04/Aug/23 ] |
|
Author: {'name': 'Varun Ravichandran', 'email': 'varun.ravichandran@mongodb.com', 'username': 'varunravi98'}Message: |
| Comment by Githook User [ 04/Aug/23 ] |
|
Author: {'name': 'Varun Ravichandran', 'email': 'varun.ravichandran@mongodb.com', 'username': 'varunravi98'}Message: |
| Comment by Githook User [ 03/Aug/23 ] |
|
Author: {'name': 'Tausif Rahman', 'email': 'tausif.rahman@mongodb.com', 'username': 'trahman1318'}Message: Revert " This reverts commit 07f47daf292c10a2d4d8a9fe00e98e4746aada7a. |
| Comment by Githook User [ 03/Aug/23 ] |
|
Author: {'name': 'Tausif Rahman', 'email': 'tausif.rahman@mongodb.com', 'username': 'trahman1318'}Message: Revert " This reverts commit 1addd9c7be2438b6357254d2b50a69be113ccb60. |
| Comment by Githook User [ 26/Jul/23 ] |
|
Author: {'name': 'Varun Ravichandran', 'email': 'varun.ravichandran@mongodb.com', 'username': 'varunravi98'}Message: |
| Comment by Githook User [ 25/Jul/23 ] |
|
Author: {'name': 'Varun Ravichandran', 'email': 'varun.ravichandran@mongodb.com', 'username': 'varunravi98'}Message: |