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
F173612709: D58317.diff
Sun, Sep 27, 4:42 AM
F173533759: D58317.id182636.diff
Sat, Sep 26, 4:16 PM
F173533573: D58317.id182466.diff
Sat, Sep 26, 4:14 PM
F173495097: D58317.diff
Sat, Sep 26, 8:52 AM
Unknown Object (File)
Fri, Sep 11, 7:10 AM
Unknown Object (File)
Thu, Sep 10, 11:31 PM
Unknown Object (File)
Tue, Sep 8, 6:04 AM
Unknown Object (File)
Mon, Sep 7, 7:52 PM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 74905
Build 71788: arc lint + arc unit

Event Timeline

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

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
3520

else is not needed.

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