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

Bogdan Andrei IANCU noreply at github.com
Tue Apr 20 15:34:19 EST 2021


  Branch: refs/heads/2.4
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 078887fef61f59d0d0948a57f6c459e892feaeac
      https://github.com/OpenSIPS/opensips/commit/078887fef61f59d0d0948a57f6c459e892feaeac
  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