Repository navigation
Conversation
With --execute_fd the sandboxee is started with execveat(fd, "", ..., AT_EMPTY_PATH). getAbsPath() returned the empty path unchanged, so the unotify report recorded the execveat under path "" with the types of /proc/<pid>/root itself instead of the executed binary. Resolve an empty path to the object dirfd refers to. With AT_FDCWD it stays empty and is reported as NONEXISTENT. Add a test run by `make test`.
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.
With
--execute_fd, nsjail starts the sandboxee withexecveat(fd, "", argv, envp, AT_EMPTY_PATH). When--seccomp_unotifyis also set, that call is traced, but the report records it under an empty path with contradictory types:getAbsPath()returns an empty path unchanged, sopopulatePathInfo()runslstat("/proc/<pid>/root")(the magic link itself, henceLINK) andlstat("")(henceNONEXISTENT). The executed binary never shows up in the report, which is the one path a--execute_fduser most needs to see, since it is usually not mounted inside the jail.An empty path only names a file through its dirfd (
AT_EMPTY_PATH, see execveat(2) and openat(2)), so this change resolves it to the object dirfd refers to, using the same/proc/<pid>/fd/<n>lookup already used for relative paths, without appending a/. The same record now readspath: "/usr/bin/true",jail_type: REGULAR,main_type: REGULAR.An empty path with
AT_FDCWDis left empty, because whether it means the working directory depends on the syscall and its flags (readlink("")fails with ENOENT). Such a record is now reported asNONEXISTENTon both sides instead of getting the types of/proc/<pid>/rootitself.Testing:
tests/unotify_execute_fd.sh, run bymake test(targettest-unotify-execute-fd). It runs/bin/truewith--execute_fd --seccomp_unotifyand all namespaces disabled, so it also works without root, and checks the path of theexecveatrecord. On Linux aarch64 (kernel 6.8) it fails on master (execveat record has path "", expected "/usr/bin/true") and passes with this change. It exits 77 (skip) where seccomp user notifications are unavailable.make test-cmdline(7 checks) and the four nstun unit tests pass with this change.python3 -c passrun under--seccomp_unotifygives the same report (101 records) before and after.This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.