CodeQL / Uncontrolled process operation
The value of this argument may come from an environment variable and is being passed to system.
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
The value of this argument may come from an environment variable and is being passed to system.
This argument to an OS command is derived from user input (string read by fgets), dangerously concatenated into snprintf output argument, and then passed to system(__command).
The value of this argument may come from string read by fgets and is being passed to system.
git checkout -b patch-944e491c5763bb7b f4a9849fb127f8d2d664dfc56890752ad180c507 curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/944e491c5763bb7b.patch | git am
github-import 1
aien-dev/omega-mv
529
e466b138b57f6672afb26fc657fcdb28cc4c6293
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":529,"url":"https://github.com/aien-dev/omega-mv/pull/529","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:38:09Z","metadata":"unavailable","state_derived":true}
diff --git a/.crumb b/.crumb index 81f377ee2..6a62fc81e 100644 --- a/.crumb +++ b/.crumb @@ -77,8 +77,8 @@ "purpose": "Directory spec. Purpose not yet described by a human." }, { - "digest": "dfa36de2ac8649f66f80587abea51a7f166285ee0b92e0e09774c98689055250", - "last_commit": "333091a6", + "digest": "e2f18fa3911a9c29bbb65a663715bcca30769d1bddef2c33b28a3869582d6538", + "last_commit": "125d5589", "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:e1a8c008214ad5dbc33a3e184d7e882dc56d1d50f9bd14c58f8773992961557e", - "compiled_at": "2026-10-16T19:04:20Z", + "children_root": "sha256:b352b84161828b8f04b2d6606a7f56e23948bbe31e21f5763b2f1cc728ce2918", + "compiled_at": "2026-10-17T03:06:04Z", "compiler": "crumb-compile/1", - "digest": "sha256:32086cfe6b319e0c0229bec39553d1b32f7460aa660ad888d5eb5990522e705a", + "digest": "sha256:9c1507dffc885e5921430ebbf2afbc816c5a6ac33af73753af2e136caaac5439", "evidence_files": 11127, "evidence_root": "sha256:4528085ec1661c442b64fb5dc8def65067ea2620ff88e42bcf52d58b7642ea6e", "files": 14109, - "generated_at_commit": "88e24bdd57b27817d030d0ad95f62c3f3eacf426", - "source_tree": "sha256:e01c9caa38757306582443fe69f52cb061c3d27250f8ad0b9f4b4f43b009dc14" + "generated_at_commit": "125d55897c85a05fe1d26d9f0e7acd78fd86e577", + "source_tree": "sha256:32f25ca8e5b79206e3510778e7922f14748c3490dd2a7a2ab0bdea77b160f991" }, "owner_lane": "", "provenance": { 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": { 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 <time.h> #include <math.h> #include <limits.h> +#include <errno.h> #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; 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 <rx_r11_aien_test> +# 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: <why>". +# 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 <rx_r11_aien_test> 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 ]