COW: mediate openat2 and renameat; build the restore stub without SSP - #206
Merged
Conversation
COW registered only openat and legacy open, and the notif list did the same, so a raw openat2 under the workdir never reached the supervisor. The kernel ran it against the real directory with the child's Landlock write grant, so an O_CREAT or O_TRUNC open survived an abort and a read-only open could see stale lower content past a whiteout. Reusing decode_open_args also fixes the argument layout: for openat2 the flags and mode live in a struct open_how in child memory, not in the syscall args. Signed-off-by: Cong Wang <cwang@multikernel.io>
A compiler that enables the stack protector by default (vanilla GCC; Ubuntu's spec exempts -ffreestanding) emits a canary load from %fs:0x28 in the stub's prologue. The stub runs with a zero thread pointer until it restores the checkpoint's, so that read faults at address 0x28 before the READY handshake and every restore dies with SIGSEGV. Pass -fno-stack-protector explicitly and add a unit test that scans the built stub for the canary load. The freshness check in build_static compared the binary only against its C source, so a flag change here never recompiled a stub that already existed in target/. Compare against build.rs as well. Signed-off-by: Cong Wang <cwang@multikernel.io>
COW registered renameat2 and legacy rename but not renameat, and the notif list did the same, so a raw renameat under the workdir went to the kernel and renamed the real file, surviving an abort. On aarch64 this covered every ordinary rename: the ABI has no rename(2), so libc's rename() compiles to renameat. The chroot lists already carried it for that reason. renameat shares renameat2's first four arguments, so the parser accepts both numbers in the same branch. Signed-off-by: Cong Wang <cwang@multikernel.io>
The fxsave/xstate frame constants only feed the x86_64 signal-frame builder, which is already cfg-gated, so the riscv64 build warned about four unused constants. Signed-off-by: Cong Wang <cwang@multikernel.io>
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.
Summary
Two COW mediation gaps and one restore-stub build fix.
Tests
Both COW tests were confirmed to fail before their fix.
🤖 Generated with Claude Code