Commit 7dcd9fa
committed
Add opt-in seccomp BPF allowlist behind --seccomp
A memory-corruption RCE in device emulation could otherwise pivot to
arbitrary host syscalls (open, execve, socket, unlink). The new filter
reduces blast radius to the syscalls every device worker, the vcpu
loop, and pthread internals actually need.
src/seccomp.c builds an arch-aware BPF allowlist for x86_64 and
aarch64. x86_64 explicitly rejects the x32 ABI: x32 shares
AUDIT_ARCH_X86_64 but tags syscall numbers with __X32_SYSCALL_BIT
(0x40000000), so a naive allowlist that copies an Internet example
without this guard would let an attacker pivot to x32 syscall numbers
that alias different kernel handlers. Default action is
SECCOMP_RET_KILL_PROCESS so a worker thread that takes a denied
syscall aborts the whole VMM rather than leaving the device in an
unrecoverable state.
Install uses seccomp(2) directly with SECCOMP_FILTER_FLAG_TSYNC. The
serial worker thread is already running by the time seccomp_apply()
is called (spawned in vm_arch_init_platform_device during vm_init);
plain prctl(PR_SET_SECCOMP) installs only on the calling thread,
leaving an attacker a path through the pre-existing worker. TSYNC's
return is three-way: 0 success, -1 errno error, positive TID for
partial-sync failure -- a naive < 0 check would silently treat
partial-sync as success and leave the process unfiltered, so any
non-zero return is reported as failure and surfaces the offending
TID.
The flag is opt-in via --seccomp so existing test and development
workflows are unaffected. CI gains a second "boot test (seccomp)"
step on host-x64 that reuses .ci/autorun.sh with
KVM_HOST_FLAGS=--seccomp; reaching the "Linux version " banner
exercises prctl(PR_SET_NO_NEW_PRIVS), seccomp(2)+TSYNC over the
already-running serial worker, and the early KVM_RUN dispatch under
the filter, so a regression that drops a steady-state syscall from
the allowlist surfaces here as a SIGSYS before the banner.
Boot-tested on x86_64 and aarch64: --seccomp boots Linux to the
busybox console prompt with virtio-blk mounting ext4 r/w (exercises
pread/pwrite/fdatasync) and virtio-net probed; the lazy
virtio-blk/virtio-net worker spawn paths inside vm_run rely on
clone/clone3 + set_robust_list + rseq + sigaltstack being
allowlisted.1 parent 737d00d commit 7dcd9fa
6 files changed
Lines changed: 352 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
188 | 201 | | |
189 | 202 | | |
190 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
69 | 75 | | |
70 | 76 | | |
71 | | - | |
| 77 | + | |
| 78 | + | |
72 | 79 | | |
73 | 80 | | |
74 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
54 | 71 | | |
55 | 72 | | |
56 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
10 | 19 | | |
11 | 20 | | |
12 | 21 | | |
| |||
19 | 28 | | |
20 | 29 | | |
21 | 30 | | |
| 31 | + | |
| 32 | + | |
22 | 33 | | |
23 | 34 | | |
24 | 35 | | |
| |||
50 | 61 | | |
51 | 62 | | |
52 | 63 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 64 | + | |
| 65 | + | |
56 | 66 | | |
57 | 67 | | |
58 | 68 | | |
| |||
69 | 79 | | |
70 | 80 | | |
71 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
72 | 85 | | |
73 | 86 | | |
74 | 87 | | |
| |||
97 | 110 | | |
98 | 111 | | |
99 | 112 | | |
100 | | - | |
101 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
102 | 122 | | |
103 | 123 | | |
104 | 124 | | |
| |||
0 commit comments