From b18ea1f2316e2221c0cb744aca57f42aab1ba4d8 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sun, 8 Nov 2026 09:25:41 -0400 Subject: [PATCH] os: the payload's modes are files AND directories, because 49 directories were writable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The row counted files only. Measured 2026-11-08 on c32's *shipped* SFS: **134 writable files under `opt/1bit-package` and 49 group-writable directories** - 183 paths, not 134 - so a payload could re-grow writable directories and this row would still PASS. That is the same too-narrow shape as the `/home/`-only, `1bit`-only and `^/home/`-anchored checks this week: `-type f` was the narrowness. It is not hypothetical: the c33 cut's first image had **0 writable files and 1 writable directory** - the payload root at `0775`, because `tar -x` creates the top directory with the caller's umask while every entry below carries the archive's stored modes. So the row counts both, says which in its verdict, and prints the offender's mode (`drwxrwxr-x .`) instead of only a count. Verified against the real artifacts: c32's payload -> `FAIL 134 file(s) and 49 dir(s)`; the c33 first cut -> `FAIL 0 file(s) and 1 dir(s) … drwxrwxr-x .`; a clean payload -> PASS. Harness `rowproof-payload-modes.sh` 13/13, including a writable-ROOT-only case and a writable-file case, with fixtures created under `umask 022` so the test cannot borrow the bug it is looking for. --- os/mini/release-check.sh | 41 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/os/mini/release-check.sh b/os/mini/release-check.sh index 14a27ae24..648f90a75 100755 --- a/os/mini/release-check.sh +++ b/os/mini/release-check.sh @@ -570,14 +570,20 @@ hrx_placement_verdict() { # files 0755 if executable else 0644) and assert it, so THIS row is the board-side proof that it did: a payload packed after that # commit has no writable file, and a payload packed before it has 134. Pure, so --self-test drives it: # [] -payload_modes_verdict() { - _n=${1:-} _sample=${2:-} - case "$_n" in ''|*[!0-9]*) printf 'FAIL the payload'"'"'s modes could not be counted (%s)' "${_n:-empty}"; return 0 ;; esac - if [ "$_n" = 0 ]; then - printf 'PASS no file in the payload is group- or other-writable (engine #1352: the packer normalises, this is the proof)' +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 + case "$_d" in ''|*[!0-9]*) printf 'FAIL the payload'"'"'s directory modes could not be counted (%s)' "${_d:-empty}"; return 0 ;; esac + if [ "$_f" = 0 ] && [ "$_d" = 0 ]; then + printf 'PASS no path in the payload is group- or other-writable - neither a file nor a directory (engine #1352: the packer normalises, this is the proof)' else - printf 'FAIL %s file(s) in the payload are group- or other-writable%s - the packer that stages with cp -a is shipping inherited modes again (engine #1352: the fix is in scripts/package-linux.sh / pack-elf.sh, not in this row)' \ - "$_n" "${_sample:+: $_sample}" + # FILES AND DIRECTORIES BOTH COUNT. The first version of this row counted files only, which was the same "too narrow" shape as + # the /home/-only and 1bit-only checks: measured 8 Nov, c32's shipped payload had **134 writable files AND 49 writable + # directories** (183 paths, not 134), so a files-only row would pass a payload that had re-grown writable directories - and + # the c33 cut's first image did exactly that (0 files, 1 directory: the payload root at 0775, because `tar -x` creates the + # top directory with the caller's umask while every entry below it carries the archive's stored modes). + printf 'FAIL %s file(s) and %s dir(s) in the payload are group- or other-writable%s - a packing site is not normalising (engine #1352: the fix is in scripts/package-linux.sh / pack-elf.sh, and for an unpacked payload the extraction root is the usual one)' \ + "$_f" "$_d" "${_sample:+: $_sample}" fi } @@ -643,11 +649,13 @@ if [ "${1:-}" = --self-test ]; then check FAIL "$(payload_runpath_verdict 1)" check FAIL "$(payload_runpath_verdict '')" # engine #1352: the payload's modes. c31/c32 shipped 134 writable files; a payload packed after #1361 has none. - check PASS "$(payload_modes_verdict 0)" - check FAIL "$(payload_modes_verdict 134)" - check FAIL "$(payload_modes_verdict 1 '/opt/1bit-package/1bit/1bit')" - check FAIL "$(payload_modes_verdict '')" - check FAIL "$(payload_modes_verdict 'x')" + check PASS "$(payload_modes_verdict 0 0)" + check FAIL "$(payload_modes_verdict 134 49)" # c31/c32's real shape: 134 files AND 49 directories + check FAIL "$(payload_modes_verdict 0 1)" # the c33 first cut: no files, the payload ROOT writable + check FAIL "$(payload_modes_verdict 1 0 '/opt/1bit-package/1bit/1bit')" + check FAIL "$(payload_modes_verdict '' 0)" + check FAIL "$(payload_modes_verdict 0 '')" + check FAIL "$(payload_modes_verdict x 0)" # c32: the HRX weight placement. The measured arms from #1339 are the first two; the failure shapes are a default # that already imported (2), an unreadable arm, and a zero. check PASS "$(hrx_placement_verdict 5692 3010)" # 4B perplexity, #1339 @@ -1701,11 +1709,14 @@ PDIR=${PAYLOAD_DIR:-/opt/1bit-package} if [ ! -d "$PDIR" ]; then skip payload-modes "no $PDIR on this system: the payload is not unpacked where an appliance keeps it, so its modes cannot be read" else - _pm_n=$(find "$PDIR" -type f \( -perm -g+w -o -perm -o+w \) 2>/dev/null | wc -l) + _pm_f=$(find "$PDIR" -type f \( -perm -g+w -o -perm -o+w \) 2>/dev/null | wc -l) + _pm_d=$(find "$PDIR" -mindepth 0 -type d \( -perm -g+w -o -perm -o+w \) 2>/dev/null | wc -l) # the sample is relative to the payload, like the modes below it: an absolute path per file makes a long line on a console # nobody can scroll, and the prefix is identical for every one of them - _pm_s=$(find "$PDIR" -type f \( -perm -g+w -o -perm -o+w \) 2>/dev/null | head -3 | sed "s|^$PDIR/||" | tr '\n' ' ') - PM=$(payload_modes_verdict "${_pm_n:-}" "${_pm_s:-}") + # the sample prints the mode too, because "writable" is not actionable and `drwxrwxr-x opt/1bit-package` is + _pm_s=$(find "$PDIR" -mindepth 0 \( -type f -o -type d \) \( -perm -g+w -o -perm -o+w \) 2>/dev/null | head -3 | + 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= 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/||")"