Conversation
Guest find/ls on /proc failed because host-kernel FDs from CONTINUE'd openat on virtual paths were not recognized in subsequent *at syscalls. The path translator resolved relative paths against CWD, making them absolute, causing resolve_open_dirfd to ignore the dirfd entirely. Detect host-passthrough dirfds in translate_request_at_path: when dirfd is not AT_FDCWD, non-negative, and not tracked in the FD table, read the guest path and signal CONTINUE for safe relative lookups. Reject paths containing ".." components or /proc magic symlinks (root, cwd, exe, fd, fdinfo, map_files) that could escape the virtual namespace. Add should_continue_virtual_path to gate CONTINUE on originally-absolute paths, preventing relative paths like "./proc" from bypassing LKL. Move kbox_relative_path_has_dotdot to path.c as public API with unit tests covering dotdot detection and proc escape patterns including fd, fdinfo, and map_files. Change-Id: Icb46feda38b8370a610c31b55ada9368bea357af
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.
Guest find/ls on /proc failed because host-kernel FDs from CONTINUE'd openat on virtual paths were not recognized in subsequent *at syscalls. The path translator resolved relative paths against CWD, making them absolute, causing resolve_open_dirfd to ignore the dirfd entirely.
Detect host-passthrough dirfds in translate_request_at_path: when dirfd is not AT_FDCWD, non-negative, and not tracked in the FD table, read the guest path and signal CONTINUE for safe relative lookups. Reject paths containing ".." components or /proc magic symlinks (root, cwd, exe, fd, fdinfo, map_files) that could escape the virtual namespace.
Add should_continue_virtual_path to gate CONTINUE on originally-absolute paths, preventing relative paths like "./proc" from bypassing LKL.
Move kbox_relative_path_has_dotdot to path.c as public API with unit tests covering dotdot detection and proc escape patterns including fd, fdinfo, and map_files.
Change-Id: Icb46feda38b8370a610c31b55ada9368bea357af
Summary by cubic
Fixes /proc dispatch by detecting host-passthrough dirfds and gating virtual-path continuations, restoring tools like
findandlsunder/proc. Blocks unsafe relative lookups to prevent escaping the virtual namespace.Bug Fixes
translate_request_at_path; for relative paths set CONTINUE, but reject..and/procescape names (root,cwd,exe,fd,fdinfo,map_files); detect/procdirfds via/proc/<pid>/fd/<n>.should_continue_virtual_path, preventing./procfrom bypassing LKL; applied toopen*,stat*,faccessat,newfstatat, and legacy path calls.readlinkat,symlinkat,linkat, andutimensatso safe relative lookups continue to the host.Refactors
kbox_relative_path_has_dotdotand addkbox_relative_proc_escape_pathinpath.c.kbox_is_proc_escape_pathto flagfd,fdinfo, andmap_files; add unit tests for..detection and/procescape patterns (including relative forms).Written for commit 0000a3b. Summary will update on new commits.