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
F120695076: D47361.id.diff
Fri, Jun 20, 6:53 AM
F120693758: D47361.id145770.diff
Fri, Jun 20, 6:39 AM
F120692809: D47361.id145772.diff
Fri, Jun 20, 6:30 AM
F120691216: D47361.id145769.diff
Fri, Jun 20, 6:10 AM
Unknown Object (File)
Thu, Jun 19, 11:34 AM
Unknown Object (File)
Wed, Jun 18, 1:26 PM
Unknown Object (File)
Thu, Jun 5, 9:39 PM
Unknown Object (File)
Fri, May 23, 2:40 AM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 60294
Build 57178: arc lint + arc unit

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