[OpenSIPS-Devel] [OpenSIPS/opensips] e3f843: Fix race condition between accept and write on TCP...

Bogdan Andrei IANCU noreply at github.com
Tue Apr 20 15:28:11 EST 2021


  Branch: refs/heads/3.1
  Home:   https://github.com/OpenSIPS/opensips
  Commit: e3f843cc4df951ff17e7ccb69498a58e5a899b59
      https://github.com/OpenSIPS/opensips/commit/e3f843cc4df951ff17e7ccb69498a58e5a899b59
  Author: Bogdan-Andrei Iancu <bogdan at opensips.org>
  Date:   2021-04-20 (Tue, 20 Apr 2021)

  Changed paths:
    M net/net_tcp.c

  Log Message:
  -----------
  Fix race condition between accept and write on TCP conn

Upon accepting a new TCP conn, the TCP Main is adding the conn into the hash, but the conn is initialized by the protocol just after being passed to the TCP Worker. So, for a short time (while the conn is passed from TCP Main to TCP Worker), the conn is not properly initialized, so not safe to use. And here we have the race condition, as the conn, being already in the tcp hash, it is foundable by any other process trying to do a write op. So, a process may end up trying to do a write on an not fully init tcp conn -> crash :(
The fix is to avoid "finding" in hash the uninit conns.

Closes #2258

(cherry picked from commit ef3518bf2c4035821fab1c87a621182a623c3493)





More information about the Devel mailing list