Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/patches/a25e94b1ec5a4728 # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## fix: bind artifact admission to canonical manifest layout merged `a25e94b1ec5a4728` #80 · opened 2026-10-25 02:41 UTC · closed 2026-10-26 03:36 UTC · merged 2026-10-26 03:36 UTC Imported from GitHub aien-dev/CUDApp#80, by drakestapleton Base `3f9c154c7ef5152b3d6b21811920fbd8eeb0d044` · Head `fd51895647c5f79c8f43fac95b2fca2097a86ad3` Merged on GitHub as `585f159e3a6fc305976791892631a94776369384`; reachable from main `21d8de285f713adf09e0d6ba6db2b37139d0674e` (observed 2026-11-18T16:38:30Z) drakestapleton wrote on 2026-10-25 02:41 UTC ## Scope Validate the complete version-1 manifest layout before field lookup or identity admission. Require the exporter's ordered, unique records and final provenance-tool boundary; reject missing/duplicate/reordered records, hidden NUL/trailing bytes, and unterminated records. Canonical artifacts retain their existing IDs. Add a portable host regression target to HOST_TESTS. This repairs a digest/interpretation binding defect for noncanonical inputs. It is not a claim of signature forgery, remote authentication bypass, observed exploitation, or complete artifact/driver security. No GPU code is executed by the new test. The existing first-party artifact boundary is patched; no frozen kernel work or .om migration scope is changed. Related context: #68 and #79. ## Verification - Base: `3f9c154c7ef5152b3d6b21811920fbd8eeb0d044`. - Test-first against original production parser: 13 checks, 8 failures (exit 1). - `make test-native-artifact-manifest`: 13 checks, 0 failed (exit 0). - GCC 14.2, x86_64, `-O0`, `-O1`, `-O2`, `-Wall -Wextra -Werror`, ASan + UBSan: 13/13 at each level. Leak detection disabled because LeakSanitizer cannot operate under this environment's ptrace; leaks NOT_RUN. - Independent review reproduced red/green, reran portable make and -O1 sanitizer checks: PASS for this bounded fix. - `git diff --check`: PASS. - Full `make -j4 test` and existing `make -j4 test-native-artifact`: attempted, BLOCKED by existing AArch64 ds/dsb assembly on this x86_64 executor in omega_blackwell_engine.c (393,558) and omega_blackwell_submit.c (279,372,532,613). Not a full-suite pass. - Spark/driver load/GPU execution/deployment: NOT_RUN. Reviewed local commit `c10d81f7c9dbbbcb071d680db53f9666f38024af` and remote code commit `fd51895647c5f79c8f43fac95b2fca2097a86ad3` have identical full tree `a7c4bf2c9849cacb24292f3505718449bd9c28aa`. Connector publication uses different commit metadata. Reviewed patch SHA256: `74283f3b518ba96c590a41c318d402e82e5e42804e311cf63a9e8e444543c3bf`. Keep draft until required AArch64/full-suite verification and normal review gates are satisfied. No merge or deployment requested. ## CI follow-up The first CodeQL run identified a newly added test helper creating files with a potentially permissive mode. Fixed with explicit 0600 creation and a permissive-umask regression. The helper-only negative control fails 1/13 before the fix, and the fixed suite passes 13/13. Independently reviewed and rerun; no suppression or gate weakening. Exact-head checks for `fd51895647c5f79c8f43fac95b2fca2097a86ad3` completed successfully: CodeQL, Analyze (c-cpp), and Analyze (python). Run: https://github.com/aien-dev/CUDApp/actions/runs/`40155818716` . These checks do not replace the still-blocked AArch64 full-suite verification. drakestapleton reviewed (COMMENTED) on 2026-10-25 02:42 UTC Bounded source inspection, exact head `16cefed932dac7d18adfa0a5ecee876b563634d5` (2026-10-25). Not a merge approval. I inspected the new `manifest_layout_ok` and compared its ordered field keys against the actual v1 exporter in `src/omega_native_artifact.c`. The parser now examines the entire byte span before `find_line` or artifact-id admission: it requires the exporter-ordered records, a terminating newline and `provenance_tool` last, rejecting hidden NUL, CR, surplus records and missing/duplicated/reordered fields. This directly addresses the previously possible divergence between the hashed identity portion and later policy field lookup. The added fixture exercises that boundary; the PR's recorded x86/sanitizer red/green results are author/earlier local-review claims, not tests rerun by this desk. Outstanding qualification: This changes the artifact trust/admission surface, so retain the existing implementation owner and the applicable operator path. GitHub currently has no submitted independent final-head approval, no established CUDApp signed-worker lane or exact-head signed Spark/AArch64 bundle. The existing full/native targets are reported blocked on AArch64 assembly on x86. Obtain a pinned AArch64 host/full-suite run with the required positive/refusal controls and an independently reviewed exact-head integration, then qualified gate evidence; do not claim GPU device load or deployment from this portable parser repair. Keep this PR draft. Do not bypass protections or reinterpret the historical #67/#70 merged heads as qualification for #80. github-advanced-security[bot] reviewed (COMMENTED) on 2026-10-25 02:43 UTC github-advanced-security[bot] commented on `tests/native_artifact_manifest_test.c` line 14 on 2026-10-25 02:43 UTC ## CodeQL / File created without restricting permissions A file may be created here with mode 0666, which would make it world-writable. Show more details drakestapleton reviewed (COMMENTED) on 2026-10-25 03:45 UTC Changed-head reinspection, exact `fd51895647c5f79c8f43fac95b2fca2097a86ad3` (2026-10-25), not approval. The one-commit delta from previously inspected `16cefed...` affects only `tests/native_artifact_manifest_test.c`: replaces `fopen("wb")` with `open(..., O_CLOEXEC, 0600)` + `fdopen`, and adds a permissive-umask negative control for private fixture file permissions. This directly addresses the prior CodeQL world-writable-file finding; current exact-head C/C++ and Python analyses and aggregate CodeQL report SUCCESS. The source admission parser's canonical-order logic is unchanged from the earlier bounded review. Still outstanding: no executed AArch64/native full-suite qualification, established CUDApp signed-worker pipeline, exact-head signed judge PASS, applicable trust-surface operator disposition or independent final-head approval. Static analysis and this delta inspection do not supply those. Preserve the draft and existing owner; refresh any qualification after the head change and do not borrow earlier #67/#70 passes. ### Apply it ``` git checkout -b patch-a25e94b1ec5a4728 3f9c154c7ef5152b3d6b21811920fbd8eeb0d044 curl -fsSL https://interplane.io/drakestapleton/CUDApp/patches/a25e94b1ec5a4728.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/CUDApp 80 fd51895647c5f79c8f43fac95b2fca2097a86ad3 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"CUDApp","number":80,"url":"https://github.com/aien-dev/CUDApp/pull/80","export_sha256":"0aafd51b77ff5776d6baaf9b88b48c8b36a6e27c8d829ae8ded561b71712b17a","imported_utc":"2026-11-18T16:38:30Z"} ``` ### Changes ``` diff --git a/Makefile b/Makefile index b820f8f9..cba34015 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,12 @@ $(OUT_DIR)/cubin_probe: tools/interop/cubin_probe.c $(OUT_DIR)/libomega_gpu.a cubin-probe: $(OUT_DIR)/cubin_probe test-native-artifact: $(ARTIFACT_EXPORT) $(ARTIFACT_TEST) ./$(ARTIFACT_TEST) $(OUT_DIR)/artifact-test +# Pure artifact-format boundary: portable host test, no driver or device objects. +.PHONY: test-native-artifact-manifest +$(OUT_DIR)/native_artifact_manifest_test: tests/native_artifact_manifest_test.c src/omega_native_artifact.c src/omega_cubin.c src/omega_blackwell_realize.c src/sha256.c | $(OUT_DIR) + $(CC) $(CFLAGS) -ffunction-sections -fdata-sections -Wl,--gc-sections -o $@ $^ +test-native-artifact-manifest: $(OUT_DIR)/native_artifact_manifest_test + ./$(OUT_DIR)/native_artifact_manifest_test .PHONY: libomega_gpu test-gpu-matmul-api # The two gate-runner objects (omegatool's M17/M18/M19 and World gates) are NOT part of the # library: nothing in the library or in the Rust FFI crate calls them (checked with nm), and @@ -290,7 +296,7 @@ HOST_TESTS = test-gpu-matmul-api test-gpu-elementwise test-gpu-reconv test-gpu-a test-gpu-engine-mutants test-gpu-engine-backend-compile test-gpu-engine-prod-build test-gpu-engine-sim \ test-gpu-engine-backend-mutants test-gpu-engine-gb10-compile test-gpu-serving-alloc test-gpu-engine-freestanding \ test-codegen-freestanding test-gpu-session-platform test-gpu-wait test-gpu-wait-mutants host-tests-m16 \ - test-runtime-api test-runtime-portability test-doctor test-hello-sim + test-runtime-api test-runtime-portability test-doctor test-hello-sim test-native-artifact-manifest test: $(HOST_TESTS) @echo "CUDA++ HOST TESTS PASS ($(words $(HOST_TESTS)) targets)" diff --git a/src/omega_native_artifact.c b/src/omega_native_artifact.c index afc963f0..9362b000 100644 --- a/src/omega_native_artifact.c +++ b/src/omega_native_artifact.c @@ -354,6 +354,36 @@ static int cubin_text_matches(const uint8_t *cub, size_t n, const char *fn, return 0; } +/* Version 1 has one canonical ordered record per field. Validate the whole + * byte span before any string lookup: otherwise find_line can select policies + * after provenance_tool even though the identity hash stops at that boundary. + * Unknown/duplicate/reordered fields require a new format, not reinterpretation + * of an existing artifact id. provenance_tool is deliberately outside the id. */ +static int manifest_layout_ok(const uint8_t *buf, size_t n) { + static const char *const keys[] = { + "artifact_id=", "op=", "shape=", "bounds=", "contract=", + "contract_id=", "semantic_spec_id=", "isa=", "machine_profile=", + "kernel_format=", "kernel_function=", "text_sha256=", "text_size=", + "cubin_sha256=", "cubin_size=", "qmd0_sha256=", "qmd1_sha256=", + "qmd_template=", "cbank_offset=", "cbank_words=", "cbank_args=", + "cbank_args_sha256=", "grid=", "block=", "shared_bytes=", "gpr_count=", + "precision=", "accumulation=", "tolerance=", "min_driver=", "requires=", + "qualification=", "provenance_source_commit=", "provenance_tool=" + }; + const size_t header = sizeof(OMEGA_ARTIFACT_FORMAT "\n") - 1; + if (n < header || n >= MANIFEST_CAP || memchr(buf, 0, n) || + memchr(buf, '\r', n) || memcmp(buf, OMEGA_ARTIFACT_FORMAT "\n", header)) return 0; + size_t off = header; + for (size_t i = 0; i < sizeof keys / sizeof keys[0]; i++) { + size_t k = strlen(keys[i]); + if (k > n - off || memcmp(buf + off, keys[i], k)) return 0; + const uint8_t *nl = memchr(buf + off + k, '\n', n - off - k); + if (!nl) return 0; + off = (size_t)(nl - buf) + 1; + } + return off == n; +} + static char *find_line(char *buf, const char *key) { size_t k = strlen(key); char *p = buf; @@ -403,7 +433,7 @@ int omega_native_artifact_admit(const char *out_prefix, const char *current_driv snprintf(path, sizeof path, "%s.manifest", out_prefix); man = read_file(path, &mn); if (!man) { if (err) snprintf(err, err_cap, "cannot read %s", path); return OMEGA_ARTIFACT_E_IO; } - if (strncmp((char *)man, OMEGA_ARTIFACT_FORMAT "\n", strlen(OMEGA_ARTIFACT_FORMAT) + 1) != 0) { + if (!manifest_layout_ok(man, mn)) { rc = OMEGA_ARTIFACT_E_FORMAT; goto done; } { diff --git a/tests/native_artifact_manifest_test.c b/tests/native_artifact_manifest_test.c new file mode 100644 index 00000000..7e30b258 --- /dev/null +++ b/tests/native_artifact_manifest_test.c @@ -0,0 +1,128 @@ +/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +/* Host-only canonical-manifest admission tests. The synthetic instruction bytes + * are never executed and make no device correctness claim. */ +#include +#include +#include +#include +#include +#include +#include "omega_native_artifact.h" +#include "sha256.h" + +static int checks, failures; +#define CHECK(c, msg) do { checks++; if (!(c)) { failures++; fprintf(stderr, "FAIL: %s\n", msg); } } while (0) +static void save(const char *path, const char *s, size_t n) { + int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0600); + if (fd < 0) exit(2); + FILE *f = fdopen(fd, "wb"); + if (!f) { close(fd); exit(2); } + if (fwrite(s, 1, n, f) != n || fclose(f)) exit(2); +} +/* Test mutations must fail as fixture errors, not dereference a missing field. */ +static char *field(char *m, const char *key) { + char *p = strstr(m, key); + if (!p) { fprintf(stderr, "fixture missing %s\n", key); exit(2); } + return p; +} +static char *next_line(char *p) { + char *nl = strchr(p, '\n'); + if (!nl) { fprintf(stderr, "fixture missing newline\n"); exit(2); } + return nl + 1; +} +static void insert_record(char *m, size_t cap, const char *key, const char *record) { + char *p = field(m, key); + size_t n = strlen(m), extra = strlen(record); + if (n >= cap || extra >= cap - n) exit(2); + size_t off = (size_t)(p - m); + if (off > n) exit(2); + memmove(m + off + extra, m + off, n - off + 1); + memcpy(m + off, record, extra); +} +static void rehash(char *m) { + char *start = field(m, "\nop=") + 1, *end = field(start, "provenance_tool="); + char *id = field(m, "artifact_id=") + 12; + if (end <= start || (size_t)(next_line(id) - id) != 65) exit(2); + static const char hex[] = "0123456789abcdef"; + uint8_t digest[32]; + sha256_hash((uint8_t *)start, (size_t)(end - start), digest); + for (int i = 0; i < 32; i++) { id[2*i] = hex[digest[i] >> 4]; id[2*i+1] = hex[digest[i] & 15]; } +} +static void refuse(const char *prefix, const char *path, char *m, size_t n, const char *msg) { + char id[65], err[256]; + save(path, m, n); + int rc = omega_native_artifact_admit(prefix, "580.173.02", id, err, sizeof err); + CHECK(rc == OMEGA_ARTIFACT_E_FORMAT, msg); +} +int main(void) { + char dir[] = "/tmp/cudapp-manifest-XXXXXX", prefix[256], path[280], id[65], err[256]; + if (!mkdtemp(dir)) return 2; + /* Even a permissive invoking umask must not create shared test files. */ + snprintf(path, sizeof path, "%s/mode-check", dir); + mode_t mask = umask(0); + save(path, "test", 4); + umask(mask); + struct stat st; + CHECK(stat(path, &st) == 0 && (st.st_mode & 0777) == 0600, "fixture file mode is not private"); + unlink(path); + snprintf(prefix, sizeof prefix, "%s/fixture", dir); + snprintf(path, sizeof path, "%s.manifest", prefix); + uint8_t text[16] = {0}; uint32_t q0[96] = {0}, q1[96] = {0}, cb[2] = {0}; + q1[52] = 0x300u >> 6; + OmegaCubinParam param = {0x380, 8, 1}; + char hash[65]; memset(hash, 'a', 64); hash[64] = 0; + OmegaNativeArtifact a = { + .op="matmul", .shape="m=1,k=1,n=1", .bounds="m<=1,k<=1,n<=1", .contract_name="test", + .contract_id_hex=hash, .semantic_spec_id_hex=hash, .kernel_function="test", + .precision="bf16", .accumulation="fp32", .tolerance="0", .text=text, .text_len=sizeof text, + .params=¶m, .nparams=1, .gpr_count=1, .grid_x=1, .grid_y=1, .block_x=1, .block_y=1, .block_z=1, + .cbank_offset=0x380, .cbank_args=cb, .cbank_words=2, .qmd0=q0, .qmd1=q1, + .min_driver="580.173.02", .requires="sm_121", .source_commit="UNKNOWN", .tool_version="test/1", + .qualification="device-load=NOT_RUN" + }; + CHECK(omega_native_artifact_export(&a,prefix,id,err,sizeof err)==0, "export fixture"); + CHECK(omega_native_artifact_admit(prefix,"580.173.02",id,err,sizeof err)==0, "admit canonical fixture"); + char original[8192], m[16384]; + FILE *f=fopen(path,"rb"); if (!f) return 2; + size_t n=fread(original,1,sizeof original-1,f); + if (ferror(f) || n == 0 || n == sizeof original-1) { fclose(f); return 2; } + fclose(f); original[n]=0; + + /* Move a checked policy after the identity terminator; the old parser + * accepts both policies under exactly the same artifact id. */ + char *line=field(original,"min_driver="), *nl=next_line(line); + size_t before=(size_t)(line-original), len=(size_t)(nl-line); + memcpy(m, original, before); strcpy(m+before, nl); + strncat(m, line, len); rehash(m); + refuse(prefix,path,m,strlen(m),"minimum driver outside identity accepted"); + char *policy=field(m,"min_driver=")+11; + if ((size_t)(next_line(policy) - policy) != 11) return 2; + memcpy(policy,"000.000.00",10); + refuse(prefix,path,m,strlen(m),"changed unhashed minimum driver accepted under same identity"); + + strcpy(m,original); strcat(m,"isa=sm_120\n"); + refuse(prefix,path,m,strlen(m),"duplicate key after terminator accepted"); + strcpy(m,original); insert_record(m,sizeof m,"shape=","shape=shadow\n"); rehash(m); + refuse(prefix,path,m,strlen(m),"duplicate key inside identity accepted"); + strcpy(m,original); line=field(m,"qualification="); nl=next_line(line); memmove(line,nl,strlen(nl)+1); rehash(m); + refuse(prefix,path,m,strlen(m),"missing qualification accepted"); + strcpy(m,original); line=field(m,"shape="); nl=next_line(line); + char *next=next_line(nl); char swap[256]; size_t l1=(size_t)(nl-line),l2=(size_t)(next-nl); + if (l1 > sizeof swap) return 2; + memcpy(swap,line,l1); memmove(line,nl,l2); memcpy(line+l2,swap,l1); rehash(m); + refuse(prefix,path,m,strlen(m),"reordered canonical fields accepted"); + strcpy(m,original); m[n]='\0'; memcpy(m+n+1,"isa=sm_120\n",11); + refuse(prefix,path,m,n+12,"embedded NUL with trailing policy accepted"); + strcpy(m,original); line=field(m,"provenance_tool="); *line=0; + refuse(prefix,path,m,strlen(m),"missing identity boundary accepted"); + strcpy(m,original); m[n-1]=0; + refuse(prefix,path,m,n-1,"missing final newline accepted"); + + save(path,original,n); + CHECK(omega_native_artifact_admit(prefix,"580.173.02",id,err,sizeof err)==0,"canonical fixture still accepted"); + const char *suffix[]={".text.bin",".cubin",".qmd0.bin",".qmd1.bin",".cbank_args.bin",".manifest",".json",".sha256"}; + for (size_t i=0;i