fix(worker): SAFETY comments state the invariants the code checks; WebP stride by checked arithmetic
The [gated <date>] markers read as an approval stamp: replaced by plain SAFETY comments giving, for each of the seven unsafe sites, the FFI contract and where the surrounding code establishes it (buffer length and stride checks, non-zero size and non-null output before from_raw_parts, single WebPFree, prctl integer arguments with the return code checked, the two negative hooks compiled with test-hooks only). The stride is now computed with checked_mul instead of width * 4.
This commit is contained in:
1 parent
f2cf93668e
commit
2d573883e5
2 files changed
+33
-13
No files matched your search
@@ -100,12 +100,17 @@ pub fn apply(limits: &Limits, seccomp: bool) -> Result<(), SandboxError> {
|
||||
/// `PR_SET_DUMPABLE 0` is the kernel-side stop, `RLIMIT_CORE 0` the belt.
|
||||
#[allow(unsafe_code)]
|
||||
fn disable_core_dumps() -> Result<(), SandboxError> {
|
||||
// SAFETY [gated 2026-10-13]: prctl with integer arguments only, changes this process only.
|
||||
// SAFETY: prctl is a variadic FFI; for PR_SET_DUMPABLE the kernel reads one integer
|
||||
// (the new flag) and requires the three remaining arguments to be zero, which is what is
|
||||
// passed: no pointer, no memory of this process involved, and only this process's flag
|
||||
// changes. The return code is checked below.
|
||||
let rc = unsafe { libc::prctl(libc::PR_SET_DUMPABLE, 0, 0, 0, 0) };
|
||||
if rc != 0 {
|
||||
return Err(SandboxError::Rlimit("PR_SET_DUMPABLE".to_owned()));
|
||||
}
|
||||
// SAFETY [gated 2026-10-13]: a getter with integer arguments.
|
||||
// SAFETY: PR_GET_DUMPABLE reads this process's flag; the four extra arguments must be
|
||||
// zero and are. The result is the flag (0 expected) or -1 on failure: any non-zero value
|
||||
// is refused below.
|
||||
let dumpable = unsafe { libc::prctl(libc::PR_GET_DUMPABLE, 0, 0, 0, 0) };
|
||||
if dumpable != 0 {
|
||||
return Err(SandboxError::Rlimit(format!(
|
||||
|
||||
Reference in new issue
Block a user