From a61ef9e6551bd41066f1f15161aa80ac55a14a62 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sat, 14 Nov 2026 06:08:36 -0400 Subject: [PATCH 1/3] release-check: payload-modes must REQUIRE the binaries it names, not only print them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit engine#2422, measured on a real 258-entry payload: the row printed the modes and judged only group/other-writability, so ``` PASS payload-modes : no path in the payload is group- or other-writable … (modes: 644 1bit/1bit 644 bin/lemond) SKIP hrx-placement : no 1bit engine binary in the image, so the two arms cannot be started ``` A 0644 engine passes the writability rule and then makes the row that would start it **skip** (`[ -x ]` finds nothing), so the release check is green over a payload that cannot run. A SKIP is right for "the binary is not here"; it is wrong for "the binary is here and is not runnable", and until now the two were indistinguishable. The row now requires what it already names — all three paths it already stats — and fails naming the offenders: ``` FAIL payload-modes : in the payload but not executable: 1bit/1bit bin/lemond - a 0644 engine or lemond refuses to run, and hrx-placement then SKIPs instead of failing (modes: 644 1bit/1bit 644 bin/lemond) ``` `tests/release_check_payload_modes_test.sh` (row in `cmake/tests-release-check-payload-modes.cmake`) builds three real payload trees and runs the row against each — 120 empty files satisfy the entry floor, nothing reads their bytes: | payload | expected | measured | |---|---|---| | `1bit/1bit` + `bin/lemond` at 0644 | FAIL, both named | **FAIL**, both named | | at 0755 | PASS, modes still printed | **PASS** `modes: 755 1bit/1bit 755 bin/lemond` | | no binaries | PASS (absence is hrx-device's claim) | **PASS**, unchanged | **The fixture is checked against the pre-fix script, not only the post-fix one**: run against `origin/main`'s `release-check.sh` it fails with exactly the message from the issue (`PASS … (modes: 644 1bit/1bit 644 bin/lemond)`), so it tests the claim rather than the plumbing. Fixtures live under `~/.cache`, not `/tmp`, because `/tmp` is tmpfs here and `tools/ci/tmp_path_check.py` flags new `/tmp` sites by design. Fixes #2422. --- cmake/tests-release-check-payload-modes.cmake | 21 +++++ os/mini/release-check.sh | 22 +++-- tests/release_check_payload_modes_test.sh | 84 +++++++++++++++++++ 3 files changed, 122 insertions(+), 5 deletions(-) create mode 100644 cmake/tests-release-check-payload-modes.cmake create mode 100755 tests/release_check_payload_modes_test.sh diff --git a/cmake/tests-release-check-payload-modes.cmake b/cmake/tests-release-check-payload-modes.cmake new file mode 100644 index 000000000..390d3a79d --- /dev/null +++ b/cmake/tests-release-check-payload-modes.cmake @@ -0,0 +1,21 @@ +# Copyright 2026 bong-water-water-bong +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# engine#2422: `release-check.sh`'s payload-modes row printed the binaries' modes and judged only group/other-writability, so a +# payload whose `1bit/1bit` was 0644 read `PASS payload-modes (modes: 644 1bit/1bit …)` while hrx-placement read `SKIP` -- green +# over a payload that cannot run. The fixture builds three real payload trees (0644, 0755, no binaries) and runs the row against +# each; it fails on the pre-fix script with exactly the message from the issue, which is how it is known to test the claim and not +# the plumbing. ~34 s, no device, no build. +add_test(NAME release_check_payload_modes COMMAND bash ${CMAKE_SOURCE_DIR}/tests/release_check_payload_modes_test.sh ${CMAKE_SOURCE_DIR}/os/mini/release-check.sh) diff --git a/os/mini/release-check.sh b/os/mini/release-check.sh index ec1e5d525..d1656ca04 100755 --- a/os/mini/release-check.sh +++ b/os/mini/release-check.sh @@ -2196,13 +2196,25 @@ else while IFS= read -r _p; do _r=${_p#"$PDIR"}; _r=${_r#/}; printf '%s %s ' "$(stat -c %A "$_p" 2>/dev/null)" "${_r:-.}"; done) PM=$(payload_modes_verdict "${_pm_f:-}" "${_pm_d:-}" "${_pm_s:-}") _pm_bits= + # engine#2422: printing the bits is not asserting them. A 0644 `1bit/1bit` passes the writability rule and then makes + # hrx-placement SKIP (`[ -x ]` cannot find a runnable engine), so the release check was green over a payload whose + # engine cannot run - measured on a real 258-entry payload: `PASS payload-modes (modes: 644 1bit/1bit 644 bin/lemond)` + # beside `SKIP hrx-placement`. Absence stays out of this row's claim: a binary that is not here is hrx-device's or + # identity's business, and a payload mid-extraction is already caught by the floor above. + _pm_noexec= for _b in "$PDIR/1bit/1bit" "$PDIR/bin/lemond" "$PDIR/lemond-onebit"; do - [ -f "$_b" ] && _pm_bits="$_pm_bits $(stat -c '%a %n' "$_b" 2>/dev/null | sed "s|$PDIR/||")" + [ -f "$_b" ] || continue + _pm_bits="$_pm_bits $(stat -c '%a %n' "$_b" 2>/dev/null | sed "s|$PDIR/||")" + [ -x "$_b" ] || _pm_noexec="$_pm_noexec ${_b#"$PDIR"/}" done - case "$PM" in - PASS*) pass payload-modes "${PM#PASS }${_pm_bits:+ (modes:$_pm_bits)}" ;; - *) fail payload-modes "${PM#FAIL }${_pm_bits:+ (modes:$_pm_bits)}" ;; - esac + if [ -n "$_pm_noexec" ]; then + fail payload-modes "in the payload but not executable:${_pm_noexec} - a 0644 engine or lemond refuses to run, and hrx-placement then SKIPs instead of failing (modes:$_pm_bits)" + else + case "$PM" in + PASS*) pass payload-modes "${PM#PASS }${_pm_bits:+ (modes:$_pm_bits)}" ;; + *) fail payload-modes "${PM#FAIL }${_pm_bits:+ (modes:$_pm_bits)}" ;; + esac + fi fi fi diff --git a/tests/release_check_payload_modes_test.sh b/tests/release_check_payload_modes_test.sh new file mode 100755 index 000000000..68a768caf --- /dev/null +++ b/tests/release_check_payload_modes_test.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# Copyright 2026 bong-water-water-bong +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# payload-modes must REQUIRE the binaries it names to be executable (engine#2422). +# +# The row printed the modes and judged only group/other-writability, so a payload whose `1bit/1bit` was 0644 read +# `PASS payload-modes (modes: 644 1bit/1bit …)` while the row that would start the engine read `SKIP hrx-placement` +# (`[ -x ]` found no runnable binary). Green over a payload that cannot run. +# +# Three arms, because the fix has two ways to be wrong and only one of them is loud: +# * 0644 binaries must FAIL and NAME them -- otherwise the row still passes what it exists to catch; +# * 0755 binaries must PASS with the modes still printed -- otherwise it fails healthy payloads; +# * a payload with no binaries must still PASS -- absence is hrx-device's claim, not this row's, and turning it into a +# failure here would red every payload that ships the engine somewhere this row does not look. +# +# The payloads are real directories (empty files are enough: the floor wants >100 entries, and nothing here reads a +# byte of them), built under ~/.cache because /tmp is tmpfs on this box and `tools/ci/tmp_path_check.py` flags new /tmp +# sites by design. +# +# usage: release_check_payload_modes_test.sh +set -u + +RC=${1:?usage: release_check_payload_modes_test.sh } +[ -r "$RC" ] || { echo "not readable: $RC"; exit 1; } + +ROOT=$(mktemp -d "${TMPDIR:-$HOME/.cache}/release-check-pm.XXXXXX") || exit 1 +trap 'rm -rf "$ROOT"' EXIT +fail=0 + +mkpayload() { # + local d=$ROOT/$1 mode=$2 i + mkdir -p "$d/1bit" "$d/bin" + for i in $(seq 1 120); do : > "$d/lib$i.so"; done + find "$d" -type d -exec chmod 0755 {} + + find "$d" -type f -exec chmod 0644 {} + + if [ "$mode" != none ]; then + printf 'x' > "$d/1bit/1bit"; printf 'x' > "$d/bin/lemond" + chmod "$mode" "$d/1bit/1bit" "$d/bin/lemond" + fi +} + +run_row() { # -> the payload-modes line + PAYLOAD_DIR=$ROOT/$1 HW_SKIPPED=gpu,npu,npu-power,models,chat-hrx,chat-npu \ + timeout 300 bash "$RC" --check 2>&1 | grep -m1 'payload-modes' || true +} + +mkpayload p644 0644 +line=$(run_row p644) +case "$line" in + FAIL*"payload-modes"*"not executable"*"1bit/1bit"*"bin/lemond"*) + echo "ok a 0644 engine and lemond FAIL, and both are named" ;; + *) echo "FAIL a 0644 payload was not refused: ${line:-}"; fail=1 ;; +esac + +mkpayload p755 0755 +line=$(run_row p755) +case "$line" in + PASS*"payload-modes"*"modes:"*"755 1bit/1bit"*) + echo "ok a 0755 payload PASSes and still prints its modes" ;; + *) echo "FAIL a healthy payload was not accepted with its modes: ${line:-}"; fail=1 ;; +esac + +mkpayload pnone none +line=$(run_row pnone) +case "$line" in + PASS*"payload-modes"*) + echo "ok a payload with no binaries still PASSes (absence is another row's claim)" ;; + *) echo "FAIL a binary-less payload changed verdict: ${line:-}"; fail=1 ;; +esac + +echo "release_check_payload_modes_test: $fail failure(s)" +exit $((fail > 0)) From 620b18eebfc4951c434813af1ff34337bbebd2e4 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sat, 14 Nov 2026 06:36:20 -0400 Subject: [PATCH 2/3] the fixture cost 392 s in CI; extract the function instead (self-review, measured) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR's first version passed CI -- `314/320 Test #314: release_check_payload_modes … Passed 392.06 sec` -- and that number is the problem. Three `release-check.sh --check` runs to prove three `[ -x ]` lines: 18 s per run here became **130 s per arm in a container**, i.e. six and a half minutes added to every build of an 18-minute job. A test may not charge that for this. So the check is now `payload_modes_noexec()` in `release-check.sh`, the row calls it, and the fixture extracts it exactly as the neighbouring `release_check_hrx_init_reason_test.sh` extracts `hrx_init_reason()`: | | before | after | |---|---|---| | fixture cost (local) | 34 s | **0.024 s** | | fixture cost (CI) | **392 s** | ~0 (function call, no script runs) | Three arms on the extracted function (0644 names both, 0755 names nothing, no binaries names nothing), plus **one grep that pins the call site** -- `payload_modes_noexec "$PDIR"` -- because a correct function nothing calls is precisely the defect this row is about (#2416/#2422), and the engine#2238 lesson is that a test should pin where the call lives, not only that the callee works. Both mutation arms were re-run against the new fixture, each exiting 1: ``` $ … /origin-main/release-check.sh FAIL no payload_modes_noexec() in … - the row cannot require an executable engine (engine#2422) $ … /script-with-the-call-removed/release-check.sh FAIL payload_modes_noexec() is defined but never called on the payload - a guard nothing calls ``` The row's own behaviour is unchanged: `FAIL … not executable: 1bit/1bit bin/lemond` on a 0644 payload, `PASS` with the modes printed on 0755, `PASS` unchanged with no binaries. --- os/mini/release-check.sh | 22 ++++++-- tests/release_check_payload_modes_test.sh | 63 +++++++++++------------ 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/os/mini/release-check.sh b/os/mini/release-check.sh index d1656ca04..e779579a6 100755 --- a/os/mini/release-check.sh +++ b/os/mini/release-check.sh @@ -779,6 +779,19 @@ kernel_cve_verdict() { fi } +payload_modes_noexec() { # -> the binaries present but not executable, space-separated and payload-relative + # engine#2422: the row prints the modes, and printing is not asserting. A 0644 `1bit/1bit` passes the writability rule and then + # makes hrx-placement SKIP (`[ -x ]` cannot find a runnable engine), so the check was green over a payload that cannot run. + # Absence is deliberately NOT an offender: a binary that is not here is hrx-device's or identity's claim, and a payload still + # being extracted is caught by the entry floor above. + _pe_dir=${1:-} _pe_out= + for _pe_b in "$_pe_dir/1bit/1bit" "$_pe_dir/bin/lemond" "$_pe_dir/lemond-onebit"; do + [ -f "$_pe_b" ] || continue + { [ -x "$_pe_b" ] || _pe_out="$_pe_out ${_pe_b#"$_pe_dir"/}"; } 2>/dev/null || true + done + printf '%s' "$_pe_out" +} + payload_modes_verdict() { # [] _f=${1:-} _d=${2:-} _sample=${3:-} case "$_f" in ''|*[!0-9]*) printf 'FAIL the payload'"'"'s file modes could not be counted (%s)' "${_f:-empty}"; return 0 ;; esac @@ -2201,12 +2214,13 @@ else # engine cannot run - measured on a real 258-entry payload: `PASS payload-modes (modes: 644 1bit/1bit 644 bin/lemond)` # beside `SKIP hrx-placement`. Absence stays out of this row's claim: a binary that is not here is hrx-device's or # identity's business, and a payload mid-extraction is already caught by the floor above. - _pm_noexec= for _b in "$PDIR/1bit/1bit" "$PDIR/bin/lemond" "$PDIR/lemond-onebit"; do - [ -f "$_b" ] || continue - _pm_bits="$_pm_bits $(stat -c '%a %n' "$_b" 2>/dev/null | sed "s|$PDIR/||")" - [ -x "$_b" ] || _pm_noexec="$_pm_noexec ${_b#"$PDIR"/}" + [ -f "$_b" ] && _pm_bits="$_pm_bits $(stat -c '%a %n' "$_b" 2>/dev/null | sed "s|$PDIR/||")" done + # The executability requirement is its own function so `tests/release_check_payload_modes_test.sh` can extract and test + # it without running the whole check: the first version of that fixture ran `release-check.sh --check` three times and cost + # **392 s** in CI (18 s locally became 130 s per arm in a container), which is not a price three `[ -x ]` lines may charge. + _pm_noexec=$(payload_modes_noexec "$PDIR") if [ -n "$_pm_noexec" ]; then fail payload-modes "in the payload but not executable:${_pm_noexec} - a 0644 engine or lemond refuses to run, and hrx-placement then SKIPs instead of failing (modes:$_pm_bits)" else diff --git a/tests/release_check_payload_modes_test.sh b/tests/release_check_payload_modes_test.sh index 68a768caf..b019e3e23 100755 --- a/tests/release_check_payload_modes_test.sh +++ b/tests/release_check_payload_modes_test.sh @@ -30,55 +30,50 @@ # sites by design. # # usage: release_check_payload_modes_test.sh +# +# The FIRST version of this fixture ran `release-check.sh --check` three times, once per payload: 34 s here and **392 s in CI** +# (18 s per run locally became 130 s in a container), for three `[ -x ]` lines. So it now does what the neighbouring +# `release_check_hrx_init_reason_test.sh` does - extract the function and test it - plus one grep that pins the CALL SITE, because a +# correct function nothing calls is the defect this whole row is about (engine#2416/#2422 shape, and the engine#2238 lesson: a test +# should pin where the call lives, not only that the callee works). set -u RC=${1:?usage: release_check_payload_modes_test.sh } [ -r "$RC" ] || { echo "not readable: $RC"; exit 1; } +FN=$(awk '/^ *payload_modes_noexec\(\) \{/{f=1} f{print} f&&/^ *\}$/{exit}' "$RC") +[ -n "$FN" ] || { echo "FAIL no payload_modes_noexec() in $RC - the row cannot require an executable engine (engine#2422)"; exit 1; } +case "$RC" in + *"this line is never matched"*) : ;; +esac +grep -q 'payload_modes_noexec "\$PDIR"' "$RC" || { echo "FAIL payload_modes_noexec() is defined but never called on the payload - a guard nothing calls"; exit 1; } + ROOT=$(mktemp -d "${TMPDIR:-$HOME/.cache}/release-check-pm.XXXXXX") || exit 1 trap 'rm -rf "$ROOT"' EXIT fail=0 -mkpayload() { # - local d=$ROOT/$1 mode=$2 i - mkdir -p "$d/1bit" "$d/bin" - for i in $(seq 1 120); do : > "$d/lib$i.so"; done - find "$d" -type d -exec chmod 0755 {} + - find "$d" -type f -exec chmod 0644 {} + - if [ "$mode" != none ]; then - printf 'x' > "$d/1bit/1bit"; printf 'x' > "$d/bin/lemond" - chmod "$mode" "$d/1bit/1bit" "$d/bin/lemond" +mktree() { # + mkdir -p "$ROOT/$1/1bit" "$ROOT/$1/bin" + if [ "$2" != none ]; then + printf 'x' > "$ROOT/$1/1bit/1bit"; printf 'x' > "$ROOT/$1/bin/lemond" + chmod "$2" "$ROOT/$1/1bit/1bit" "$ROOT/$1/bin/lemond" fi } -run_row() { # -> the payload-modes line - PAYLOAD_DIR=$ROOT/$1 HW_SKIPPED=gpu,npu,npu-power,models,chat-hrx,chat-npu \ - timeout 300 bash "$RC" --check 2>&1 | grep -m1 'payload-modes' || true -} - -mkpayload p644 0644 -line=$(run_row p644) -case "$line" in - FAIL*"payload-modes"*"not executable"*"1bit/1bit"*"bin/lemond"*) - echo "ok a 0644 engine and lemond FAIL, and both are named" ;; - *) echo "FAIL a 0644 payload was not refused: ${line:-}"; fail=1 ;; +mktree p644 0644 +got=$(bash -c "$FN"$'\npayload_modes_noexec "$1"' _ "$ROOT/p644") +case "$got" in + *1bit/1bit*bin/lemond*) echo "ok a 0644 engine and lemond are both named as not executable" ;; + *) echo "FAIL a 0644 payload was not reported: '${got}'"; fail=1 ;; esac -mkpayload p755 0755 -line=$(run_row p755) -case "$line" in - PASS*"payload-modes"*"modes:"*"755 1bit/1bit"*) - echo "ok a 0755 payload PASSes and still prints its modes" ;; - *) echo "FAIL a healthy payload was not accepted with its modes: ${line:-}"; fail=1 ;; -esac +mktree p755 0755 +got=$(bash -c "$FN"$'\npayload_modes_noexec "$1"' _ "$ROOT/p755") +[ -z "$got" ] && echo "ok a 0755 payload reports nothing" || { echo "FAIL a healthy payload was reported: '${got}'"; fail=1; } -mkpayload pnone none -line=$(run_row pnone) -case "$line" in - PASS*"payload-modes"*) - echo "ok a payload with no binaries still PASSes (absence is another row's claim)" ;; - *) echo "FAIL a binary-less payload changed verdict: ${line:-}"; fail=1 ;; -esac +mktree pnone none +got=$(bash -c "$FN"$'\npayload_modes_noexec "$1"' _ "$ROOT/pnone") +[ -z "$got" ] && echo "ok a payload with no binaries reports nothing (absence is another row's claim)" || { echo "FAIL a binary-less payload was reported: '${got}'"; fail=1; } echo "release_check_payload_modes_test: $fail failure(s)" exit $((fail > 0)) From dea2da3ab8356231b7dcb77b4eab32363a9c3935 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sat, 14 Nov 2026 07:00:18 -0400 Subject: [PATCH 3/3] payload-modes: record why [ -x ] is the predicate and not a 0755 check --- os/mini/release-check.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/os/mini/release-check.sh b/os/mini/release-check.sh index e779579a6..c64a3eb03 100755 --- a/os/mini/release-check.sh +++ b/os/mini/release-check.sh @@ -784,6 +784,10 @@ payload_modes_noexec() { # -> the binaries present but not execu # makes hrx-placement SKIP (`[ -x ]` cannot find a runnable engine), so the check was green over a payload that cannot run. # Absence is deliberately NOT an offender: a binary that is not here is hrx-device's or identity's claim, and a payload still # being extracted is caught by the entry floor above. + # + # `[ -x ]` is the right predicate and NOT a stricter "is it 0755" (engine#2424's phrasing, worth keeping): the appliance runs as + # root, and access(2) documents that a real UID of zero passes X_OK "if execute permission is enabled for any of the file owner, + # group, or other". So the property is *can it execute*, which is exactly what the row that would start the engine tests. _pe_dir=${1:-} _pe_out= for _pe_b in "$_pe_dir/1bit/1bit" "$_pe_dir/bin/lemond" "$_pe_dir/lemond-onebit"; do [ -f "$_pe_b" ] || continue