Page MenuHomeFreeBSD

unix: Preserve FD_RESOLVE_BENEATH when passing an fd
ClosedPublic

Authored by markj on Jul 17 2026, 9:51 PM.
Tags
None
Referenced Files
F167034580: D58317.diff
Tue, Aug 18, 4:47 PM
Unknown Object (File)
Sun, Aug 16, 4:06 AM
Unknown Object (File)
Sun, Aug 16, 3:41 AM
Unknown Object (File)
Fri, Aug 14, 4:23 AM
Unknown Object (File)
Tue, Aug 11, 4:19 AM
Unknown Object (File)
Mon, Aug 10, 7:35 PM
Unknown Object (File)
Mon, Aug 10, 10:00 AM
Unknown Object (File)
Mon, Aug 10, 9:44 AM
Subscribers

Details

Summary

The FD_RESOLVE_BENEATH flag is supposed to be sticky. It's set when you
receive an fd from a different jail and preserved by openat(<dfd>) etc..
However, if you send the fd to yourself, the flag is stripped since
SCM_RIGHTS message don't preserve file descriptor flags.

Fix this by preserving those flags and checking for UF_RESOLVE_BENEATH
in restrict_rights().

Fixes: 350ba9672a7f ("unix: Set O_RESOLVE_BENEATH on fds transferred between jails")

Diff Detail

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

Event Timeline

markj requested review of this revision.Jul 17 2026, 9:51 PM
kib added inline comments.
sys/kern/uipc_usrreq.c
3521–3525

BTW why not return the UF_ flag(s) directly from restrict_rights, instead of using ternary operator in the calling place?

This revision is now accepted and ready to land.Jul 17 2026, 11:01 PM
This revision now requires review to proceed.Wed, Jul 22, 3:45 PM
kib added inline comments.
sys/kern/uipc_usrreq.c
3524

else is not needed.

This revision is now accepted and ready to land.Wed, Jul 22, 9:04 PM