Resolve /dev/shm host paths in one place#228
Merged
Merged
Conversation
jserv
reviewed
Jul 19, 2026
jserv
left a comment
Contributor
There was a problem hiding this comment.
Centralizing the /dev/shm redirect in path_translate_at is the right call, but the shared primitive now reaches follow-capable callers that were never taught to force nofollow. Inline notes below. Test gap: tests/test-dev-shm-paths.c exercises the symlink-not-followed case only for the metadata ops, not for statfs/chdir/execve on a symlink leaf.
henrybear327
force-pushed
the
fix/dev-shm-path-redirect
branch
from
July 20, 2026 18:53
8cee1c5 to
a93fac7
Compare
jserv
reviewed
Jul 21, 2026
henrybear327
force-pushed
the
fix/dev-shm-path-redirect
branch
2 times, most recently
from
July 22, 2026 18:28
aa70bbf to
8769937
Compare
macOS has no /dev/shm, so elfuse backs POSIX shared memory with a
per-UID host directory, /tmp/elfuse-shm-<uid>/<name>, via the validated
resolver proc_dev_shm_resolve. Only open, stat, and unlinkat did that
redirect by hand; every other path syscall fell through
path_translate_at, which prepends the sysroot, so one guest path
resolved two ways:
/dev/shm/foo
open -> /tmp/elfuse-shm-1000/foo (backing dir, created)
chmod -> <sysroot>/dev/shm/foo (absent -> ENOENT)
LTP's setup_ipc (lib/tst_test.c) hits this exactly: open(O_CREAT|O_EXCL)
then SAFE_CHMOD on the same path. The open succeeded in the backing
dir, the chmod hit ENOENT and aborted common setup, failing all 24
conformance tests before any test body ran.
Do the redirect once, in path_translate_at, behind an is_dev_shm flag,
so chmod, chown, truncate, utimensat, rename, link, symlink, mknod,
readlink, mkdir, statfs, and xattr all inherit the backing path from one
choke point. The backing path is absolute, so path_translation_dirfd()
selects AT_FDCWD and the hand-rolled unlinkat rewrite folds away.
henrybear327
force-pushed
the
fix/dev-shm-path-redirect
branch
from
July 22, 2026 19:17
8769937 to
a89a59c
Compare
Contributor
|
Thank @henrybear327 for contributing! |
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.
macOS has no
/dev/shm, so elfuse backs POSIX shared memory with a per-UID host directory,/tmp/elfuse-shm-<uid>/<name>, via the validated resolverproc_dev_shm_resolve(flat leaf only; "..", embedded '/', and empty names rejected).Only three syscalls performed that redirect by hand: open, stat, and unlinkat. Every other path syscall fell through path_translate_at, which prepends the sysroot instead, so the same guest path resolved two different ways:
LTP's library startup (lib/tst_test.c setup_ipc) is failing to run all tests due to the following:
The fix is to do the redirect once, in path_translate_at, through the same resolver and a new shm_redirect flag, so chmod, chown, truncate, utimensat, rename, link, symlink, mknod, readlink, mkdir, statfs, and the xattr family all inherit the backing path from one choke point.
The backing path is absolute and POSIX ignores dirfd for absolute paths, so path_tx_dirfd() selects AT_FDCWD and the hand-rolled unlinkat rewrite folds away.
Summary by cubic
Centralized /dev/shm path resolution so all path syscalls and exec use the same per-UID backing directory on macOS. Enforced never-follow and tmpfs reporting so shm symlinks cannot escape to the host; fixes LTP setup_ipc open(O_CREAT) → chmod failure.
path_translate_atvia the validated resolver and setis_dev_shm; usepath_translation_dirfdfor absolute redirects; remove theunlinkatspecial-case.path_translation_at_flagsaddsAT_SYMLINK_NOFOLLOWon *at and xattr; lstat for stat and statfs leaf checks; exec image/interpreter opened withO_NOFOLLOW; truncate/chdir reach the leaf via a nofollow fd (O_NONBLOCKfor FIFOs); clearAT_SYMLINK_FOLLOWonlinkat; report/dev/shmand leaves as tmpfs (syntheticstatfs,TMPFS_MAGIC).EACCES; returnENAMETOOLONGon overflow; use lstat in proc stat; refuse a/dev/shminterpreter during bootstrap.test-dev-shm-paths: covers open→chmod, metadata ops, chdir/getcwd, rename/link/unlink, tmpfs statfs for root/leaves and FIFOs, symlink containment, exec of symlink refused and real binary runs, and name-shape/oversize gates; enabled intests/manifest.txt.Written for commit a89a59c. Summary will update on new commits.