Uploaded image for project: 'radsecproxy'
  1. radsecproxy
  2. RADSECPROXY-67

Race condition in TCP/TLS accept

    XMLWordPrintable

Details

    • Task
    • Resolution: Fixed
    • Minor
    • None
    • None
    • None
    • None

    Description

      Hi All,

      There is a race condition in both the tcp and tls code (in functions tcplistener and tlslistener) when accepting new connections.
      If new connections arrive in very short succession, and the second (or any further) accept() call returns before the previously created thread has actually started off, these threads operate on the wrong socket.
      (the pointer handed to the thread points to the local variable s in [tcp|tls]listener() which gets its new value before the thread could copy its value)

      Proposed change: copy the variable to the heap and use this as argument to the new thread; also new thread is responsible for the memory if spawn is successful.

      Additional side-fix:
      tcpreadtimeout() does a select() on a write-fd with the intention to wait for readable bytes.
      This was fixed in 1.6.3 for tls code, but not tcp.

      Patch is attached.

      Best regards,
      Fabian

      --
      SWITCH
      Fabian Mauchle, Network Engineer
      Werdstrasse 2, P.O. Box, 8021 Zurich, Switzerland
      phone +41 44 268 15 30, direct +41 44 268 15 39
      fabian.mauchle@switch.ch, www.switch.ch

      [Created via e-mail received from: fabian.mauchle@switch.ch]

      Attachments

        Activity

          People

            mail_user Mail reader user (Inactive)
            mail_user Mail reader user (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: