Skip to content

seccomp: check every handler against the filter the child installs - #366

Open
congwang-mk wants to merge 1 commit into
seccomp-filter-specfrom
seccomp-shared-trap-tables
Open

congwang-mk wants to merge 1 commit into
seccomp-filter-specfrom
seccomp-shared-trap-tables

Conversation

@congwang-mk

Copy link
Copy Markdown
Contributor

Stacked on #365; the base is seccomp-filter-spec, so this shows only the one commit on top of it.

Problem

The BPF notif list and the dispatch table were built from separate syscall lists in separate processes. A handler registered for a syscall the filter allows never runs, and nothing reported it. Two such cases existed:

  • the shmget memory-accounting handler when SysV IPC is denied (shmget is then on the blocklist, not the notif list);
  • the sysinfo handler when the policy denies sysinfo.

Change

  • The parent builds one FilterSpec before fork. The child installs it and the same value goes to the supervisor. ChildSpawnArgs carries filter in place of features and extra_syscalls.
  • After building the dispatch table, the supervisor refuses to start if any handler sits on a syscall the spec does not notify. The error goes through the existing startup channel, so it surfaces from run like any other startup failure, in release builds too.
  • The two mismatches above are fixed: shmget follows sysv_ipc_allowed on both sides, and the sysinfo handler is registered only when sysinfo is notified.
  • Lists with a single handler (memory accounting, exec, destination, timer and open-family syscalls) are defined once in seccomp/filter.rs and iterated by both the filter and build_dispatch_table.
  • notif::supervisor becomes pub(crate), since it takes the crate-private FilterSpec. Nothing outside the crate called it.

Not covered

  • Chroot and COW handlers still register syscall by syscall, because each gets a different handler. The startup check covers them; a shared list does not.
  • The check is one-directional. It does not flag a syscall that is notified but has no table entry, since fork, exit and policy events are handled outside the table.

Tests

  • New unit test: a handler on an unnotified syscall is reported, and is accepted once the syscall is passed as a handler syscall.
  • CI does not trigger for a PR whose base is not main, so it was dispatched manually on this branch: all 25 jobs pass (run).

🤖 Generated with Claude Code

The BPF notif list and the dispatch table were built from separate
syscall lists in separate processes, so a handler registered for a
syscall the filter allows would never run and nothing said so. Two such
cases existed: the shmget accounting handler when SysV IPC is denied,
and the sysinfo handler when the policy denies sysinfo.

The parent now builds one FilterSpec before fork. The child installs it
and the supervisor refuses to start if any handler sits on a syscall
that spec does not notify. The lists with a single handler (memory
accounting, exec, destination, timer and open-family syscalls) are
defined once in seccomp/filter.rs and iterated by both sides.

Signed-off-by: Cong Wang <cwang@multikernel.io>

This branch has not been deployed

No deployments
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.

1 participant