Skip to content

Fix /proc dispatch for host-passthrough dirfds#41

Merged
jserv merged 1 commit intomainfrom
fix-proc
Apr 1, 2026
Merged

Fix /proc dispatch for host-passthrough dirfds#41
jserv merged 1 commit intomainfrom
fix-proc

Conversation

@jserv
Copy link
Copy Markdown
Contributor

@jserv jserv commented Apr 1, 2026

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 find and ls under /proc. Blocks unsafe relative lookups to prevent escaping the virtual namespace.

  • Bug Fixes

    • Detect untracked host dirfds in translate_request_at_path; for relative paths set CONTINUE, but reject .. and /proc escape names (root, cwd, exe, fd, fdinfo, map_files); detect /proc dirfds via /proc/<pid>/fd/<n>.
    • Gate virtual-path CONTINUE to originally-absolute guest paths with should_continue_virtual_path, preventing ./proc from bypassing LKL; applied to open*, stat*, faccessat, newfstatat, and legacy path calls.
    • Apply host-dirfd handling to readlinkat, symlinkat, linkat, and utimensat so safe relative lookups continue to the host.
  • Refactors

    • Expose kbox_relative_path_has_dotdot and add kbox_relative_proc_escape_path in path.c.
    • Extend kbox_is_proc_escape_path to flag fd, fdinfo, and map_files; add unit tests for .. detection and /proc escape patterns (including relative forms).

Written for commit 0000a3b. Summary will update on new commits.

cubic-dev-ai[bot]

This comment was marked as resolved.

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
@jserv jserv merged commit 26c912e into main Apr 1, 2026
5 checks passed
@jserv jserv deleted the fix-proc branch April 1, 2026 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant