Page MenuHomeFreeBSD

getsockopt: improve locking for SOL_SOCKET level socket options
ClosedPublic

Authored by tuexen on Oct 2 2024, 8:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 9, 1:29 AM
Unknown Object (File)
Fri, Dec 6, 1:39 PM
Unknown Object (File)
Mon, Dec 2, 5:15 PM
Unknown Object (File)
Sat, Nov 16, 11:01 AM
Unknown Object (File)
Sat, Nov 16, 6:26 AM
Unknown Object (File)
Thu, Nov 14, 5:36 PM
Unknown Object (File)
Nov 9 2024, 4:48 PM
Unknown Object (File)
Nov 1 2024, 2:41 AM
Subscribers

Diff Detail

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

Event Timeline

tuexen requested review of this revision.Oct 2 2024, 8:34 PM
This revision is now accepted and ready to land.Oct 3 2024, 3:46 PM

All of the races are harmless though, i.e., the getsockopt call would return garbage in the worst case. There might be applications which query these socket options frequently, especially the socket buffer sizes. Do you think the extra overhead of acquiring the socket lock is unlikely to matter?

All of the races are harmless though, i.e., the getsockopt call would return garbage in the worst case. There might be applications which query these socket options frequently, especially the socket buffer sizes. Do you think the extra overhead of acquiring the socket lock is unlikely to matter?

I would not expect these socket options in the fast path. But if you prefer, I can just add comments, that the caller might get garbage and needs to deal with it.

All of the races are harmless though, i.e., the getsockopt call would return garbage in the worst case. There might be applications which query these socket options frequently, especially the socket buffer sizes. Do you think the extra overhead of acquiring the socket lock is unlikely to matter?

I would not expect these socket options in the fast path. But if you prefer, I can just add comments, that the caller might get garbage and needs to deal with it.

I'm on the fence. The lock is unlikely to be contended, and this patch will help KCSAN. We've had more severe bugs involving lack of locking for SOLISTENING checks, so let's aim to be correct and avoid the lock only when it's demonstrably important for performance. I agree that these options aren't likely to be queried frequently.