Skip to content

fix(linux): allow fd seccomp syscalls, fail xattrs with EOPNOTSUPP - #110

Merged
johayang-amd merged 3 commits into
ROCm:mainfrom
ltsabadz:fix/seccomp-fd-metadata-syscalls
Nov 16, 2026
Merged

johayang-amd merged 3 commits into
ROCm:mainfrom
ltsabadz:fix/seccomp-fd-metadata-syscalls

Conversation

@ltsabadz

Copy link
Copy Markdown
Collaborator

Motivation

Inside the Linux sandbox, common tools like sed -i, ls -la and id say "Operation not permitted" even when they worked. That confuses agents, because they can't tell if the command succeeded. Fixes #106.

Technical Details

The sandbox blocked some harmless calls that these tools make. We now allow them, because they can only touch files the sandbox already lets you touch. If a policy blocks the older version of one of these calls, the new version is blocked too.

The calls that read or change extended file attributes (xattrs) are still blocked, but now they say "not supported" instead of "not permitted". Tools treat that as normal and keep going without an error.

Security impact: none. The newly allowed calls can't reach anything the policy denies, and xattrs are still refused.

Test Plan

Ran the test suite, plus the commands from #106 inside the sandbox, and tried to reach denied files through the newly allowed calls.

Test Result

Tests pass, the commands from #106 no longer print errors, and denied files stay out of reach. Not tested on MXC, macOS or Windows.

@johayang-amd johayang-amd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Luka, this is a really nice fix: agents stop seeing errors from commands that succeeded, and blocking each variant with its base syscall plus the Landlock link/fchdir probes make the new allowlist entries easy to trust.

Approving. The red Dependency audit is the rustix advisory from before #109; merging main into the branch fixes it. The new push will dismiss this approval, so I'll approve again once CI is green.

Small, non-blocking:

  • fchmodat2 still gets EPERM. glibc 2.39+ tries it for lchmod / fchmodat(..., AT_SYMLINK_NOFOLLOW) and falls back only on ENOSYS, so returning ENOSYS (like clone3) or allowing it would avoid another spurious error.
  • The PR body says MXC wasn't tested; it works there too (below), so that line could go.

Tested d716041 (this branch merged onto main 0c53fd6), Linux x86_64 WSL2, kernel 6.18, native and MXC (lxc-exec v1.0.0):

  • Local checks: fmt, clippy, cargo test --workspace 1001 passed / 0 failed, tier 0, workflow verifier, e2e/linux/test_sandbox.sh 16/16. The new Landlock link/fchdir test ran with its AT_EMPTY_PATH probes (not skipped on 6.18).
  • #106 commands with a policy like the issue's ({workspace} read-write, system dirs read-only, blocked_syscalls: [ptrace, mount, bpf, io_uring_setup], block mode), and with GAS's axis-policy-native and axis-policy-writecapable:
Command main this PR
sed -i edit lands, prints Operation not permitted no error
ls -la Operation not permitted per entry no error
id failed to get groups, exit 1 exit 0
cp -p preserving permissions ... Operation not permitted, exit 1 exit 0
chmod +x build.sh && ./build.sh works works

Same results on native and MXC.

  • Boundary checks, this PR, native:
Probe Result
listxattr / setxattr in the workspace EOPNOTSUPP
getxattr on a denied file EOPNOTSUPP
hard link of a read-only file into the workspace EXDEV
hard link of a denied file via /proc/self/fd (O_PATH) EXDEV
read a denied file EACCES
  • No bundled policy or GAS policy names an xattr syscall in blocked_syscalls, so the new rejection doesn't affect them.
  • Not run: macOS and Windows (the PR only touches Linux; CI covers the builds). Unrelated to this PR: under MXC, /dev/null and /dev/zero grants can't be opened (git fails there on main too); worth its own issue.

@johayang-amd johayang-amd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Luka, this is a really nice fix: agents stop seeing errors from commands that succeeded, and blocking each variant with its base syscall plus the Landlock link/fchdir probes make the new allowlist entries easy to trust.

Approving. The red Dependency audit is now the new quinn-udp advisory (RUSTSEC-2026-0538), not your change; #113 fixes it. Merging main again after that will dismiss this approval, so I'll approve again once CI is green.

