Repository navigation
network: resolve chroot named unix sockets on-behalf - #337
Open
congwang-mk wants to merge 1 commit into
Open
congwang-mk wants to merge 1 commit into
congwang-mk wants to merge 1 commit into
Conversation
Chroot mode never moves the child's real root or cwd, yet the named unix gate checked the raw sun_path lexically and returned Continue, leaving the kernel to resolve it on the host. An absolute virtual path therefore reached the host's socket of that name (an escape where Landlock cannot gate unix connect), and a relative one was checked as if anchored at / but resolved against the cwd the child was exec'ed in, so ./svc.sock from a granted cwd was refused while tmp/x.sock from an ungranted one passed. Serve chroot connect/sendto/sendmsg/sendmmsg on-behalf like non-chroot: build the virtual path against the tracked virtual cwd, pin the inode inside the root (mount aware), and check write access on where it really sits. The trap now stays on under chroot even with Landlock ABI v9. Signed-off-by: Cong Wang <cwang@multikernel.io>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #328, which fixed relative named unix socket paths in non-chroot mode.
Chroot mode never moves the child's real root or cwd, yet the named unix gate checked the raw
sun_pathlexically and returnedContinue, leaving the kernel to resolve it on the host:/tmp/svc.sockreached the host socket of that name instead of the one in the rootfs. Where Landlock cannot gate unix connect (ABI < 9), that is an escape to host sockets under a granted prefix./but resolved against the cwd the child was exec'ed in, so./svc.sockfrom a granted cwd was refused whiletmp/x.sockfrom an ungranted one passed.This serves chroot
connect/sendto/sendmsg/sendmmsgon-behalf like non-chroot: build the virtual path against the tracked virtual cwd, pin the inode inside the root (mount aware) withopenat2(RESOLVE_IN_ROOT), and checkcan_writeon where the pinned inode really sits. The trap stays on under chroot even with Landlock ABI v9, since the kernel cannot resolve virtual paths. As in non-chroot pre-v9, the peer'sSO_PEERCREDthen names the supervisor.Tests: a new
unix-sendrootfs-helper command and three chroot integration tests (absolute and relative stream connects, relative datagram, relative path outside the grant, symlink out of the grant). All fail on main and pass here.