carlos / platform Public

gvisor: filter readback refuses a needed call with any action suffix

systemd shows a call with an action of its own as name:ACTION
(mount:EPERM). The contract's check for calls runsc needs compared bare
names, so a filter denying mount:EPERM or ptrace:EPERM passed both
readbacks (Astra R2 check P2). It now strips the suffix before that
check; required denials must still be bare, so a per-call errno cannot
stand in for ENOSYS. Suffixed cases in the helper's and both
consumers' tests; the two needed-call cases failed on the old check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 275ef41abae17b673b16e021cf1bc39fcf6fc865 parent 1e609dc
4 files changed, +26 −6
  • internal/demobuild/gvisor_test.go +3 −0
  • internal/execsandbox/hardening.go +12 −6
  • internal/execsandbox/hardening_test.go +6 −0
  • internal/instancectl/gvisorunit_seccomp_test.go +5 −0
diff --git a/internal/demobuild/gvisor_test.go b/internal/demobuild/gvisor_test.go
index 9ac9b4c84..3e3fee976 100644
--- a/internal/demobuild/gvisor_test.go
+++ b/internal/demobuild/gvisor_test.go
@@ -635,6 +635,9 @@ func TestGVisorBuildRefusesUncontained(t *testing.T) {
strings.Replace(filter, " open_by_handle_at ", " ", 1): false,
strings.TrimPrefix(filter, "~"): false,
filter + " mount": false,
+ filter + " mount:EPERM": false,
+ filter + " ptrace:EPERM": false,
+ strings.Replace(filter, " bpf ", " bpf:EPERM ", 1): false,
} {
p := gvisorBuildShownFixture(t, l)
p["SystemCallFilter"] = value
diff --git a/internal/execsandbox/hardening.go b/internal/execsandbox/hardening.go
index 8ebc28f04..5a0d254f3 100644
--- a/internal/execsandbox/hardening.go
+++ b/internal/execsandbox/hardening.go
@@ -261,8 +261,9 @@ func GVisorHardeningSet(name string) bool {
// gvisorSyscallFilterShown is the syscall filter's readback contract
// (gvisor follow-ups round 1): a deny-list (the leading ~) that denies
-// every name of gvisorSyscallDenyRequired and none of
-// gvisorSyscallRunscNeeds. Other denied names are tolerated: systemd
+// every name of gvisorSyscallDenyRequired, each bare (with the unit's
+// ENOSYS, not an action of its own), and none of gvisorSyscallRunscNeeds,
+// with or without an action suffix. Other denied names are tolerated: systemd
// documents that its groups change between versions and builds, and
// libseccomp's name table with them, so a later expansion that denies
// more must not refuse every gVisor start; one that denies less, or
@@ -272,14 +273,19 @@ func gvisorSyscallFilterShown(got string) bool {
if !ok {
return false
}
- names := strings.Fields(denied)
+ // systemd shows a call with an action of its own as name:ACTION
+ // (ptrace:EPERM). A required denial must be the bare name, so that it
+ // answers SystemCallErrorNumber's ENOSYS; a call runsc needs is
+ // refused whatever its action (Astra R2 check).
+ entries := strings.Fields(denied)
for _, name := range gvisorSyscallDenyRequired {
- if !slices.Contains(names, name) {
+ if !slices.Contains(entries, name) {
return false
}
}
- for _, name := range gvisorSyscallRunscNeeds {
- if slices.Contains(names, name) {
+ for _, entry := range entries {
+ name, _, _ := strings.Cut(entry, ":")
+ if slices.Contains(gvisorSyscallRunscNeeds, name) {
return false
}
}
diff --git a/internal/execsandbox/hardening_test.go b/internal/execsandbox/hardening_test.go
index 262995f32..88756e366 100644
--- a/internal/execsandbox/hardening_test.go
+++ b/internal/execsandbox/hardening_test.go
@@ -130,6 +130,12 @@ func TestGVisorHardeningShown(t *testing.T) {
{"SystemCallFilter", strings.TrimPrefix(GVisorHardening()["SystemCallFilter"], "~"), false},
{"SystemCallFilter", GVisorHardening()["SystemCallFilter"] + " ptrace", false},
{"SystemCallFilter", GVisorHardening()["SystemCallFilter"] + " mount", false},
+ // Per-call actions, as systemd shows them (Astra R2 check).
+ {"SystemCallFilter", GVisorHardening()["SystemCallFilter"] + " mount:EPERM", false},
+ {"SystemCallFilter", GVisorHardening()["SystemCallFilter"] + " ptrace:EPERM", false},
+ {"SystemCallFilter", GVisorHardening()["SystemCallFilter"] + " a_future_obsolete_call:EPERM", true},
+ {"SystemCallFilter", strings.Replace(GVisorHardening()["SystemCallFilter"], " setns ", " setns:EPERM ", 1), false},
+ {"SystemCallFilter", strings.Replace(GVisorHardening()["SystemCallFilter"], " bpf ", " bpf:ENOSYS ", 1), false},
{"SystemCallFilter", "~", false},
{"SystemCallFilter", "", false},
{"SystemCallErrorNumber", "38", true},
diff --git a/internal/instancectl/gvisorunit_seccomp_test.go b/internal/instancectl/gvisorunit_seccomp_test.go
index 5c2c90c84..f577f9da7 100644
--- a/internal/instancectl/gvisorunit_seccomp_test.go
+++ b/internal/instancectl/gvisorunit_seccomp_test.go
@@ -39,6 +39,11 @@ func TestGVisorUnitRefusesUnfiltered(t *testing.T) {
{"SystemCallFilter", strings.Replace(filter, " bpf ", " ", 1)},
{"SystemCallFilter", strings.TrimPrefix(filter, "~")},
{"SystemCallFilter", filter + " ptrace"},
+ // Per-call actions (Astra R2 check): a needed call denied with
+ // any action, or a required one answering anything but ENOSYS.
+ {"SystemCallFilter", filter + " ptrace:EPERM"},
+ {"SystemCallFilter", filter + " mount:EPERM"},
+ {"SystemCallFilter", strings.Replace(filter, " setns ", " setns:EPERM ", 1)},
} {
if gvisorUnitShown(with(c.key, c.value), host, role, pin, gvisorTestLayout(t, host, role)) == nil {
t.Errorf("%s: accepted %s=%.40s...", role, c.key, c.value)