Commit fafa9a4
committed
feat(sandbox): pluggable handler for bootstrap-subsystem failures
The supervisor performs three optional hardening steps that the host
kernel may refuse: unshare(CLONE_NEWNET), the supervisor seccomp
prelude, and the workload seccomp filter. On bare-metal Linux a refusal
is fatal. Under an outer sandbox (gVisor, Firecracker, Kata) the host
runtime is itself the enforcing boundary and routinely intercepts those
syscalls, leaving the supervisor unable to boot.
Introduce a pluggable SandboxFailureHandler trait. The default
StrictHandler preserves the historical contract — every refusal aborts.
Outer-sandbox integrations link this crate and call set_failure_handler
once at process start to register a handler that returns Ok(()) for the
kinds the host runtime is expected to manage. The three internal call
sites in run_sandbox and sandbox::linux::enforce route through
failure_handler().handle(kind, err)?.
Also make drop_privileges idempotent: when euid/egid already match the
resolved target, skip initgroups(3), which would otherwise fail without
CAP_SETGID.
The stock openshell-sandbox binary never calls set_failure_handler, so
its behaviour against this commit is byte-identical to upstream main.
All 777 sandbox library tests pass unchanged.
Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com>1 parent f0f17bf commit fafa9a4
3 files changed
Lines changed: 71 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
114 | 163 | | |
115 | 164 | | |
116 | 165 | | |
| |||
547 | 596 | | |
548 | 597 | | |
549 | 598 | | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
555 | 608 | | |
556 | 609 | | |
557 | 610 | | |
| |||
566 | 619 | | |
567 | 620 | | |
568 | 621 | | |
569 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
570 | 625 | | |
571 | 626 | | |
572 | 627 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
480 | 487 | | |
481 | 488 | | |
482 | 489 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
0 commit comments