[SERVER-62665] Ensure `TransportLayerASIO::TimerService` can safely end the session Created: 14/Jan/22  Updated: 29/Oct/23  Resolved: 26/Jan/22

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

Type: Bug Priority: Major - P3
Reporter: Amirsaman Memaripour Assignee: Amirsaman Memaripour
Resolution: Fixed Votes: 0
Labels: servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
related to SERVER-62970 Separate SSL socket construction from... Closed
is related to SERVER-54900 Blocking networking calls can delay s... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0
Sprint: Service Arch 2022-1-24, Service Arch 2022-2-07
Participants:
Linked BF Score: 113
Story Points: 2

 Description   

Attempting to close SSL sockets through ASIOSession::end() is not multi-thread safe. Here is a possible scenario where we can have a read after write data-race:

  • Thread 1 is running SSL handshake, and attempts to emplace the established SSL socket into _sslSocket (see here). This is done while holding the session lock.
  • Thread 2 calls into ASIOSession::end(), which will attempt to get the underlying socket object by inquiring _sslSocket multiple times (here). All these accesses are done without holding the lock.

We can serialize accesses to _sslSocket by threads calling into ASIOSession::end() and ASIOSession::handshakeSSLForEgressWithLock() using a mutex. This should ensure the socket is not altered while running ASIOSession::end().



 Comments   
Comment by Githook User [ 17/Feb/23 ]

Author:

{'name': 'Amirsaman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}

Message: SERVER-62665 Ensure `TimerService` can safely end the session

(cherry picked from commit 3f92a7d72d4fe92a12aeb0f35bb6110fbce8ceb9)
Branch: v5.0
https://github.com/mongodb/mongo/commit/2b9bf831dafe30835643e6c7db9b2555c6023670

Comment by Uladzimir Makouski [ 17/Feb/23 ]

Reoccurring on v5.0 branch: BFG-1815688

Comment by Githook User [ 26/Jan/22 ]

Author:

{'name': 'Amirsaman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}

Message: SERVER-62665 Ensure `TimerService` can safely end the session
Branch: master
https://github.com/mongodb/mongo/commit/3f92a7d72d4fe92a12aeb0f35bb6110fbce8ceb9

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