Skip to content

seccomp: say why sed -i needs fchmod, fchown and getgroups, and test it - #116

Closed
masabzev-amd wants to merge 1 commit into
ROCm:mainfrom
masabzev-amd:deskside/p3-8-sed-metadata
Closed

masabzev-amd wants to merge 1 commit into
ROCm:mainfrom
masabzev-amd:deskside/p3-8-sed-metadata

Conversation

@masabzev-amd

@masabzev-amd masabzev-amd commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

#110 already allows fchmod, fchown and getgroups, and fails the xattr calls with EOPNOTSUPP, so this no longer changes the allow-list. It is rebased onto main and cut down to:

  • A comment at each of the three entries saying 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.
  • whitelist_allows_the_metadata_sed_sets: the three stay allowed.
  • sed_inplace_edit_does_not_report_eperm: sed -i under the default filter edits the file, with no "Operation not permitted" warning. It skips where there is no sed.

Not verified: this has not been built or tested since the rebase. The earlier version, which also allowed the xattr calls, is dropped: #110 keeps them denied because Landlock does not check them.

@johayang-amd

Copy link
Copy Markdown
Collaborator

Thanks for tracking this down. The sed test is a good, concrete reproduction of P3-8.

I think #110 (merged on main yesterday) already covers this, so I'd suggest closing this one:

  • fix(linux): allow fd seccomp syscalls, fail xattrs with EOPNOTSUPP #110 allows fchmod, fchown and getgroups, as here, but keeps every xattr syscall denied and answers them with EOPNOTSUPP, so sed and coreutils treat the file as having no ACL instead of printing an error. Its commit message explains why the xattr calls stay off the allowlist. Allowing them, as this PR does, would undo that decision once it's rebased onto main.
  • I ran this PR's sed_inplace_edit_does_not_report_eperm unchanged on both commits: it fails on c5023ce (/bin/sed: 'notes.txt': Operation not permitted) and passes on main 9d442a5.

For GAS, the fix is to move the AXIS pin (stack/platforms/halo/versions.env, plus the two READMEs that name c5023ce) to main at or after 890b7f9, and rerun the envelope-policy probe and e2e on Halo. One side effect worth noting there: after #110, sed -i no longer copies an ACL to the rewritten file.

Tested: GNU sed 4.9, WSL kernel 6.18, cargo test -p axis-sandbox --lib sed_inplace_edit_does_not_report_eperm on c5023ce (fails) and 9d442a5 (passes). Not tested on Halo.

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]>
@masabzev-amd
masabzev-amd force-pushed the deskside/p3-8-sed-metadata branch from d09e65c to 6f10b63 Compare November 19, 2026 07:51
@masabzev-amd masabzev-amd changed the title seccomp: allow the metadata calls GNU sed -i makes seccomp: say why sed -i needs fchmod, fchown and getgroups, and test it Nov 19, 2026
@johayang-amd

Copy link
Copy Markdown
Collaborator

Thanks for cutting this down. The comments at the three entries say what #110's commit message says, where the next reader of the allowlist will look, and the sed test checks the tool-level symptom P3-8 was about. I checked that it bites: with fchmod commented out of the allowlist it fails with exactly the P3-8 warning.

Before it can merge:

  • whitelist_allows_the_metadata_sed_sets repeats fix(linux): allow fd seccomp syscalls, fail xattrs with EOPNOTSUPP #110's every_backend_allows_fd_and_at_syscalls, which checks the same three on every backend; I'd drop it.
  • Format fails, and that alone fails the CI publication gate (cargo fmt fixes seccomp.rs:1065).
  • The title becomes the squash commit, so it needs the DEVELOPMENT.md form, e.g. test(seccomp): run sed -i under the default filter, and the body the template's sections (Motivation, Technical Details with **Security impact:** none, Test Plan, Test Result).

Optional: tempfile::tempdir() instead of temp_dir() plus the pid would clean up when an assert fails.

Tested: 6f10b63 on main 85f76b5 (WSL 6.18, GNU sed 4.9): both new tests pass; cargo fmt --check fails at seccomp.rs:1065 only.

@masabzev-amd

Copy link
Copy Markdown
Collaborator Author

Closing: #110 already allows fchmod, fchown and getgroups and refuses the xattr calls with EOPNOTSUPP, and GAS picked it up in silogen/GAS#212 (AXIS pin a4cf70e). every_backend_allows_fd_and_at_syscalls covers the allowlist check here. Thanks for the reviews.

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.

2 participants