Small, non-blocking:

  • fchmodat2 still gets EPERM. glibc 2.39+ tries it for lchmod / fchmodat(..., AT_SYMLINK_NOFOLLOW) and falls back only on ENOSYS, so returning ENOSYS (like clone3) or allowing it would avoid another spurious error.
  • The PR body says MXC wasn't tested; it works there too (below), so that line could go.

Tested c0f1b20 merged onto main 0c53fd6 (the same tree as 69a86ca), Linux x86_64 WSL2, kernel 6.18, native and MXC (lxc-exec v1.0.0):

  • Local checks: fmt, clippy, cargo test --workspace 1001 passed / 0 failed, tier 0, workflow verifier, e2e/linux/test_sandbox.sh 16/16. The new Landlock link/fchdir test ran with its AT_EMPTY_PATH probes (not skipped on 6.18).
  • #106 commands with a policy like the issue's ({workspace} read-write, system dirs read-only, blocked_syscalls: [ptrace, mount, bpf, io_uring_setup], block mode), and with GAS's axis-policy-native and axis-policy-writecapable:
Command main this PR
sed -i edit lands, prints Operation not permitted no error
ls -la Operation not permitted per entry no error
id failed to get groups, exit 1 exit 0
cp -p preserving permissions ... Operation not permitted, exit 1 exit 0
chmod +x build.sh && ./build.sh works works

Same results on native and MXC.

  • Boundary checks, this PR, native:
Probe Result
listxattr / setxattr in the workspace EOPNOTSUPP
getxattr on a denied file EOPNOTSUPP
hard link of a read-only file into the workspace EXDEV
hard link of a denied file via /proc/self/fd (O_PATH) EXDEV
read a denied file EACCES
  • No bundled policy or GAS policy names an xattr syscall in blocked_syscalls, so the new rejection doesn't affect them.
  • Not run: macOS and Windows (the PR only touches Linux; CI covers the builds). Unrelated to this PR: under MXC, /dev/null and /dev/zero grants can't be opened (git fails there on main too); worth its own issue.

@johayang-amd

Copy link
Copy Markdown
Collaborator

The dependency audit failure is fixed on main now. Could you merge main into the branch (or click "Update branch")? I'll re-approve once CI is green. Thanks!

Allow fchmod, fchown, getgroups, fchdir, linkat, symlinkat and close_range
on every Linux backend. Keep all xattr syscalls denied, returning EOPNOTSUPP so
tools treat files as having no ACLs instead of reporting errors; Landlock does
not check xattr calls and lets access-mode-3 opens through.

Fixes ROCm#106
A policy that blocks chdir, chmod, chown, link, symlink or close now
also blocks fchdir, fchmod, fchown, linkat, symlinkat or close_range.
Before this branch allowed those variants, blocking the base syscall
was enough to refuse them.

Also fail setxattrat, getxattrat, listxattrat and removexattrat with
EOPNOTSUPP like the other xattr calls, and reject a policy that names an
xattr call in blocked_syscalls with a clear error.

Make the Landlock link test require EXDEV or EACCES, report a failed
open separately, and probe /proc/self/fd links. Build the MXC test
options with mxc_seccomp_options_for_policy.
Blocking a base syscall blocks only the variant listed for it, so
blocking chmod or chown does not block fchmodat or fchownat. Say so in
the Seccomp section and link it from the isolation contract.

Fail with an error if a variant name does not resolve, check that each
variant is allowed when nothing blocks it, and skip the Landlock
AT_EMPTY_PATH probes only on the ENOENT that kernels before 6.10 return.
@ltsabadz
ltsabadz force-pushed the fix/seccomp-fd-metadata-syscalls branch from 69a86ca to 2cec16e Compare November 16, 2026 09:23
@johayang-amd
johayang-amd merged commit 890b7f9 into ROCm:main Nov 16, 2026
33 checks passed
masabzev-amd added a commit to masabzev-amd/axis that referenced this pull request Nov 19, 2026
ROCm#110 allows fchmod, fchown and getgroups and fails the xattr calls with
EOPNOTSUPP. Say at each allow-list entry what refusing it broke: GNU sed -i
applies the original's mode and owner to its temporary file with fchmod and
fchown, and `id` reads its groups with getgroups.

Test that the three stay allowed, and that sed -i under the default filter
edits the file without an "Operation not permitted" warning.

Co-authored-by: Cursor <[email protected]>
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.

Native sandbox returns EPERM for fchmod, fchown, xattr reads, getgroups and setsid, so everyday tools print errors after succeeding

2 participants