Page MenuHomeFreeBSD

socket: Avoid clearing SS_ISCONNECTING if soconnect() fails
ClosedPublic

Authored by markj on Aug 26 2021, 9:05 PM.
Tags
None
Referenced Files
F169043122: D31699.diff
Mon, Aug 31, 5:37 AM
Unknown Object (File)
Sat, Aug 29, 10:57 PM
Unknown Object (File)
Fri, Aug 28, 8:58 AM
Unknown Object (File)
Thu, Aug 27, 4:10 AM
Unknown Object (File)
Wed, Aug 26, 3:35 PM
Unknown Object (File)
Mon, Aug 24, 12:32 AM
Unknown Object (File)
Sun, Aug 23, 7:12 AM
Unknown Object (File)
Sat, Aug 22, 9:35 AM
Subscribers

Details

Summary

This behaviour appears to date from the 4.4 BSD import. It has two
problems:

  1. The update to so_state is racy, and this can cause problems in the socket connection state machine. In particular it means that the check in solisten_proto_check() fails to catch a connecting socket.
  2. Suppose two threads race to call connect(2) on a socket, and one succeeds while the other fails. Then the failing thread may incorrectly clear SS_ISCONNECTING, confusing the state machine.

Simply remove the update. I don't believe it's necessary: pru_connect
implementations which call soisconnecting() only do so after all failure
modes have been handled. For instance, tcp_connect() and tcp6_connect()
will never return an error after calling soisconnected(). However, we
cannot correctly assert that SS_ISCONNECTED is _not_ set after an error
from soconnect().

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable