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
F109568710: D31699.id94860.diff
Thu, Feb 6, 8:20 PM
F109568652: D31699.id94249.diff
Thu, Feb 6, 8:19 PM
F109523475: D31699.diff
Thu, Feb 6, 5:21 AM
Unknown Object (File)
Thu, Jan 30, 6:42 AM
Unknown Object (File)
Thu, Jan 16, 5:55 AM
Unknown Object (File)
Thu, Jan 16, 3:10 AM
Unknown Object (File)
Dec 4 2024, 1:53 AM
Unknown Object (File)
Dec 2 2024, 11:37 PM
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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 41234
Build 38123: arc lint + arc unit