From bedd2df4af3645e70798919aa437d38ac9323004 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sat, 14 Nov 2026 13:52:18 -0400 Subject: [PATCH 1/4] gpu-hold: hand the child its own ticket, so ownership can be checked (I broke the rule without it) Measured 2026-11-14 17:39Z: my runner started a GPU serve while another lane held a 45-minute ticket. The guard it used was [ -n "${GPU_HOLD:-}" ] || [ -f "$HOME/GPU-TOKEN" ] and the token file exists whenever ANY lane holds the box, so it passed exactly when starting work was most harmful. gpu-hold ran the command with `"$@" &` and exported nothing, so no consumer could tell holding from being a bystander. -env ... +env GPU_HOLD_TICKET="$mine" GPU_HOLD_LABEL="$SAFE" "$@" < /dev/null & GPU_HOLD_TICKET is the exact line written into the token, so the check is an equality, not a string guess. Verified live: inside a hold the child prints `GPU_HOLD_TICKET=gpu-hold pi-release-directtest2 pid 26131 2026-11-14T13:51:15-04:00` and the token holds the same line. scripts/npu-kernel-bitx.sh had the same defect and said so in its own message - "not inside an npu-hold ticket (no ~/NPU-TOKEN)" - while only proving that *someone* holds the device. It now requires NPU_HOLD_TICKET and compares it with the token, naming both on refusal: outside a ticket -> "refusing: NPU_HOLD_TICKET is not set, so this run cannot prove it owns the device ticket" + the npu-hold command line to use inside a ticket -> passes the guard and proceeds tests/gpu_hold_child_identity_test.sh (registered as gpu_hold_child_identity) asserts the export, the label, and that the variables are ABSENT outside a hold - the third arm is what makes a bare presence check unable to pass. Mutation-proven: reverting the export fails 2 arms. --- cmake/tests-gpu-hold.cmake | 6 +++ scripts/gpu-hold | 8 +++- scripts/npu-kernel-bitx.sh | 18 ++++++- tests/gpu_hold_child_identity_test.sh | 67 +++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 3 deletions(-) create mode 100755 tests/gpu_hold_child_identity_test.sh diff --git a/cmake/tests-gpu-hold.cmake b/cmake/tests-gpu-hold.cmake index 32c4deb1e..e1f63f6f7 100644 --- a/cmake/tests-gpu-hold.cmake +++ b/cmake/tests-gpu-hold.cmake @@ -57,3 +57,9 @@ add_test(NAME gpu_hold_group # resolve under DIFFERENT bases, so two callers could each hold a token and both run GPU work. Asserts the two # resolve under one base in all three states, plus that the script's two predicates are textually identical. add_test(NAME gpu_hold_hold_dir COMMAND bash ${CMAKE_SOURCE_DIR}/tests/gpu_hold_hold_dir_test.sh ${CMAKE_SOURCE_DIR}/scripts/gpu-hold) + +# The holder can PROVE it holds the ticket. `[ -e "$TOKEN" ]` is true whenever ANY lane holds the box, so a guard built +# on it passes exactly when starting work is most harmful - measured 2026-11-14, when a lane's runner served on the GPU +# for 40 s inside another lane's 45-minute hold. gpu-hold exports the exact token line it wrote (GPU_HOLD_TICKET) and the +# label, and this asserts the child sees both, on a sandboxed HOME. +add_test(NAME gpu_hold_child_identity COMMAND bash ${CMAKE_SOURCE_DIR}/tests/gpu_hold_child_identity_test.sh ${CMAKE_SOURCE_DIR}/scripts/gpu-hold) diff --git a/scripts/gpu-hold b/scripts/gpu-hold index e7a819737..4a0883aa3 100755 --- a/scripts/gpu-hold +++ b/scripts/gpu-hold @@ -345,7 +345,13 @@ set -m # `while read m; do gpu-hold -- bench "$m"; done < list`: without `set -m` the loop runs every entry, with `set -m` the # first payload's `cat` swallows the rest and the sweep silently runs once. Background jobs on `main` already got # /dev/null (a non-interactive shell's rule), so this keeps that semantic and takes only the process group. -"$@" < /dev/null & +# A child cannot otherwise prove it is the HOLDER rather than a bystander: `[ -e "$TOKEN" ]` is true whenever ANY lane +# holds the box, so a guard written with it passes exactly when starting work is most harmful (measured 2026-11-14: my +# own runner did that for 40 s against another lane's 45-minute ticket). The token's content is what this run wrote, so +# give it to the child - exact, not a string guess: +# GPU_HOLD_TICKET the exact line in the token file ("gpu-hold