Page MenuHomeFreeBSD

tcp: Disallow re-connection of a connected socket
ClosedPublic

Authored by markj on Feb 11 2023, 4:28 PM.
Tags
None
Referenced Files
F167516048: D38507.id117142.diff
Sat, Aug 22, 10:18 AM
F167400457: D38507.id116986.diff
Fri, Aug 21, 1:38 PM
F167399024: D38507.id117205.diff
Fri, Aug 21, 1:27 PM
F167398738: D38507.id116987.diff
Fri, Aug 21, 1:24 PM
F167398730: D38507.id117142.diff
Fri, Aug 21, 1:24 PM
F167397766: D38507.diff
Fri, Aug 21, 1:19 PM
Unknown Object (File)
Fri, Aug 21, 5:34 AM
Unknown Object (File)
Thu, Aug 13, 7:46 PM
Subscribers

Details

Summary

soconnectat() tries to ensure that one cannot connect a connected
socket. However, the check is racy and does not really prevent two
threads from attempting to connect the same TCP socket.

Modify tcp_connect() and tcp6_connect() to perform the check again, this
time synchronized by the inpcb lock, under which we call
soisconnecting().

Reported by: syzkaller

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 49689
Build 46579: arc lint + arc unit

Event Timeline

markj requested review of this revision.Feb 11 2023, 4:28 PM
  • Undo the modification to tcp6_usr_connect().

May I ask two additions to the existing patch?

  1. Your discovery of the racyness of soconnectat() is very important and it deserves a comment in the function code with reference to the fact that TCP solves the problem for itself.
  2. I'd suggest to brace the new check info __predict_false().
  • Add a comment to soconnectat().
  • Add __predict_false annotations.

May I ask two additions to the existing patch?

  1. Your discovery of the racyness of soconnectat() is very important and it deserves a comment in the function code with reference to the fact that TCP solves the problem for itself.
  2. I'd suggest to brace the new check info __predict_false().

BTW, this is already checked implicitly by UDP when it checks inp->inp_faddr.

This revision was not accepted when it landed; it landed in state Needs Review.Feb 14 2023, 3:14 PM
This revision was automatically updated to reflect the committed changes.