Page MenuHomeFreeBSD

unix: Preserve FD_RESOLVE_BENEATH when passing an fd
ClosedPublic

Authored by markj on Fri, Jul 17, 9:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Aug 3, 11:42 PM
Unknown Object (File)
Mon, Aug 3, 9:24 AM
Unknown Object (File)
Mon, Aug 3, 8:53 AM
Unknown Object (File)
Mon, Aug 3, 8:37 AM
Unknown Object (File)
Mon, Aug 3, 6:27 AM
Unknown Object (File)
Mon, Aug 3, 12:46 AM
Unknown Object (File)
Sun, Aug 2, 8:12 AM
Unknown Object (File)
Sun, Aug 2, 1:16 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 75015
Build 71898: 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
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.Fri, Jul 17, 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