HomeFreeBSD

unix: Set O_RESOLVE_BENEATH on fds transferred between jails

Description

unix: Set O_RESOLVE_BENEATH on fds transferred between jails

If a pair of jails with different filesystem roots is able to exchange
SCM_RIGHTS messages (e.g., using a unix socket in a shared nullfs
mount), a process in one jail can open a directory outside of the root
of the second jail and then pass the fd to that second jail, allowing
the receiving process to escape the jail chroot.

Address this using the new FD_RESOLVE_BENEATH flag. When externalizing
an SCM_RIGHTS message into the receiving process, automatically set this
flag on all new fds where a jail boundary is crossed. This ensures that
the receiver cannot do more than access files underneath the directory;
in particular, the received fd cannot be used to access vnodes not
accessible by the sender.

PR: 262179
Reviewed by: kib
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D50371

Details

Provenance
markjAuthored on Jun 24 2025, 8:05 PM
Reviewer
kib
Differential Revision
D50371: unix: Restrict dirfds exchanged between jails with a different root
Parents
rGf35525ff2053: file: Add a fd flag with O_RESOLVE_BENEATH semantics
Branches
Unknown
Tags
Unknown

Event Timeline