Refactor seccomp syscall-list machinery + guard notify/deny overlap#82
Merged
Conversation
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
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
Three focused, behavior-preserving refactors to the seccomp syscall-list machinery in
sandlock-core, plus one defensive correctness guard.Commits
core: move syscall name mapping out of context— relocatessyscall_name_to_nrfromcontext.rsinto a newseccomp/syscall_names.rsmodule (it belongs next to the seccomp code, not in context). Callers insandbox.rsand the FFI are updated to the new path; the in-module import is a plainuse(no public re-export).seccomp: guard against notify/deny list overlap—assemble_filternow returnsInvalidInputif any syscall appears on both the notification and the deny lists. The BPF layout evaluates notif JEQs before deny JEQs, so an overlapping syscall wouldRET_USER_NOTIFand silently bypass the kernel-level deny. Failing loud at assembly time prevents that misconfiguration. Also consolidates the duplicatedSYS_FACCESSAT2 = 439constant (previously copied inchroot/dispatch.rsandcow/dispatch.rs) into a singlearch::SYS_FACCESSAT2(439 is the unified syscall number across x86_64/aarch64/riscv64).core: refactor notification syscall list builder— replaces the hand-rolledVec<u32>+ scatteredas u32casts innotif_syscallswith a smallSyscallListhelper and named per-featureconstgroups. No change to which syscalls land on the notif list;finish()does the samesort_unstable+dedupas before.Testing
cargo check -p sandlock-coreclean.cargo test -p sandlock-core --lib→ 309 passed, 0 failed.notif_syscallsrewrite was diffed group-by-group against the previous inline lists to confirm the set of intercepted syscalls is unchanged (security-critical: a dropped syscall would mean a silent virtualization bypass or broken deny).