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
F168414677: D58317.id182163.diff
Fri, Aug 28, 4:04 AM
F168414410: D58317.id182163.diff
Fri, Aug 28, 4:01 AM
Unknown Object (File)
Sun, Aug 23, 1:01 AM
Unknown Object (File)
Sat, Aug 22, 12:48 PM
Unknown Object (File)
Sat, Aug 22, 6:47 AM
Unknown Object (File)
Tue, Aug 18, 4:47 PM
Unknown Object (File)
Sun, Aug 16, 4:06 AM
Unknown Object (File)
Sun, Aug 16, 3:41 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.Jul 22 2026, 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.Jul 22 2026, 9:04 PM