[Midnightbsd-cvs] [MidnightBSD/src] 4903d5: unix: support fchmod(2) on unix sockets before bin...
Lucas Holt
noreply at github.com
Tue Sep 29 18:28:55 EDT 2026
Branch: refs/heads/master
Home: https://github.com/MidnightBSD/src
Commit: 4903d5982ced2cce7aa445bb7abf05ff72205b9a
https://github.com/MidnightBSD/src/commit/4903d5982ced2cce7aa445bb7abf05ff72205b9a
Author: Lucas Holt <luke at foolishgames.com>
Date: 2026-09-29 (Tue, 29 Sep 2026)
Changed paths:
M lib/libc/sys/chmod.2
M share/man/man4/unix.4
M sys/kern/sys_socket.c
M sys/kern/uipc_usrreq.c
M sys/sys/protosw.h
M sys/sys/unpcb.h
M tests/sys/kern/Makefile
A tests/sys/kern/unix_dgram.c
Log Message:
-----------
unix: support fchmod(2) on unix sockets before bind(2) (#530)
Allow fchmod() on an AF_UNIX socket prior to bind(), so that the mode
of the socket file is set atomically when it is created in the
filesystem. Without this, callers must chmod() after bind(), leaving a
window where the socket is reachable with the default mode. Once the
socket is bound, fchmod() reverts to failing with EINVAL. The
interface mirrors Linux.
Adapted from FreeBSD bfd03046d187 (D47361, PR 282393). Our protosw
still uses the pr_usrreqs layout, so the hook is a new pru_chmod entry
rather than pr_chmod; soo_chmod() dispatches to it and returns EINVAL
for protocols that do not provide one. fstat() behaviour is unchanged.
The FreeBSD stable/15 syslogd imported in #526 uses this in
socksetup(); its chmod()-after-bind fallback now only triggers on
older kernels.
Only the fchmod test from FreeBSD's tests/sys/kern/unix_dgram.c is
carried, since the other cases depend on newer socket buffer code.
Closes #527
AI-Assisted-by: Claude Fable 5.1
Signed-off-by: Lucas Holt <luke at foolishgames.com>
Co-authored-by: Claude Fable 5.1 <noreply at anthropic.com>
To unsubscribe from these emails, change your notification settings at https://github.com/MidnightBSD/src/settings/notifications
More information about the Midnightbsd-cvs
mailing list