test(worker): verify child at the input caps, brk bounded by the limits

Max frame (document and base 2 MiB, drawings 6 MiB) passes through the full
sandbox; refusals just beyond give caps verdicts; RLIMIT_AS and the argument
filters still stop the verify child; seccomp traced on the max input; the two
tracked misclassifications asserted as current behaviour.
This commit is contained in:
bchanot committed 2026-11-01 21:07:23 +01:00
1 parent a6de7d6b94
commit e967ce6736
5 files changed
+385 -3

No files matched your search

+20
View File
@@ -210,6 +210,9 @@ enum HookAction {
Flood,
/// Allocates the given number of GiB: `RLIMIT_AS` must abort the child.
AllocGib(usize),
/// Grows the heap by the given GiB in 4 KiB chunks kept alive (the small-allocation path,
/// where musl extends the heap with `brk`): `RLIMIT_AS` must abort the child as well.
AllocSmallGib(usize),
/// Burns CPU forever: `RLIMIT_CPU` (SIGXCPU) or the parent's deadline must stop it.
Spin,
/// Sends SIGTERM to the parent through `tkill`: the argument filter must kill the child.
@@ -246,6 +249,13 @@ impl TestHooks {
.ok_or("--alloc-gib <n>")?;
hooks.action = Some(HookAction::AllocGib(value));
}
"--alloc-small-gib" => {
let value = iter
.next()
.and_then(|v| v.parse().ok())
.ok_or("--alloc-small-gib <n>")?;
hooks.action = Some(HookAction::AllocSmallGib(value));
}
other => return Err(format!("unknown flag {other}")),
}
}
@@ -296,6 +306,16 @@ impl TestHooks {
);
Some(exit_codes::INTERNAL)
}
HookAction::AllocSmallGib(gib) => {
let chunks = gib.saturating_mul(1024 * 1024 * 1024) / 4096;
let kept: Vec<Vec<u8>> = (0..chunks).map(|_| vec![1u8; 4096]).collect();
let _ = writeln!(
stderr,
"decode: kept {} chunks",
std::hint::black_box(&kept).len()
);
Some(exit_codes::INTERNAL)
}
HookAction::Spin => loop {
std::hint::black_box(0u8);
},