From 8bc3af2b283b6982feecb7e866660af6134688c0 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Fri, 16 Oct 2026 22:05:50 -0500 Subject: [PATCH 01/11] gates: clean-clone copies and logs live in a private mkdtemp folder, not fixed /tmp paths (#526) Hypothesis that held: M18 gate 16 (chained by M19 gate 17) copied the repo to /tmp/omega_clean_m18 and wrote /tmp/clean_clone_m18.log. Both names are shared by every user of the machine, and /tmp is sticky, so whoever ran second lost: the Spark judge (user aien-run) hit "cannot create /tmp/clean_clone_m18.log: Permission denied" on a log Drake's account left on 2026-10-06 (judge run cf5495d0, M19 FAIL REGRESSION 158/159), and an operator run from Drake's account hit "rm: cannot remove /tmp/omega_clean_m18/...: Permission denied" on the 636 MB copy the judge left on 2026-10-16. Not a sandbox rule: the sandbox writes to /tmp fine (M19's mkdtemp clones from the same runs are there). M18 now does what M19 already did: mkdtemp("$TMPDIR|/tmp/omega_clean_m18_XXXXXX"), copy into /checkout, log to /clean_clone_m18.log, and print that path on failure so the receipt names it. Both M18 and M19 remove the built checkout after the nested run (hundreds of MB each; five M19 copies from one day were in /tmp, disk at 83%) and keep the log. Red: judge receipt blob for M19 in cf5495d0 and the rm refusal reproduced from Drake's account on 2026-10-17. Green: the Spark judge's M18/M19 gates on this head; they also need the channel-create fix (aien-dev/physics-mv#64), so this ships with the physics.lock bump. Co-Authored-By: Claude Fable 5.1 Co-authored-by: Drake Stapleton --- src/omega_blackwell_gates.c | 42 ++++++++++++++++++++++++++++++------- src/omega_world_gates.c | 22 ++++++++++++++++--- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/src/omega_blackwell_gates.c b/src/omega_blackwell_gates.c index 5c7634b41..8e6da5f00 100644 --- a/src/omega_blackwell_gates.c +++ b/src/omega_blackwell_gates.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "omega_physics_dir.h" static int m17_gate_count = 0; @@ -975,31 +976,58 @@ fail: return false; } +/* Remove the built copy a clean-clone gate made under its private folder; the + * log beside it stays for the reader. Hundreds of MB per run otherwise pile up + * in /tmp (omega#526). */ +static void m18_clean_clone_remove_checkout(const char *clone) { + char cmd[PATH_MAX + 32]; + int n = snprintf(cmd, sizeof(cmd), "rm -rf -- '%s/checkout'", clone); + if (n < 0 || (size_t)n >= sizeof(cmd)) return; + int rc = system(cmd); + (void)rc; +} + static bool test_m18_gate16_clean_clone(void) { if (getenv("OMEGA_IN_CLEAN_CLONE") != NULL) { return true; } /* Copy the repo this omegatool runs from (the code under test), not a * hardcoded checkout, and pass the PHYSICS_DIR this process resolves at run time - * (omega_physics_dir.h) as an absolute path so the copy in /tmp does not fall back to - * the Makefile default ../physics (= /tmp/physics). Mirrors M19. */ + * (omega_physics_dir.h) as an absolute path so the copy does not fall back to + * the Makefile default ../physics. Mirrors M19. + * + * The copy and its log live in a private mkdtemp folder (omega#526). A fixed + * /tmp path is shared by every user of the machine, and the sticky /tmp lets + * neither the judge user nor the operator remove or overwrite what the other + * left behind ("rm: Permission denied", "cannot create ...log: Permission denied"), + * so the gate failed for whoever ran second. */ char physics_dir_resolved[PATH_MAX], physics_err[OMEGA_PHYSICS_ERR_SIZE]; if (!omega_physics_dir_resolve_pinned(physics_dir_resolved, sizeof(physics_dir_resolved), 0, physics_err, sizeof(physics_err))) { fprintf(stderr, "%s\n", physics_err); return false; } + const char *tmp = getenv("TMPDIR"); + if (!tmp || !*tmp) tmp = "/tmp"; + char clone[PATH_MAX]; + int cl = snprintf(clone, sizeof(clone), "%s/omega_clean_m18_XXXXXX", tmp); + if (cl < 0 || (size_t)cl >= sizeof(clone)) return false; + if (!mkdtemp(clone)) { + fprintf(stderr, "M18 clean clone: mkdtemp %s: %s\n", clone, strerror(errno)); + return false; + } char command[4608]; int len = snprintf(command, sizeof(command), "root=$(git rev-parse --show-toplevel) && " - "rm -rf /tmp/omega_clean_m18 && " - "cp -r \"$root\" /tmp/omega_clean_m18 && " - "cd /tmp/omega_clean_m18 && " + "cp -r \"$root\" '%s/checkout' && " + "cd '%s/checkout' && " "make clean >/dev/null 2>&1 && " "make -j PHYSICS_DIR='%s' >/dev/null 2>&1 && " - "OMEGA_IN_CLEAN_CLONE=1 ./build/omegatool --run-m18-gates >/tmp/clean_clone_m18.log 2>&1", - physics_dir_resolved); + "OMEGA_IN_CLEAN_CLONE=1 ./build/omegatool --run-m18-gates >'%s/clean_clone_m18.log' 2>&1", + clone, clone, physics_dir_resolved, clone); if (len < 0 || (size_t)len >= sizeof(command)) return false; int rc = system(command); + if (rc != 0) fprintf(stderr, "M18 clean clone failed (rc %d); log: %s/clean_clone_m18.log\n", rc, clone); + m18_clean_clone_remove_checkout(clone); return (rc == 0); } diff --git a/src/omega_world_gates.c b/src/omega_world_gates.c index e0f6d310c..0a4ecbe62 100644 --- a/src/omega_world_gates.c +++ b/src/omega_world_gates.c @@ -1759,6 +1759,16 @@ static bool test_m19_gate15_zero_libcuda(void) { return true; } +/* Remove the built copy under the private clone folder; qualification.log stays + * beside it (omega#526: five such copies per day filled /tmp). */ +static void m19_clean_clone_remove_checkout(const char *checkout) { + char cmd[600]; + int n = snprintf(cmd, sizeof(cmd), "rm -rf -- '%s'", checkout); + if (n < 0 || (size_t)n >= sizeof(cmd)) return; + int rc = system(cmd); + (void)rc; +} + /* Gate 16: OMEGA_ACCEL_RESIDENT_CLEAN_CLONE_PASS */ static bool test_m19_gate16_clean_clone(void) { char src_sha[41] = {0}; @@ -1803,12 +1813,18 @@ static bool test_m19_gate16_clean_clone(void) { "OMEGA_IN_CLEAN_CLONE=1 ./build/omegatool --run-m19-gates >%s/qualification.log 2>&1", checkout, checkout, src_sha, physics_dir_resolved, clone); if (len < 0 || (size_t)len >= sizeof(command)) return false; - if (system(command) != 0) return false; + int rc = system(command); + if (rc != 0) { + fprintf(stderr, "M19 clean clone failed (rc %d); log: %s/qualification.log\n", rc, clone); + m19_clean_clone_remove_checkout(checkout); + return false; + } /* The built checkout must be exactly the named candidate revision. */ char clone_sha[41] = {0}; - if (!m19_git_head(checkout, clone_sha)) return false; - if (strcmp(clone_sha, src_sha) != 0) return false; + bool same = m19_git_head(checkout, clone_sha) && strcmp(clone_sha, src_sha) == 0; + m19_clean_clone_remove_checkout(checkout); + if (!same) return false; memcpy(m19_candidate_commit, src_sha, sizeof(m19_candidate_commit)); return true; From 8eedc34a97f6ba104c5aad9332cab6d0196678fb Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Fri, 16 Oct 2026 22:06:08 -0500 Subject: [PATCH 02/11] crumb: recompile after src/omega_blackwell_gates.c and src/omega_world_gates.c (#526) Co-Authored-By: Claude Fable 5.1 Co-authored-by: Drake Stapleton --- src/.crumb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/.crumb b/src/.crumb index 4fe5298a4..94e9f39eb 100644 --- a/src/.crumb +++ b/src/.crumb @@ -182,14 +182,14 @@ } ], "children_root": "sha256:15012a017b26a269feb256b64875ece2912f5f82c57804baafa3777c4fcb80b9", - "compiled_at": "2026-10-16T07:33:43Z", + "compiled_at": "2026-10-17T03:06:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:dfa36de2ac8649f66f80587abea51a7f166285ee0b92e0e09774c98689055250", + "digest": "sha256:e2f18fa3911a9c29bbb65a663715bcca30769d1bddef2c33b28a3869582d6538", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 537, - "generated_at_commit": "1d481ab853a14d3c11eff926ce1e25993085f76a", - "source_tree": "sha256:200c9243151691313acb5f86d3e9cb3058f1a1b92ece2a255b3340b691dfb894" + "generated_at_commit": "125d55897c85a05fe1d26d9f0e7acd78fd86e577", + "source_tree": "sha256:6b6abccff82effd780389017a14312a55ef8aef02d43b36e77c8a86716361ab7" }, "owner_lane": "", "provenance": { From 332bda3771a8bb0af475ea1e6fafdea69e6761ab Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Fri, 16 Oct 2026 22:13:15 -0500 Subject: [PATCH 03/11] r11 own-hold test: a load refusal is not the flag refusal; wait for quiet, never pass a skip OMEGA-R11-OWN-HOLD failed on every Spark judge run since the pipeline started running ~20 host gates at once. The q1-abc case wants the R11 living run to start inside its own quiet hold, but rx_r11_aien.c other_load() also refuses the living run when the 1-minute load average is above 2 (SKIPPED-LOADED). The test counted any refusal as the flag refusal, so a loaded machine read as "refused, want ran" (red reproduced at load 4.5, same line as the judge). Now the test tells the two reasons apart by the binary's own text: - flag refusal ("holds ~/workspace/.spark-quiet") is the refusal under test; - a load refusal on the q1-abc case waits for load <= 2 (15 s polls, at most R11_QUIET_WAIT s, default 1800, inside the gate's 60 min timeout) and runs again. If the machine never quiets the case still fails ("loaded, want ran"): a skipped living run is never a pass. - a load refusal on a case that must be refused by the flag now fails (the flag was accepted as ours), which the old test could not see. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit aae8d114d0dc769eeec11037781f1bd69baf0cf4) --- tests/runtime/r11_own_hold_test.sh | 34 ++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/tests/runtime/r11_own_hold_test.sh b/tests/runtime/r11_own_hold_test.sh index d16128cc1..13325f0b9 100755 --- a/tests/runtime/r11_own_hold_test.sh +++ b/tests/runtime/r11_own_hold_test.sh @@ -2,17 +2,43 @@ # R11 living run inside its own quiet hold (tests/runtime/rx_r11_aien.c # quiet_flag_is_mine). With a fake HOME whose ~/workspace/.spark-quiet carries # hold=q1-abc: no QUIETLOCK_HOLD, a prefix and an extension of the id must all -# refuse the living run (someone else's measurement); QUIETLOCK_HOLD=q1-abc -# must run it. usage: r11_own_hold_test.sh +# refuse the living run because of the flag (someone else's measurement); +# QUIETLOCK_HOLD=q1-abc must run it. +# +# The binary also refuses the living run when the machine is loaded (1-minute +# load average above 2, or an R15 program alive): "SKIPPED-LOADED: ". +# Only the flag reason counts as the refusal this test is about. When the +# q1-abc case is refused for load, the test waits for the machine to quiet down +# and runs it again, for at most R11_QUIET_WAIT seconds (default 1800). If the +# machine never quiets, the case stays a failure: a skipped living run is never +# a pass. usage: r11_own_hold_test.sh B=${1:?rx_r11_aien_test binary}; H=$(mktemp -d); fail=0 +WAIT=${R11_QUIET_WAIT:-1800} trap 'rm -rf "$H"' EXIT mkdir -p "$H/workspace" echo "other quietlock X start=2026-10-05T00:00:00Z expected_end=2099-01-01T00:00:00Z pid=1 hold=q1-abc" > "$H/workspace/.spark-quiet" +FLAG_WHY='holds ~/workspace/.spark-quiet' + +load_ok() { awk '{ exit !($1 <= 2.0) }' /proc/loadavg; } + for hold in "" q1-ab q1-abcd q1-abc; do - out=$(HOME=$H QUIETLOCK_HOLD=$hold "$B" 2>&1) - if printf '%s\n' "$out" | grep -Fq "living run not exercised"; then got=refused; else got=ran; fi if [ "$hold" = q1-abc ]; then want=ran; else want=refused; fi + waited=0 + while :; do + out=$(HOME=$H QUIETLOCK_HOLD=$hold "$B" 2>&1) + if ! printf '%s\n' "$out" | grep -Fq "living run not exercised"; then got=ran + elif printf '%s\n' "$out" | grep -Fq "$FLAG_WHY"; then got=refused + else got=loaded; fi + [ "$got" = loaded ] && [ "$want" = ran ] && [ "$waited" -lt "$WAIT" ] || break + why=$(printf '%s\n' "$out" | sed -n 's/^\[-\] SKIPPED-LOADED: living run not started: //p' | head -n 1) + echo "[~] hold='$hold': living run refused for load ($why), waiting for a quiet machine (${waited}s of ${WAIT}s)" + while [ "$waited" -lt "$WAIT" ]; do + sleep 15; waited=$((waited + 15)) + load_ok && break + done + done printf '%s\n' "$out" | grep -Eq '^checks [0-9]+ failures 0$' || { got="$got+failures"; } if [ "$got" = "$want" ]; then echo "[+] hold='$hold': $got"; else echo "[-] hold='$hold': $got, want $want"; fail=$((fail + 1)); fi + [ "$got" = loaded ] && printf '%s\n' "$out" | grep -F "SKIPPED-LOADED" | head -n 1 done echo "failures $fail"; [ "$fail" = 0 ] From a6360ea7f13508bf80e65ef7837ccbaa10671045 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sun, 18 Oct 2026 16:34:57 -0500 Subject: [PATCH 04/11] gates: clean-clone nested build ignores the per-step OUT_DIR (#526) tests/gates/run.sh exports OUT_DIR=build/step- (#511). The M18 and M19 clean-clone gates run make inside their private copy and then ./build/omegatool; with OUT_DIR inherited the binary lands at $OUT_DIR/omegatool and sh exits 127 ("./build/omegatool: not found"). The judge run of e466b138 failed M19 that way (rc 32512 for both clean clones, REGRESSION 158/159). The nested command now unsets OUT_DIR; the copy is private, so it needs no per-step build directory. Co-Authored-By: Claude --- src/omega_blackwell_gates.c | 9 ++++++++- src/omega_world_gates.c | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/omega_blackwell_gates.c b/src/omega_blackwell_gates.c index 8e6da5f00..669466718 100644 --- a/src/omega_blackwell_gates.c +++ b/src/omega_blackwell_gates.c @@ -1000,7 +1000,13 @@ static bool test_m18_gate16_clean_clone(void) { * /tmp path is shared by every user of the machine, and the sticky /tmp lets * neither the judge user nor the operator remove or overwrite what the other * left behind ("rm: Permission denied", "cannot create ...log: Permission denied"), - * so the gate failed for whoever ran second. */ + * so the gate failed for whoever ran second. + * + * OUT_DIR is unset for the nested build: tests/gates/run.sh exports a per-step + * OUT_DIR (omega#511), so `make` in the copy would put the binary at + * $OUT_DIR/omegatool and "./build/omegatool" would not exist (sh exit 127 in + * the judge run of e466b138, omega#526). The copy is private, so it needs no + * per-step build directory. */ char physics_dir_resolved[PATH_MAX], physics_err[OMEGA_PHYSICS_ERR_SIZE]; if (!omega_physics_dir_resolve_pinned(physics_dir_resolved, sizeof(physics_dir_resolved), 0, physics_err, sizeof(physics_err))) { fprintf(stderr, "%s\n", physics_err); @@ -1017,6 +1023,7 @@ static bool test_m18_gate16_clean_clone(void) { } char command[4608]; int len = snprintf(command, sizeof(command), + "unset OUT_DIR; " "root=$(git rev-parse --show-toplevel) && " "cp -r \"$root\" '%s/checkout' && " "cd '%s/checkout' && " diff --git a/src/omega_world_gates.c b/src/omega_world_gates.c index 0a4ecbe62..fec5eb309 100644 --- a/src/omega_world_gates.c +++ b/src/omega_world_gates.c @@ -1806,9 +1806,12 @@ static bool test_m19_gate16_clean_clone(void) { return false; } + /* OUT_DIR is unset for the nested build so the copy builds ./build/omegatool: + * tests/gates/run.sh exports a per-step OUT_DIR (omega#511) that would move the + * binary to $OUT_DIR/omegatool (sh exit 127, omega#526). */ char command[4608]; int len = snprintf(command, sizeof(command), - "git clone --quiet --no-hardlinks . %s && cd %s && git checkout --quiet %s && " + "unset OUT_DIR; git clone --quiet --no-hardlinks . %s && cd %s && git checkout --quiet %s && " "make clean >/dev/null 2>&1 && make -j PHYSICS_DIR=%s >/dev/null 2>&1 && " "OMEGA_IN_CLEAN_CLONE=1 ./build/omegatool --run-m19-gates >%s/qualification.log 2>&1", checkout, checkout, src_sha, physics_dir_resolved, clone); From 5b3a23c4031575028bee281dd40c272d5046e28f Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sun, 18 Oct 2026 16:37:33 -0500 Subject: [PATCH 05/11] gates: M19 receipt gate hashes the running binary, not build/omegatool (#526) With the per-step OUT_DIR (#511) the binary under test is $OUT_DIR/omegatool; a fresh judge worktree has no build/omegatool, so gate 18 failed with 17/17 M19 gates and 159/159 regression gates passing (sandbox run of 47f982be). Hash /proc/self/exe instead. Co-Authored-By: Claude --- src/omega_world_gates.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/omega_world_gates.c b/src/omega_world_gates.c index fec5eb309..b647b6e3f 100644 --- a/src/omega_world_gates.c +++ b/src/omega_world_gates.c @@ -1883,9 +1883,13 @@ static bool test_m19_gate18_receipt(void) { if (!candidate || strcmp(candidate, head_sha) != 0 || omega_evidence_tree_dirty()) return false; } + /* Hash the binary that is running these gates. Under tests/gates/run.sh it is + * $OUT_DIR/omegatool (per-step build dir, omega#511), so the fixed path + * build/omegatool does not exist in a fresh judge worktree and this gate + * failed with every other gate passing (omega#526). */ uint8_t digest[32]; char hex[65]; - return compute_file_sha256("build/omegatool", digest, hex); + return compute_file_sha256("/proc/self/exe", digest, hex); } int run_m19_gates(void) { From 39c51c7eda8cafff03e113bdbf76f9dcfb3a3602 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sun, 18 Oct 2026 16:37:55 -0500 Subject: [PATCH 06/11] crumb: recompile (pinned tool d0f0b95d) After the two #526 gate fixes, and for tests/ and tests/runtime/, which were already stale on e466b138 (the r11 test commit landed after the last recompile; crumb verify there: 3 of 157 stale). --- src/.crumb | 8 ++++---- tests/.crumb | 14 +++++++------- tests/runtime/.crumb | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/.crumb b/src/.crumb index 94e9f39eb..3d1343f87 100644 --- a/src/.crumb +++ b/src/.crumb @@ -182,14 +182,14 @@ } ], "children_root": "sha256:15012a017b26a269feb256b64875ece2912f5f82c57804baafa3777c4fcb80b9", - "compiled_at": "2026-10-17T03:06:04Z", + "compiled_at": "2026-10-18T21:37:52Z", "compiler": "crumb-compile/1", - "digest": "sha256:e2f18fa3911a9c29bbb65a663715bcca30769d1bddef2c33b28a3869582d6538", + "digest": "sha256:acd1bee1bed884a4b69be04a31ad6ac089632a5ba24497ceadbe5e75ebb86c0d", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 537, - "generated_at_commit": "125d55897c85a05fe1d26d9f0e7acd78fd86e577", - "source_tree": "sha256:6b6abccff82effd780389017a14312a55ef8aef02d43b36e77c8a86716361ab7" + "generated_at_commit": "11166a26d30bb96a833e0206440cdcfeddd4c2ad", + "source_tree": "sha256:71ac45597c0044ea137bc14222f87567796b1d58381f48b8d52ab27ac84477b9" }, "owner_lane": "", "provenance": { diff --git a/tests/.crumb b/tests/.crumb index bd5535a8b..44abd920b 100644 --- a/tests/.crumb +++ b/tests/.crumb @@ -265,8 +265,8 @@ "purpose": "Reservoir tests (omega#440): Gate 1 simulator and readout checks against an independent binary64" }, { - "digest": "bc2b514054f69604a155900fb1884948a78e12b88a15852296cbea1f751055b2", - "last_commit": "501d555c", + "digest": "8d9902bfef6302ea10880ea50d88ef5d6b8bf2619e9c10b3a756968421bedbbb", + "last_commit": "e466b138", "name": "runtime", "purpose": "Directory tests/runtime. Purpose not yet described by a human." }, @@ -295,15 +295,15 @@ "purpose": "Directory tests/visor. Purpose not yet described by a human." } ], - "children_root": "sha256:ddc3618190458bc5073e3bee67ffccc68a2ee9f065f2cb0d86545386a29fddf8", - "compiled_at": "2026-10-16T19:04:20Z", + "children_root": "sha256:4aee8c2d8f21fd9452fadad70e84057e0b44f93e85fe1bebb34074676f999ad2", + "compiled_at": "2026-10-18T21:37:52Z", "compiler": "crumb-compile/1", - "digest": "sha256:4eb9d4d76234448c0ed691f0aeb9c90d785f8a47b1b1291d728bbe3e1509dc10", + "digest": "sha256:c610d329879c01df4bdbc5d8621ed28e79a491484646c800508fe712348a3111", "evidence_files": 16, "evidence_root": "sha256:96d08097822ad95f4e562c19e0ba5df5a035774c48632f1832912c40a27bd27a", "files": 1270, - "generated_at_commit": "88e24bdd57b27817d030d0ad95f62c3f3eacf426", - "source_tree": "sha256:e6c4f0021d383ba2e59da0d85d06a0b98170f6d188289c891b5745200548e6fc" + "generated_at_commit": "11166a26d30bb96a833e0206440cdcfeddd4c2ad", + "source_tree": "sha256:4df4909f694a2a9646ec5ad92e5c444fc79174a72e7ed1cf7aaeaa00bfccff38" }, "owner_lane": "", "provenance": { diff --git a/tests/runtime/.crumb b/tests/runtime/.crumb index 48918ae9f..3652a3a24 100644 --- a/tests/runtime/.crumb +++ b/tests/runtime/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-13T02:12:57Z", + "compiled_at": "2026-10-18T21:37:52Z", "compiler": "crumb-compile/1", - "digest": "sha256:bc2b514054f69604a155900fb1884948a78e12b88a15852296cbea1f751055b2", + "digest": "sha256:8d9902bfef6302ea10880ea50d88ef5d6b8bf2619e9c10b3a756968421bedbbb", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 70, - "generated_at_commit": "95829f2abd7f66461b4ba153ea807f39e9d06db8", - "source_tree": "sha256:e037c5156071865094d0e60262d34ca920be2dd6f98e2603a1f0082330ba7841" + "generated_at_commit": "11166a26d30bb96a833e0206440cdcfeddd4c2ad", + "source_tree": "sha256:2b9d483a1f8068dfe689b5457e6d9f4a9bc928626e4ae525030f12b74609f0f3" }, "owner_lane": "", "provenance": { From 4d0d54d32b3f3bf9a9aba6e3e60d5902bed4f168 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sun, 18 Oct 2026 17:40:36 -0500 Subject: [PATCH 07/11] crumb compile (after rebase onto main) Co-authored-by: Drake Stapleton Co-Authored-By: Claude Fable 5.1 --- .crumb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.crumb b/.crumb index d121d2dad..b631150c4 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ "purpose": "Directory spec. Purpose not yet described by a human." }, { - "digest": "dfa36de2ac8649f66f80587abea51a7f166285ee0b92e0e09774c98689055250", - "last_commit": "333091a6", + "digest": "acd1bee1bed884a4b69be04a31ad6ac089632a5ba24497ceadbe5e75ebb86c0d", + "last_commit": "5b3a23c4", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { - "digest": "4eb9d4d76234448c0ed691f0aeb9c90d785f8a47b1b1291d728bbe3e1509dc10", - "last_commit": "88e24bdd", + "digest": "c610d329879c01df4bdbc5d8621ed28e79a491484646c800508fe712348a3111", + "last_commit": "332bda37", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, @@ -95,15 +95,15 @@ "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:e1a8c008214ad5dbc33a3e184d7e882dc56d1d50f9bd14c58f8773992961557e", - "compiled_at": "2026-10-18T21:10:38Z", + "children_root": "sha256:4597c990109dcd3e547565639cb5ed1b760c58ba5e59afe59a0815f6c95ab7a6", + "compiled_at": "2026-10-18T22:40:32Z", "compiler": "crumb-compile/1", - "digest": "sha256:be7220db494238bb4c33023d1df17286c35f947336bee5fc2e0405c136ec3e73", + "digest": "sha256:2b6c03004819f0f5230e7e1deb20a5a91b8f081d0349bcc4ce5cf2820399b362", "evidence_files": 11127, "evidence_root": "sha256:4528085ec1661c442b64fb5dc8def65067ea2620ff88e42bcf52d58b7642ea6e", "files": 14100, - "generated_at_commit": "f4a9849fb127f8d2d664dfc56890752ad180c507", - "source_tree": "sha256:21f93defce6c9ba159a4bd31083db787e156dfaa4afb80c3427cf88f732f8258" + "generated_at_commit": "39c51c7eda8cafff03e113bdbf76f9dcfb3a3602", + "source_tree": "sha256:67f7c770efed174f3f8ca4a1d221a031a3dcba4f5ef8bc0ba8f7631fc52213ae" }, "owner_lane": "", "provenance": { From 99f944a4f60203905ffeb9161b720935567de26b Mon Sep 17 00:00:00 2001 From: "Hermes (desk)" Date: Sun, 18 Oct 2026 18:39:13 -0500 Subject: [PATCH 08/11] gates: clean-clone helpers run no shell; remove trees with a file walk (#565) CodeQL flagged the clean-clone gates (cpp/uncontrolled-process-operation, cpp/command-line-injection; alerts 544-547): the M18 and M19 build steps and the new checkout cleanup built a command string with the clone path and PHYSICS_DIR pasted in and handed it to system(). The clone path comes from TMPDIR, so a quote or shell metacharacter in it changed what the shell ran. Now no path is ever pasted into a command: - src/omega_clean_clone.{c,h}: omega_cc_run (fork + execvp with an argument vector, OUT_DIR removed and OMEGA_IN_CLEAN_CLONE set only in the child, output to a file), omega_cc_capture_line (one line of stdout, no shell), omega_cc_remove_tree (nftw FTW_DEPTH|FTW_PHYS|FTW_MOUNT with unlink/rmdir; never follows a symlink; refuses "/", relative and non-plain paths). - M18 gate 16 and M19 gate 16 run cp / git clone, git checkout, make clean, make, and the nested omegatool as separate programs. Paths outside [A-Za-z0-9/._+-] are refused before anything runs (fail closed), since make would also expand a '$' in PHYSICS_DIR=. - Both checkout cleanups use omega_cc_remove_tree; m19_git_head no longer uses popen. - The helper is kept out of GPU_API_OBJS like the gate objects. Tested: build with -Werror; 29 helper checks under ASan/UBSan, including a hostile path passed as data that runs nothing, and a symlink to an outside file and directory that survives the tree removal. --- Makefile | 4 +- src/omega_blackwell_gates.c | 61 +++++++++++----- src/omega_clean_clone.c | 136 ++++++++++++++++++++++++++++++++++++ src/omega_clean_clone.h | 39 +++++++++++ src/omega_world_gates.c | 60 +++++++++------- 5 files changed, 255 insertions(+), 45 deletions(-) create mode 100644 src/omega_clean_clone.c create mode 100644 src/omega_clean_clone.h diff --git a/Makefile b/Makefile index 3551fea3f..e22ae924c 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ SRCS = src/sha256.c src/omega_canonical.c src/omega_validate.c src/omega_core.c src/omega_matvec.c src/omega_accelerator.c src/omega_accelerator_world.c \ src/omega_vector.c src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c \ src/omega_blackwell_realize.c src/omega_blackwell_submit.c src/omega_blackwell_engine.c src/omega_gpu_engine.c src/omega_blackwell_gates.c src/omega_blackwell_matmul.c src/omega_blackwell_codegen.c src/omega_gpu_session.c src/omega_gpu_platform.c src/omega_gpu_platform_linux.c src/omega_gpu_fmt.c src/omega_gpu_matmul_api.c src/omega_gpu_elementwise_api.c src/omega_gpu_attention_api.c src/omega_gpu_serving.c src/omega_world_gates.c src/omega_gpu_wait.c \ - src/omega_evidence.c \ + src/omega_evidence.c src/omega_clean_clone.c \ $(PHYSICS_DIR)/m16/m16_native.c $(PHYSICS_DIR)/nvrm/nvrm.c \ tools/omegatool.c # OWN-30B cut 2 (2026-10-13): column windows over a resident bf16 tensor for the MoE path. New file, @@ -2387,7 +2387,7 @@ test-vc-bridge: tests/test_omega_vc_bridge.c src/omega_vc_bridge.c src/omega_vc_ # they compile the physics checkout path into the object (-DOMEGA_PHYSICS_DIR), which made the # archive digest depend on where physics was checked out. Without them libomega_gpu.a is # byte-identical for any PHYSICS_DIR and any omega checkout directory. -GPU_API_OBJS = $(filter-out $(OUT_DIR)/omegatool.o $(OUT_DIR)/omega_blackwell_gates.o $(OUT_DIR)/omega_world_gates.o,$(OBJS)) +GPU_API_OBJS = $(filter-out $(OUT_DIR)/omegatool.o $(OUT_DIR)/omega_blackwell_gates.o $(OUT_DIR)/omega_world_gates.o $(OUT_DIR)/omega_clean_clone.o,$(OBJS)) GPU_API_TEST = $(OUT_DIR)/gpu_matmul_api_test GPU_R4_RECEIPT = $(OUT_DIR)/gpu_matmul_r4_receipt $(OUT_DIR)/libomega_gpu.a: $(GPU_API_OBJS) | check-physics-lock diff --git a/src/omega_blackwell_gates.c b/src/omega_blackwell_gates.c index 669466718..b27d7e01c 100644 --- a/src/omega_blackwell_gates.c +++ b/src/omega_blackwell_gates.c @@ -19,6 +19,8 @@ #include #include #include "omega_physics_dir.h" +#include "omega_clean_clone.h" +#include static int m17_gate_count = 0; static int m17_gate_passed = 0; @@ -980,11 +982,13 @@ fail: * log beside it stays for the reader. Hundreds of MB per run otherwise pile up * in /tmp (omega#526). */ static void m18_clean_clone_remove_checkout(const char *clone) { - char cmd[PATH_MAX + 32]; - int n = snprintf(cmd, sizeof(cmd), "rm -rf -- '%s/checkout'", clone); - if (n < 0 || (size_t)n >= sizeof(cmd)) return; - int rc = system(cmd); - (void)rc; + char checkout[PATH_MAX]; + int n = snprintf(checkout, sizeof(checkout), "%s/checkout", clone); + if (n < 0 || (size_t)n >= sizeof(checkout)) return; + /* No shell: a file-tree walk that never follows a symlink (omega#565). */ + if (omega_cc_remove_tree(checkout) != 0) { + fprintf(stderr, "M18 clean clone: could not remove %s\n", checkout); + } } static bool test_m18_gate16_clean_clone(void) { @@ -1021,19 +1025,40 @@ static bool test_m18_gate16_clean_clone(void) { fprintf(stderr, "M18 clean clone: mkdtemp %s: %s\n", clone, strerror(errno)); return false; } - char command[4608]; - int len = snprintf(command, sizeof(command), - "unset OUT_DIR; " - "root=$(git rev-parse --show-toplevel) && " - "cp -r \"$root\" '%s/checkout' && " - "cd '%s/checkout' && " - "make clean >/dev/null 2>&1 && " - "make -j PHYSICS_DIR='%s' >/dev/null 2>&1 && " - "OMEGA_IN_CLEAN_CLONE=1 ./build/omegatool --run-m18-gates >'%s/clean_clone_m18.log' 2>&1", - clone, clone, physics_dir_resolved, clone); - if (len < 0 || (size_t)len >= sizeof(command)) return false; - int rc = system(command); - if (rc != 0) fprintf(stderr, "M18 clean clone failed (rc %d); log: %s/clean_clone_m18.log\n", rc, clone); + /* No shell (omega#565): each step is its own program with an argument vector, + * so nothing in TMPDIR or PHYSICS_DIR can change what runs. Paths outside the + * plain charset are refused (fail closed); make would also expand a '$'. */ + if (!omega_cc_path_is_plain(clone) || !omega_cc_path_is_plain(physics_dir_resolved)) { + fprintf(stderr, "M18 clean clone: refusing a path with characters outside [A-Za-z0-9/._+-]: %s | %s\n", + clone, physics_dir_resolved); + (void)rmdir(clone); + return false; + } + char root[PATH_MAX], checkout[PATH_MAX], log_path[PATH_MAX], physics_arg[PATH_MAX + 16]; + char *git_top[] = {"git", "rev-parse", "--show-toplevel", NULL}; + if (!omega_cc_capture_line(NULL, git_top, root, sizeof(root))) { + fprintf(stderr, "M18 clean clone: git rev-parse --show-toplevel failed\n"); + (void)rmdir(clone); + return false; + } + int n1 = snprintf(checkout, sizeof(checkout), "%s/checkout", clone); + int n2 = snprintf(log_path, sizeof(log_path), "%s/clean_clone_m18.log", clone); + int n3 = snprintf(physics_arg, sizeof(physics_arg), "PHYSICS_DIR=%s", physics_dir_resolved); + if (n1 < 0 || (size_t)n1 >= sizeof(checkout) || n2 < 0 || (size_t)n2 >= sizeof(log_path) || + n3 < 0 || (size_t)n3 >= sizeof(physics_arg)) { + (void)rmdir(clone); + return false; + } + char *cp_argv[] = {"cp", "-r", "--", root, checkout, NULL}; + char *clean_argv[] = {"make", "clean", NULL}; + char *make_argv[] = {"make", "-j", physics_arg, NULL}; + char *run_argv[] = {"./build/omegatool", "--run-m18-gates", NULL}; + const char *step = "cp"; + int rc = omega_cc_run(NULL, cp_argv, NULL, false); + if (rc == 0) { step = "make clean"; rc = omega_cc_run(checkout, clean_argv, NULL, false); } + if (rc == 0) { step = "make"; rc = omega_cc_run(checkout, make_argv, NULL, false); } + if (rc == 0) { step = "omegatool --run-m18-gates"; rc = omega_cc_run(checkout, run_argv, log_path, true); } + if (rc != 0) fprintf(stderr, "M18 clean clone failed at %s (rc %d); log: %s\n", step, rc, log_path); m18_clean_clone_remove_checkout(clone); return (rc == 0); } diff --git a/src/omega_clean_clone.c b/src/omega_clean_clone.c new file mode 100644 index 000000000..8b58b12f6 --- /dev/null +++ b/src/omega_clean_clone.c @@ -0,0 +1,136 @@ +#include "omega_clean_clone.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +bool omega_cc_path_is_plain(const char *s) { + if (!s || !*s) return false; + for (const char *p = s; *p; p++) { + char c = *p; + bool ok = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || + c == '/' || c == '.' || c == '_' || c == '+' || c == '-'; + if (!ok) return false; + } + return true; +} + +/* Child side: environment, directory, output, then exec. Never returns. */ +static void cc_child(const char *dir, char *const argv[], int out_fd, bool in_clean_clone) { + if (unsetenv("OUT_DIR") != 0) _exit(127); + if (in_clean_clone && setenv("OMEGA_IN_CLEAN_CLONE", "1", 1) != 0) _exit(127); + if (dir && chdir(dir) != 0) _exit(127); + if (dup2(out_fd, STDOUT_FILENO) < 0) _exit(127); + if (dup2(out_fd, STDERR_FILENO) < 0) _exit(127); + if (out_fd != STDOUT_FILENO && out_fd != STDERR_FILENO) close(out_fd); + execvp(argv[0], argv); + _exit(127); +} + +static int cc_wait(pid_t pid) { + int status = 0; + while (waitpid(pid, &status, 0) < 0) { + if (errno != EINTR) return -1; + } + if (WIFEXITED(status)) return WEXITSTATUS(status); + if (WIFSIGNALED(status)) return 128 + WTERMSIG(status); + return -1; +} + +int omega_cc_run(const char *dir, char *const argv[], const char *out_path, bool in_clean_clone) { + if (!argv || !argv[0]) return -1; + int out_fd = out_path ? open(out_path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644) + : open("/dev/null", O_WRONLY | O_CLOEXEC); + if (out_fd < 0) return -1; + fflush(NULL); + pid_t pid = fork(); + if (pid < 0) { + close(out_fd); + return -1; + } + if (pid == 0) cc_child(dir, argv, out_fd, in_clean_clone); + close(out_fd); + return cc_wait(pid); +} + +bool omega_cc_capture_line(const char *dir, char *const argv[], char *out, size_t out_size) { + if (!argv || !argv[0] || !out || out_size == 0) return false; + out[0] = '\0'; + int fds[2]; + if (pipe2(fds, O_CLOEXEC) != 0) return false; + int err_fd = open("/dev/null", O_WRONLY | O_CLOEXEC); + if (err_fd < 0) { + close(fds[0]); + close(fds[1]); + return false; + } + fflush(NULL); + pid_t pid = fork(); + if (pid < 0) { + close(fds[0]); + close(fds[1]); + close(err_fd); + return false; + } + if (pid == 0) { + if (dir && chdir(dir) != 0) _exit(127); + if (dup2(fds[1], STDOUT_FILENO) < 0) _exit(127); + if (dup2(err_fd, STDERR_FILENO) < 0) _exit(127); + execvp(argv[0], argv); + _exit(127); + } + close(fds[1]); + close(err_fd); + size_t used = 0; + bool overflow = false; + char buf[256]; + for (;;) { + ssize_t n = read(fds[0], buf, sizeof(buf)); + if (n < 0 && errno == EINTR) continue; + if (n <= 0) break; + for (ssize_t i = 0; i < n; i++) { + if (used + 1 < out_size) out[used++] = buf[i]; + else overflow = true; + } + } + close(fds[0]); + out[used] = '\0'; + int rc = cc_wait(pid); + char *nl = strpbrk(out, "\r\n"); + if (nl) *nl = '\0'; + else if (overflow) return false; + return rc == 0 && out[0] != '\0'; +} + +static int cc_remove_entry(const char *path, const struct stat *sb, int type, struct FTW *ftw) { + (void)sb; + (void)ftw; + int rc = (type == FTW_DP) ? rmdir(path) : unlink(path); + if (rc != 0 && errno != ENOENT) { + fprintf(stderr, "clean clone: cannot remove %s: %s\n", path, strerror(errno)); + return -1; + } + return 0; +} + +int omega_cc_remove_tree(const char *path) { + if (!omega_cc_path_is_plain(path) || path[0] != '/' || strcmp(path, "/") == 0) { + fprintf(stderr, "clean clone: refusing to remove '%s' (not a plain absolute path)\n", + path ? path : "(null)"); + return -1; + } + struct stat st; + if (lstat(path, &st) != 0) return (errno == ENOENT) ? 0 : -1; + /* FTW_DEPTH: children before their directory. FTW_PHYS: never follow a symlink, + * so a link inside the copy cannot reach outside it. FTW_MOUNT: stay on one + * file system. */ + return nftw(path, cc_remove_entry, 32, FTW_DEPTH | FTW_PHYS | FTW_MOUNT) == 0 ? 0 : -1; +} diff --git a/src/omega_clean_clone.h b/src/omega_clean_clone.h new file mode 100644 index 000000000..3c0a79b06 --- /dev/null +++ b/src/omega_clean_clone.h @@ -0,0 +1,39 @@ +#ifndef OMEGA_CLEAN_CLONE_H +#define OMEGA_CLEAN_CLONE_H + +#include +#include + +/* Process and file helpers for the M18 and M19 clean-clone gates (omega#526, #565). + * + * No shell anywhere: every child program is started with fork + execvp and an + * argument vector, and trees are removed with nftw + unlink/rmdir. A path is + * never pasted into a command string, so a quote or shell metacharacter in + * TMPDIR, PHYSICS_DIR or a clone path cannot change what runs. + * + * Fail closed: a path outside the plain charset (letters, digits, / . _ + -) + * is refused before anything runs, because it is also handed to make as + * PHYSICS_DIR= and make expands '$' in variable values. */ + +/* True when every byte of s is in [A-Za-z0-9/._+-] and s is non-empty. */ +bool omega_cc_path_is_plain(const char *s); + +/* Run argv[0] (looked up on PATH) with argv in directory dir. + * stdout and stderr go to out_path (created or truncated), or to /dev/null when + * out_path is NULL. OUT_DIR is removed from the child environment; when + * in_clean_clone is true the child also gets OMEGA_IN_CLEAN_CLONE=1. + * Returns the child's exit code, 128 + signal if it was killed, or -1 if it + * could not be started. */ +int omega_cc_run(const char *dir, char *const argv[], const char *out_path, bool in_clean_clone); + +/* Run argv in dir and capture the first line of its stdout (newline stripped) + * into out. stderr goes to /dev/null. Returns true only when the program exits + * 0 and printed a line that fit. */ +bool omega_cc_capture_line(const char *dir, char *const argv[], char *out, size_t out_size); + +/* Remove path and everything under it without following symlinks. + * Refuses an empty path, "/", a relative path, or a path outside the plain + * charset. Returns 0 when the tree is gone (or was never there), -1 otherwise. */ +int omega_cc_remove_tree(const char *path); + +#endif diff --git a/src/omega_world_gates.c b/src/omega_world_gates.c index b647b6e3f..e59bf9af7 100644 --- a/src/omega_world_gates.c +++ b/src/omega_world_gates.c @@ -18,6 +18,7 @@ #include #include #include "omega_physics_dir.h" +#include "omega_clean_clone.h" static int m19_gate_count = 0; static int m19_gate_passed = 0; @@ -38,17 +39,13 @@ static bool m19_fault_zero_device_reset = false; /* Resolve the full 40-hex revision of a working tree via git. */ static bool m19_git_head(const char *repo_dir, char out[41]) { - char cmd[512]; - int n = snprintf(cmd, sizeof(cmd), "git -C %s rev-parse HEAD 2>/dev/null", repo_dir); - if (n < 0 || (size_t)n >= sizeof(cmd)) return false; - FILE *p = popen(cmd, "r"); - if (!p) return false; - char *got = fgets(out, 41, p); - pclose(p); - if (!got) return false; - size_t len = strlen(out); - while (len > 0 && (out[len - 1] == '\n' || out[len - 1] == '\r')) out[--len] = '\0'; - return (len == 40); + /* No shell (omega#565): git gets the directory as an argument. */ + char line[64]; + char *argv[] = {"git", "-C", (char *)repo_dir, "rev-parse", "HEAD", NULL}; + if (!omega_cc_capture_line(NULL, argv, line, sizeof(line))) return false; + if (strlen(line) != 40) return false; + memcpy(out, line, 41); + return true; } static const uint32_t WORLD_SETUP_WORDS[18] = { @@ -1762,11 +1759,10 @@ static bool test_m19_gate15_zero_libcuda(void) { /* Remove the built copy under the private clone folder; qualification.log stays * beside it (omega#526: five such copies per day filled /tmp). */ static void m19_clean_clone_remove_checkout(const char *checkout) { - char cmd[600]; - int n = snprintf(cmd, sizeof(cmd), "rm -rf -- '%s'", checkout); - if (n < 0 || (size_t)n >= sizeof(cmd)) return; - int rc = system(cmd); - (void)rc; + /* No shell: a file-tree walk that never follows a symlink (omega#565). */ + if (omega_cc_remove_tree(checkout) != 0) { + fprintf(stderr, "M19 clean clone: could not remove %s\n", checkout); + } } /* Gate 16: OMEGA_ACCEL_RESIDENT_CLEAN_CLONE_PASS */ @@ -1809,16 +1805,30 @@ static bool test_m19_gate16_clean_clone(void) { /* OUT_DIR is unset for the nested build so the copy builds ./build/omegatool: * tests/gates/run.sh exports a per-step OUT_DIR (omega#511) that would move the * binary to $OUT_DIR/omegatool (sh exit 127, omega#526). */ - char command[4608]; - int len = snprintf(command, sizeof(command), - "unset OUT_DIR; git clone --quiet --no-hardlinks . %s && cd %s && git checkout --quiet %s && " - "make clean >/dev/null 2>&1 && make -j PHYSICS_DIR=%s >/dev/null 2>&1 && " - "OMEGA_IN_CLEAN_CLONE=1 ./build/omegatool --run-m19-gates >%s/qualification.log 2>&1", - checkout, checkout, src_sha, physics_dir_resolved, clone); - if (len < 0 || (size_t)len >= sizeof(command)) return false; - int rc = system(command); + /* No shell (omega#565): each step is its own program with an argument vector. + * Paths outside the plain charset are refused (fail closed). */ + if (!omega_cc_path_is_plain(checkout) || !omega_cc_path_is_plain(physics_dir_resolved)) { + fprintf(stderr, "M19 clean clone: refusing a path with characters outside [A-Za-z0-9/._+-]: %s | %s\n", + checkout, physics_dir_resolved); + return false; + } + char log_path[600], physics_arg[PATH_MAX + 16]; + int n1 = snprintf(log_path, sizeof(log_path), "%s/qualification.log", clone); + int n2 = snprintf(physics_arg, sizeof(physics_arg), "PHYSICS_DIR=%s", physics_dir_resolved); + if (n1 < 0 || (size_t)n1 >= sizeof(log_path) || n2 < 0 || (size_t)n2 >= sizeof(physics_arg)) return false; + char *clone_argv[] = {"git", "clone", "--quiet", "--no-hardlinks", ".", checkout, NULL}; + char *checkout_argv[] = {"git", "checkout", "--quiet", src_sha, NULL}; + char *clean_argv[] = {"make", "clean", NULL}; + char *make_argv[] = {"make", "-j", physics_arg, NULL}; + char *run_argv[] = {"./build/omegatool", "--run-m19-gates", NULL}; + const char *step = "git clone"; + int rc = omega_cc_run(NULL, clone_argv, NULL, false); + if (rc == 0) { step = "git checkout"; rc = omega_cc_run(checkout, checkout_argv, NULL, false); } + if (rc == 0) { step = "make clean"; rc = omega_cc_run(checkout, clean_argv, NULL, false); } + if (rc == 0) { step = "make"; rc = omega_cc_run(checkout, make_argv, NULL, false); } + if (rc == 0) { step = "omegatool --run-m19-gates"; rc = omega_cc_run(checkout, run_argv, log_path, true); } if (rc != 0) { - fprintf(stderr, "M19 clean clone failed (rc %d); log: %s/qualification.log\n", rc, clone); + fprintf(stderr, "M19 clean clone failed at %s (rc %d); log: %s\n", step, rc, log_path); m19_clean_clone_remove_checkout(checkout); return false; } From 25b052d84a65aeef50639936713bebc11168b94d Mon Sep 17 00:00:00 2001 From: "Hermes (desk)" Date: Sun, 18 Oct 2026 18:39:19 -0500 Subject: [PATCH 09/11] crumb: recompile after omega_clean_clone (#565) (pinned tool d0f0b95d) --- .crumb | 16 ++++++++-------- src/.crumb | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.crumb b/.crumb index b631150c4..4db8b1637 100644 --- a/.crumb +++ b/.crumb @@ -77,8 +77,8 @@ "purpose": "Directory spec. Purpose not yet described by a human." }, { - "digest": "acd1bee1bed884a4b69be04a31ad6ac089632a5ba24497ceadbe5e75ebb86c0d", - "last_commit": "5b3a23c4", + "digest": "09332cb22674b6dfefec1f651198bdbc67f6bb52bc1527f42c80952865f84db2", + "last_commit": "99f944a4", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, @@ -95,15 +95,15 @@ "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:4597c990109dcd3e547565639cb5ed1b760c58ba5e59afe59a0815f6c95ab7a6", - "compiled_at": "2026-10-18T22:40:32Z", + "children_root": "sha256:20d513a69a310cdc411d6c00cefdc30c4f8b9bf3dd75f26c197abac573cbd96f", + "compiled_at": "2026-10-18T23:39:16Z", "compiler": "crumb-compile/1", - "digest": "sha256:2b6c03004819f0f5230e7e1deb20a5a91b8f081d0349bcc4ce5cf2820399b362", + "digest": "sha256:d79a8069e12741fab605b382ac1280fe0a41590a249232dd8be3b6f72cbb6ecf", "evidence_files": 11127, "evidence_root": "sha256:4528085ec1661c442b64fb5dc8def65067ea2620ff88e42bcf52d58b7642ea6e", - "files": 14100, - "generated_at_commit": "39c51c7eda8cafff03e113bdbf76f9dcfb3a3602", - "source_tree": "sha256:67f7c770efed174f3f8ca4a1d221a031a3dcba4f5ef8bc0ba8f7631fc52213ae" + "files": 14102, + "generated_at_commit": "99f944a4f60203905ffeb9161b720935567de26b", + "source_tree": "sha256:f3a2ee85c79f212719f984df7f0d9c588d8e78c5c3c4968355f5370307ca9c8e" }, "owner_lane": "", "provenance": { diff --git a/src/.crumb b/src/.crumb index 3d1343f87..ca0c0947e 100644 --- a/src/.crumb +++ b/src/.crumb @@ -182,14 +182,14 @@ } ], "children_root": "sha256:15012a017b26a269feb256b64875ece2912f5f82c57804baafa3777c4fcb80b9", - "compiled_at": "2026-10-18T21:37:52Z", + "compiled_at": "2026-10-18T23:39:16Z", "compiler": "crumb-compile/1", - "digest": "sha256:acd1bee1bed884a4b69be04a31ad6ac089632a5ba24497ceadbe5e75ebb86c0d", + "digest": "sha256:09332cb22674b6dfefec1f651198bdbc67f6bb52bc1527f42c80952865f84db2", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 537, - "generated_at_commit": "11166a26d30bb96a833e0206440cdcfeddd4c2ad", - "source_tree": "sha256:71ac45597c0044ea137bc14222f87567796b1d58381f48b8d52ab27ac84477b9" + "files": 539, + "generated_at_commit": "99f944a4f60203905ffeb9161b720935567de26b", + "source_tree": "sha256:a8bd3b0c194a4e417db87a4656d0cc7e7964239746f107e91e640c1c11e2b6b2" }, "owner_lane": "", "provenance": { From e0fdd7cfb746c979b5d8ec1b6a7b310719bf958d Mon Sep 17 00:00:00 2001 From: "Hermes (desk)" Date: Sun, 18 Oct 2026 18:54:34 -0500 Subject: [PATCH 10/11] gates: constant program names at execvp; log opened by the child (#565) CodeQL on 25b052d8 cleared alerts 544-547 and raised two more on the helper itself: - 555 cpp/uncontrolled-process-operation at execvp(argv[0], argv): the analysis cannot tell argv[0] apart from the path arguments beside it. omega_cc_run and omega_cc_capture_line now take the program as its own parameter, and every caller passes a string literal. - 554 cpp/path-injection: the M18 log was opened at a path built from TMPDIR. The child now opens its output after chdir, by a fixed relative name ("../clean_clone_m18.log", "../qualification.log"), with O_NOFOLLOW so a planted symlink cannot redirect it. A log that cannot be opened exits 126. Same files land in the same places as before. 33 helper checks pass under ASan/UBSan, including a symlinked log that is refused without truncating its target. --- src/omega_blackwell_gates.c | 11 ++++++----- src/omega_clean_clone.c | 29 +++++++++++++---------------- src/omega_clean_clone.h | 25 ++++++++++++++----------- src/omega_world_gates.c | 13 +++++++------ 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/src/omega_blackwell_gates.c b/src/omega_blackwell_gates.c index b27d7e01c..48add9ccc 100644 --- a/src/omega_blackwell_gates.c +++ b/src/omega_blackwell_gates.c @@ -1036,7 +1036,7 @@ static bool test_m18_gate16_clean_clone(void) { } char root[PATH_MAX], checkout[PATH_MAX], log_path[PATH_MAX], physics_arg[PATH_MAX + 16]; char *git_top[] = {"git", "rev-parse", "--show-toplevel", NULL}; - if (!omega_cc_capture_line(NULL, git_top, root, sizeof(root))) { + if (!omega_cc_capture_line(NULL, "git", git_top, root, sizeof(root))) { fprintf(stderr, "M18 clean clone: git rev-parse --show-toplevel failed\n"); (void)rmdir(clone); return false; @@ -1054,10 +1054,11 @@ static bool test_m18_gate16_clean_clone(void) { char *make_argv[] = {"make", "-j", physics_arg, NULL}; char *run_argv[] = {"./build/omegatool", "--run-m18-gates", NULL}; const char *step = "cp"; - int rc = omega_cc_run(NULL, cp_argv, NULL, false); - if (rc == 0) { step = "make clean"; rc = omega_cc_run(checkout, clean_argv, NULL, false); } - if (rc == 0) { step = "make"; rc = omega_cc_run(checkout, make_argv, NULL, false); } - if (rc == 0) { step = "omegatool --run-m18-gates"; rc = omega_cc_run(checkout, run_argv, log_path, true); } + int rc = omega_cc_run(NULL, "cp", cp_argv, NULL, false); + if (rc == 0) { step = "make clean"; rc = omega_cc_run(checkout, "make", clean_argv, NULL, false); } + if (rc == 0) { step = "make"; rc = omega_cc_run(checkout, "make", make_argv, NULL, false); } + /* The log sits beside the checkout: /clean_clone_m18.log. */ + if (rc == 0) { step = "omegatool --run-m18-gates"; rc = omega_cc_run(checkout, "./build/omegatool", run_argv, "../clean_clone_m18.log", true); } if (rc != 0) fprintf(stderr, "M18 clean clone failed at %s (rc %d); log: %s\n", step, rc, log_path); m18_clean_clone_remove_checkout(clone); return (rc == 0); diff --git a/src/omega_clean_clone.c b/src/omega_clean_clone.c index 8b58b12f6..db83e4d17 100644 --- a/src/omega_clean_clone.c +++ b/src/omega_clean_clone.c @@ -24,14 +24,18 @@ bool omega_cc_path_is_plain(const char *s) { } /* Child side: environment, directory, output, then exec. Never returns. */ -static void cc_child(const char *dir, char *const argv[], int out_fd, bool in_clean_clone) { +static void cc_child(const char *dir, const char *prog, char *const argv[], const char *out_rel, bool in_clean_clone) { if (unsetenv("OUT_DIR") != 0) _exit(127); if (in_clean_clone && setenv("OMEGA_IN_CLEAN_CLONE", "1", 1) != 0) _exit(127); if (dir && chdir(dir) != 0) _exit(127); + /* Opened after chdir: the name is fixed by the caller, never built from a path. */ + int out_fd = out_rel ? open(out_rel, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW, 0644) + : open("/dev/null", O_WRONLY | O_CLOEXEC); + if (out_fd < 0) _exit(126); if (dup2(out_fd, STDOUT_FILENO) < 0) _exit(127); if (dup2(out_fd, STDERR_FILENO) < 0) _exit(127); if (out_fd != STDOUT_FILENO && out_fd != STDERR_FILENO) close(out_fd); - execvp(argv[0], argv); + execvp(prog, argv); _exit(127); } @@ -45,24 +49,17 @@ static int cc_wait(pid_t pid) { return -1; } -int omega_cc_run(const char *dir, char *const argv[], const char *out_path, bool in_clean_clone) { - if (!argv || !argv[0]) return -1; - int out_fd = out_path ? open(out_path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644) - : open("/dev/null", O_WRONLY | O_CLOEXEC); - if (out_fd < 0) return -1; +int omega_cc_run(const char *dir, const char *prog, char *const argv[], const char *out_rel, bool in_clean_clone) { + if (!prog || !argv || !argv[0]) return -1; fflush(NULL); pid_t pid = fork(); - if (pid < 0) { - close(out_fd); - return -1; - } - if (pid == 0) cc_child(dir, argv, out_fd, in_clean_clone); - close(out_fd); + if (pid < 0) return -1; + if (pid == 0) cc_child(dir, prog, argv, out_rel, in_clean_clone); return cc_wait(pid); } -bool omega_cc_capture_line(const char *dir, char *const argv[], char *out, size_t out_size) { - if (!argv || !argv[0] || !out || out_size == 0) return false; +bool omega_cc_capture_line(const char *dir, const char *prog, char *const argv[], char *out, size_t out_size) { + if (!prog || !argv || !argv[0] || !out || out_size == 0) return false; out[0] = '\0'; int fds[2]; if (pipe2(fds, O_CLOEXEC) != 0) return false; @@ -84,7 +81,7 @@ bool omega_cc_capture_line(const char *dir, char *const argv[], char *out, size_ if (dir && chdir(dir) != 0) _exit(127); if (dup2(fds[1], STDOUT_FILENO) < 0) _exit(127); if (dup2(err_fd, STDERR_FILENO) < 0) _exit(127); - execvp(argv[0], argv); + execvp(prog, argv); _exit(127); } close(fds[1]); diff --git a/src/omega_clean_clone.h b/src/omega_clean_clone.h index 3c0a79b06..b829f483b 100644 --- a/src/omega_clean_clone.h +++ b/src/omega_clean_clone.h @@ -18,18 +18,21 @@ /* True when every byte of s is in [A-Za-z0-9/._+-] and s is non-empty. */ bool omega_cc_path_is_plain(const char *s); -/* Run argv[0] (looked up on PATH) with argv in directory dir. - * stdout and stderr go to out_path (created or truncated), or to /dev/null when - * out_path is NULL. OUT_DIR is removed from the child environment; when - * in_clean_clone is true the child also gets OMEGA_IN_CLEAN_CLONE=1. - * Returns the child's exit code, 128 + signal if it was killed, or -1 if it - * could not be started. */ -int omega_cc_run(const char *dir, char *const argv[], const char *out_path, bool in_clean_clone); +/* Run prog (looked up on PATH; callers pass a string literal) with argv in + * directory dir (NULL: the current directory). stdout and stderr go to out_rel, + * a path opened by the child AFTER it changes to dir, so callers pass a fixed + * relative name such as "../qualification.log"; NULL means /dev/null. + * OUT_DIR is removed from the child environment; when in_clean_clone is true + * the child also gets OMEGA_IN_CLEAN_CLONE=1. + * Returns the child's exit code (126: output file could not be opened, 127: + * program could not be started), 128 + signal if it was killed, or -1 if the + * child could not be created. */ +int omega_cc_run(const char *dir, const char *prog, char *const argv[], const char *out_rel, bool in_clean_clone); -/* Run argv in dir and capture the first line of its stdout (newline stripped) - * into out. stderr goes to /dev/null. Returns true only when the program exits - * 0 and printed a line that fit. */ -bool omega_cc_capture_line(const char *dir, char *const argv[], char *out, size_t out_size); +/* Run prog with argv in dir and capture the first line of its stdout (newline + * stripped) into out. stderr goes to /dev/null. Returns true only when the + * program exits 0 and printed a line that fit. */ +bool omega_cc_capture_line(const char *dir, const char *prog, char *const argv[], char *out, size_t out_size); /* Remove path and everything under it without following symlinks. * Refuses an empty path, "/", a relative path, or a path outside the plain diff --git a/src/omega_world_gates.c b/src/omega_world_gates.c index e59bf9af7..0fff1a947 100644 --- a/src/omega_world_gates.c +++ b/src/omega_world_gates.c @@ -42,7 +42,7 @@ static bool m19_git_head(const char *repo_dir, char out[41]) { /* No shell (omega#565): git gets the directory as an argument. */ char line[64]; char *argv[] = {"git", "-C", (char *)repo_dir, "rev-parse", "HEAD", NULL}; - if (!omega_cc_capture_line(NULL, argv, line, sizeof(line))) return false; + if (!omega_cc_capture_line(NULL, "git", argv, line, sizeof(line))) return false; if (strlen(line) != 40) return false; memcpy(out, line, 41); return true; @@ -1822,11 +1822,12 @@ static bool test_m19_gate16_clean_clone(void) { char *make_argv[] = {"make", "-j", physics_arg, NULL}; char *run_argv[] = {"./build/omegatool", "--run-m19-gates", NULL}; const char *step = "git clone"; - int rc = omega_cc_run(NULL, clone_argv, NULL, false); - if (rc == 0) { step = "git checkout"; rc = omega_cc_run(checkout, checkout_argv, NULL, false); } - if (rc == 0) { step = "make clean"; rc = omega_cc_run(checkout, clean_argv, NULL, false); } - if (rc == 0) { step = "make"; rc = omega_cc_run(checkout, make_argv, NULL, false); } - if (rc == 0) { step = "omegatool --run-m19-gates"; rc = omega_cc_run(checkout, run_argv, log_path, true); } + int rc = omega_cc_run(NULL, "git", clone_argv, NULL, false); + if (rc == 0) { step = "git checkout"; rc = omega_cc_run(checkout, "git", checkout_argv, NULL, false); } + if (rc == 0) { step = "make clean"; rc = omega_cc_run(checkout, "make", clean_argv, NULL, false); } + if (rc == 0) { step = "make"; rc = omega_cc_run(checkout, "make", make_argv, NULL, false); } + /* The log sits beside the checkout: /qualification.log. */ + if (rc == 0) { step = "omegatool --run-m19-gates"; rc = omega_cc_run(checkout, "./build/omegatool", run_argv, "../qualification.log", true); } if (rc != 0) { fprintf(stderr, "M19 clean clone failed at %s (rc %d); log: %s\n", step, rc, log_path); m19_clean_clone_remove_checkout(checkout); From 68a3a6145fc6ae1771adab88b8292af785a10bb1 Mon Sep 17 00:00:00 2001 From: "Hermes (desk)" Date: Sun, 18 Oct 2026 18:54:42 -0500 Subject: [PATCH 11/11] crumb: recompile after the #565 helper fix (pinned tool d0f0b95d) --- .crumb | 14 +++++++------- src/.crumb | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.crumb b/.crumb index 4db8b1637..96271afc6 100644 --- a/.crumb +++ b/.crumb @@ -77,8 +77,8 @@ "purpose": "Directory spec. Purpose not yet described by a human." }, { - "digest": "09332cb22674b6dfefec1f651198bdbc67f6bb52bc1527f42c80952865f84db2", - "last_commit": "99f944a4", + "digest": "c296c77597a9f7be28f887f1df11908e3da49736534b90a1038ce633d27f0c29", + "last_commit": "e0fdd7cf", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, @@ -95,15 +95,15 @@ "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:20d513a69a310cdc411d6c00cefdc30c4f8b9bf3dd75f26c197abac573cbd96f", - "compiled_at": "2026-10-18T23:39:16Z", + "children_root": "sha256:4b56484a92e52f2968150c5636f2d826532456feb62e391551be73a13a06b5b1", + "compiled_at": "2026-10-18T23:54:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:d79a8069e12741fab605b382ac1280fe0a41590a249232dd8be3b6f72cbb6ecf", + "digest": "sha256:f1c98af390d4b707a1772250b05aedc643d9e17bf7f65dbf9a247eba05dbcd64", "evidence_files": 11127, "evidence_root": "sha256:4528085ec1661c442b64fb5dc8def65067ea2620ff88e42bcf52d58b7642ea6e", "files": 14102, - "generated_at_commit": "99f944a4f60203905ffeb9161b720935567de26b", - "source_tree": "sha256:f3a2ee85c79f212719f984df7f0d9c588d8e78c5c3c4968355f5370307ca9c8e" + "generated_at_commit": "e0fdd7cfb746c979b5d8ec1b6a7b310719bf958d", + "source_tree": "sha256:3ec171e83ba5d838b0d2938271ec63a620f666fb80ae0d38e3fe43c487df1bcf" }, "owner_lane": "", "provenance": { diff --git a/src/.crumb b/src/.crumb index ca0c0947e..bdb00f959 100644 --- a/src/.crumb +++ b/src/.crumb @@ -182,14 +182,14 @@ } ], "children_root": "sha256:15012a017b26a269feb256b64875ece2912f5f82c57804baafa3777c4fcb80b9", - "compiled_at": "2026-10-18T23:39:16Z", + "compiled_at": "2026-10-18T23:54:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:09332cb22674b6dfefec1f651198bdbc67f6bb52bc1527f42c80952865f84db2", + "digest": "sha256:c296c77597a9f7be28f887f1df11908e3da49736534b90a1038ce633d27f0c29", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 539, - "generated_at_commit": "99f944a4f60203905ffeb9161b720935567de26b", - "source_tree": "sha256:a8bd3b0c194a4e417db87a4656d0cc7e7964239746f107e91e640c1c11e2b6b2" + "generated_at_commit": "e0fdd7cfb746c979b5d8ec1b6a7b310719bf958d", + "source_tree": "sha256:3c517fada2cf1941df57e8d3757d2bb6170bd69305800a95727e37a0ccf1ed15" }, "owner_lane": "", "provenance": {