Page MenuHomeFreeBSD

unix: Preserve FD_RESOLVE_BENEATH when passing an fd
AcceptedPublic

Authored by markj on Fri, Jul 17, 9:51 PM.
Tags
None
Referenced Files
F163304417: D58317.diff
Tue, Jul 21, 9:42 PM
F163211303: D58317.id182163.diff
Tue, Jul 21, 2:32 AM
F163202091: D58317.id182163.diff
Tue, Jul 21, 12:33 AM
Unknown Object (File)
Tue, Jul 21, 12:10 AM
Unknown Object (File)
Mon, Jul 20, 11:26 AM
Unknown Object (File)
Mon, Jul 20, 9:47 AM
Unknown Object (File)
Mon, Jul 20, 3:43 AM
Unknown Object (File)
Mon, Jul 20, 1:33 AM
Subscribers

Details

Reviewers
kib
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.Fri, Jul 17, 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.Fri, Jul 17, 11:01 PM