Repository navigation
Conversation
Container seccomp and LSM policies (for example LXC on ext4) deny the FICLONE ioctl with EPERM by ioctl number. clone: "auto" treated that as a hard helper failure instead of an unavailable clone, so Root.copyIn and callers such as the OpenClaw updater failed with "native file copy failed". The target is created with O_EXCL immediately before FICLONE, so the kernel's own EPERM (immutable or append-only destination) cannot apply. The ordinary-copy fallback writes through the same exclusive descriptor with normal I/O, so any real policy denial still fails closed.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 6:30 PM ET / 22:30 UTC. ClawSweeper reviewWhat this changesThe PR lets Linux native file copies fall back when FICLONE returns EPERM, preserves strict cloning refusal, and updates regression coverage and the changelog. Merge readiness✅ Ready for maintainer review The fix remains necessary: current main and v0.23.0 still reject seccomp-denied FICLONE instead of falling back. The patch is focused and supported by a real LXC public-API comparison; another open PR independently covers the same defect. Priority: P2 Review scores
Verification
How this fits togetherfs-safe copies admitted source files into exclusive destination stages before guarded publication. Its native transfer layer chooses cloning, copy offload, or ordinary reads and writes while preserving filesystem safety checks. flowchart TD
A[Admitted source file] --> B[Exclusive destination stage]
B --> C[Attempt Linux cloning]
C --> D{Clone policy and result}
D --> E[Successful clone]
D --> F[Checked cleanup and ordinary copy]
D --> G[Strict refusal or terminal error]
E --> H[Guarded publication]
F --> H
Before mergeNone. Agent review detailsSecurityNone. Review metricsNone. Technical reviewBest possible solution: Land one shared FICLONE-only fix across the overlapping candidates, retaining checked cleanup, exclusive recreation, and strict cloning refusal. Do we have a high-confidence way to reproduce the issue? Yes: Root.copyIn with clone auto and native require mode on a host denying FICLONE with EPERM follows the source-proven failure path, corroborated by the contributor’s real LXC comparison. The reviewer did not execute it. Is this the best way to solve the issue? Yes: classifying only the clone ioctl denial as unavailable uses the existing guarded fallback without broadening permission-error recovery elsewhere. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 29f13fdeacc0. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Linux containers whose seccomp or LSM policy denies `FICLONE` with `EPERM` caused native copies with `clone: "auto"` to fail instead of copying bytes. The file-clone primitive now classifies that ioctl denial as unavailable cloning: `auto` uses the existing guarded ordinary-copy path, while `always` reports `unsupported-platform` and removes the stage. Strict `copyTree` cloning is unchanged. This addresses the updater failure tracked in openclaw/openclaw#164113. The target was just created with `O_EXCL`, so FICLONE's immutable/append-only destination explanation for EPERM does not apply. The fallback recreates the destination through the same guarded exclusive path and still fails closed if normal writes are denied. This deliberately differs from openat2's EPERM rule: it does not weaken path resolution. The rationale from @foxsky's duplicate #831 is incorporated inline, with co-author credit in the squash commit; a one-caller classification helper was unnecessary. The isolated Linux seccomp regression denies only `ioctl(FICLONE)`, verifies correct non-cloned bytes in auto mode, and verifies always-mode failure without a leftover stage. The writing guide, clone support probe, and Unreleased changelog are updated. Validation: `cargo test --workspace --locked` and Clippy passed on macOS; 64 focused copy tests passed with the native addon loaded (nine platform skips); Codex autoreview is clean at P0–P2. Exact-head Linux CI runs the seccomp regression, alongside the full OS matrix and CodeQL. Full `pnpm check` passed lint, build, allocator-build, and documentation checks locally, but the full test phase was stopped after widespread timing failures on a busy host. Thanks @Mohl for the fix and seccomp regression, and @foxsky for the security rationale. Exact-head CI passed on `6fe1c458485a699b12a71806d8093b1e0dfb92ed`: all OS lanes, the Linux seccomp regression, mutation-policy proofs, coverage, benchmarks, and CodeQL. [CI run](https://github.com/openclaw/fs-safe/actions/runs/37258456239). Co-authored-by: Mohl <[email protected]> Co-authored-by: foxsky <[email protected]>
|
Thanks for the fix and the careful security rationale, @foxsky! We landed the same production change in the earlier-submitted #829, which also includes an isolated seccomp regression proving that Your explanation of the newly created exclusive target and why this fallback remains fail-closed is incorporated in the code comment, including the distinction from openat2's EPERM rule. You are credited as a co-author in the squash commit. Closing this as a duplicate of #829, with thanks for helping make the fix clearer. |
What Problem This Solves
Fixes:
Root.copyInand other native file copies withclone: "auto"fail withhelper-failed("native file copy failed | FICLONE: Operation not permitted") inside containers whose seccomp or LSM policy denies theFICLONEioctl, such as LXC on ext4.User Impact
User impact: on such hosts,
clone: "auto"copies now fall back to an ordinary copy instead of failing, andclone: "always"reportsunsupported-platforminstead ofhelper-failed. OpenClaw's updater hits this in itsupdater-runtime-retentionstep, which blocks package updates on LXC hosts until the fixed version is the one running the update.Why This Change Was Made
Container seccomp profiles deny
FICLONEwithEPERMby ioctl number, and the auto policy only treatedENOTSUP/EOPNOTSUPP/EXDEV/EINVAL/ENOSYS/ENOTTYas "clone unavailable". The change addsEPERMto that set forFICLONEonly.This differs from the
openat2rule inlinux_open.rs("EPERM on an actual operation must never select a fallback"). There the fallback would weaken path resolution. Here the target was just created withO_EXCL, so the kernel's ownFICLONEEPERM(immutable or append-only destination) cannot apply. The ordinary-copy fallback also writes through the same exclusive descriptor using normal I/O, so a real policy denial still fails closed.copy_file_rangehandling is unchanged.Evidence
Checked on a real Proxmox LXC host (
container=lxc, ext4, seccomp filter active). There,FICLONEreturnsEPERMeven for arguments the kernel would reject with other errors (a directory source, the same fd), which confirms the filter matches on the ioctl number.copy_file_rangeworks on this host.Public API A/B (
root(dir).copyIn(..., { clone: "auto" }),FS_SAFE_NATIVE_MODE=require, rebuilt native addon):EPERMline:helper-failed native file copy failed | cause: FICLONE: Operation not permitted (os error 1)test/root-copy-options.test.ts"honors clone=always only when…": the environment probe now acceptsEPERM. On this host it fails withhelper-failedwithout the fix and passes with it (38 passed, 1 skipped).New Rust unit test
ficlone_policy_denials_select_ordinary_copy.cargo test --workspacepasses (134 tests in thefs-safe-nativelibrary suite).14 copy and clone test files under
FS_SAFE_NATIVE_MODE=require: 269 passed, 14 skipped, 0 failed after the probe update.cargo clippy --workspace --locked -- -D warningsis clean apart from afetch_updatedeprecation inwatch.rs, which also fails on unmodifiedmainwith Rust 1.99.lint:file-size,lint:fs-boundary,docs:checkpass.git diff --checkis clean.Codex autoreview (P0–P2): scoped-clean.
Gap: full
pnpm checkdidn't run locally because its archive WASM build needs clang with the wasm32 target. CI covers it.Tests added or updated when behavior changed
Security and compatibility impact considered
CHANGELOG.mdupdated when release-relevantNo credentials, private paths, private hosts, or sensitive contents included