Page MenuHomeFreeBSD

unix: Add support for atomically setting the socket mode
ClosedPublic

Authored by markj on Oct 31 2024, 6:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jul 11, 11:15 PM
Unknown Object (File)
Sun, Jul 5, 12:11 AM
Unknown Object (File)
Sat, Jul 4, 5:57 PM
Unknown Object (File)
Thu, Jul 2, 10:44 AM
Unknown Object (File)
Thu, Jul 2, 8:08 AM
Unknown Object (File)
Wed, Jul 1, 2:18 PM
Unknown Object (File)
Tue, Jun 30, 1:58 AM
Unknown Object (File)
Sat, Jun 27, 11:23 PM
Subscribers

Details

Summary

With this patch, it is possible to call fchmod() on a unix socket prior
to binding it to the filesystem namespace, so that the mode is set
atomically. Without this, one has to call chmod() after bind(), leaving
a window where threads can connect to the socket with the default mode.
After bind(), fchmod() reverts to failing with EINVAL.

I believe this is compatible with Linux.

I did not modify the behaviour of fstat(), i.e., it continues to return
the mode as set by soo_stat().

PR: 282393

Diff Detail

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

Event Timeline

markj requested review of this revision.Oct 31 2024, 6:30 PM

sys/_types.h is sufficient.

Update man pages, add some tests.

markj added reviewers: glebius, kib.
This revision is now accepted and ready to land.Nov 1 2024, 11:37 AM