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
GitHub aien-dev/CUDApp#241 (code only)
Fetch it
curl -fsSL https://interplane.io/drakestapleton/CUDApp/patches/c2fe6793af8e28b9.bundle -o c2fe6793af8e28b9.bundle git fetch c2fe6793af8e28b9.bundle refs/pull/241/head
Provenance
github-import 1
aien-dev/CUDApp
241
f13d736e395f789b6c93b5906ece3efbfc1b29ca
{"kind":"github-import","owner":"aien-dev","repo":"CUDApp","number":241,"url":"https://github.com/aien-dev/CUDApp/pull/241","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:38:58Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/src/omega_blackwell_codegen.c b/src/omega_blackwell_codegen.c index 5c5756ac..3f1e6dd1 100644 --- a/src/omega_blackwell_codegen.c +++ b/src/omega_blackwell_codegen.c @@ -2,6 +2,7 @@ #include "omega_blackwell_codegen.h" #include "omega_blackwell_submit.h" #include "sha256.h" +#include "omega_path_check.h" #include <string.h> /* native v1 P07 cut A.2 (aienos#286, docs/numeric/OMEGA_GPU_NATIVE_BOUNDARY.md): with OMEGA_GPU_NO_POSIX this file * builds -ffreestanding. Code generation then runs only through the allocation-free entry points @@ -1134,8 +1135,15 @@ int omega_blackwell_verify_codegen_fixtures_fb1cut4(void) { * every kernel the library builds. Unset (the normal case) it does nothing; the freestanding build has no files. */ void omega_kernel_dump(const uint8_t *code, size_t len) { #ifndef OMEGA_GPU_NO_POSIX - const char *dir = getenv("OMEGA_KERNEL_DUMP_DIR"); - if (!dir || !dir[0] || !code || !len) return; + const char *env = getenv("OMEGA_KERNEL_DUMP_DIR"); + if (!env || !env[0] || !code || !len) return; + /* Only the checked copy (src/omega_path_check.h) is opened; a refused directory is a diagnostic, which + * tools/sm121dis/corpus.sh fails on, never a silent skip. */ + char dir[4000]; + if (omega_path_copy(dir, sizeof dir, env) != 0) { + BW_DIAG("omega_kernel_dump: OMEGA_KERNEL_DUMP_DIR refused (src/omega_path_check.h)\n"); + return; + } uint8_t d[SHA256_DIGEST_SIZE]; sha256_hash(code, len, d); char path[4096]; int n = snprintf(path, sizeof path, "%s/%02x%02x%02x%02x%02x%02x%02x%02x.bin", diff --git a/src/omega_path_check.h b/src/omega_path_check.h new file mode 100644 index 00000000..a0ebf22f --- /dev/null +++ b/src/omega_path_check.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: Apache-2.0 + * Copyright 2026 Drake Stapleton (AIEN / aien-dev) + * + * omega_path_check.h: a checked copy of a file system path that came from outside the program (an + * environment variable, a command's output, a caller's argument) before anything opens it. + * + * A path is accepted only when it is 1..cap-1 bytes long, every byte is in the POSIX portable file name set + * [A-Za-z0-9._-] or one of / + , = @ : ~ (no space, quote, control, shell or non-ASCII byte), and no + * component is "..". Absolute and relative paths are both accepted. The accepted path is copied byte by byte + * through omega_path_byte, so the bytes the caller later opens are exactly the bytes that were checked. + * A refused path leaves out as the empty string. + */ +#ifndef OMEGA_PATH_CHECK_H +#define OMEGA_PATH_CHECK_H + +#include <stddef.h> + +/* c when it may appear in a checked path, -1 otherwise */ +static inline int omega_path_byte(int c) { + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) return c; + switch (c) { + case '.': case '_': case '-': case '/': case '+': case ',': case '=': case '@': case ':': case '~': + return c; + default: + return -1; + } +} + +/* 0 with out = in when in is an acceptable path shorter than cap; -1 with out = "" otherwise */ +static inline int omega_path_copy(char *out, size_t cap, const char *in) { + if (!out || cap == 0) return -1; + out[0] = '\0'; + if (!in || !in[0]) return -1; + size_t k = 0; + for (; in[k]; k++) { + int b = omega_path_byte((unsigned char)in[k]); + if (b < 0 || k + 1 >= cap) { + out[0] = '\0'; + return -1; + } + out[k] = (char)b; + } + out[k] = '\0'; + for (size_t i = 0; i < k;) { + size_t j = i; + while (j < k && out[j] != '/') j++; + if (j - i == 2 && out[i] == '.' && out[i + 1] == '.') { + out[0] = '\0'; + return -1; + } + i = j + 1; + } + return 0; +} + +#endif /* OMEGA_PATH_CHECK_H */ diff --git a/tools/extract/.crumb b/tools/extract/.crumb index bb0582df..a509b1e6 100644 --- a/tools/extract/.crumb +++ b/tools/extract/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-31T14:25:29Z", + "compiled_at": "2026-10-31T15:42:13Z", "compiler": "crumb-compile/1", - "digest": "sha256:3f1a49f75f5135ddcbf16d7d9b8f0727c6b807749d27c9b7af3e1df9aa1bc9fd", + "digest": "sha256:0200d0e20ea1931e6d28799bfb6b939446c9bdc0b1ee6963934a3887f8bbe259", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 30, - "generated_at_commit": "4e888d1f9ea8cd97bcc790764d75565da996a434", - "source_tree": "sha256:207733c19a122029efa439ff585327996153cf6cd6b505f2264c81c98c755e5f" + "generated_at_commit": "b42b11c89706d1b84e0fd2e5ffb4ad68d8b2897e", + "source_tree": "sha256:336f17a380621e6bc506c2b724eb9c3de8bca0f5afb6ebc17e089de3a82f05b3" } }, "name": "extract", diff --git a/tools/extract/drift-baseline.tsv b/tools/extract/drift-baseline.tsv index c9dbdf69..1a172b1e 100644 --- a/tools/extract/drift-baseline.tsv +++ b/tools/extract/drift-baseline.tsv @@ -160,7 +160,7 @@ mk/omega-gpu-code-alloc.mk 3b217c32d9cc063c8b83d18ede48afcc24a594ae mk/omega-gpu-engine.mk f3f5dd632c6a42c806ccdb687c8df6e7e5c35ffa mk/omega-gpu-wait.mk 42e5ed25b232b7ae67f922e9a4a948e3ef942159 mk/sm121dis.mk c9440caa7c5b1f956c4fdd55d93e1eb631a2e768 -src/omega_blackwell_codegen.c a0520f4c9f4c796fd1f4c1fd3eb670bb434e0753 +src/omega_blackwell_codegen.c 97a727a97323936af86acf81a2d36cb35befd9f2 src/omega_blackwell_codegen.h 1f0b70eecd3860da68bbe013860f27ca01da0d2f src/omega_blackwell_codegen_attn.c 060e25cff987ff43fdb234aee39497253cf25c3a src/omega_blackwell_codegen_attn.h 4f84bba33c4cf4dfca8834335b6900aba01b677b @@ -321,12 +321,12 @@ tests/dagsim/run_cli.sh 5b22297de823d24af6c8f7e5f373b90f632aa461 tests/dagsim/sha256_host.c 64ffdf4e5d6443ccf1272d43f6dba39589624c0a tests/fake_m16_native.c 54f204c266512c29324a46bbcda880c004509971 tests/fake_m16_native.h cdb48ee8764184fdbf9d8895019d44f87a5e21ca -tests/gpu_attention_test.c 8ba96c81c437141544a3dffc0801ca7f332bdbd8 -tests/gpu_bf16_gemv_test.c f37a595006adddd0261e5c741634909167888daf +tests/gpu_attention_test.c fa8b39cf58dbf20ec4785f3be2b9d58d443cf1ea +tests/gpu_bf16_gemv_test.c 4a8b733f7effd37220ebcd50991455eac3fe125f tests/gpu_cmdlist_test.c f32d36caed78fda46cd1a7536da284d8d260e952 tests/gpu_dattn256_multi_test.c daef69b87e28c449d7756216f343d6463a0ddd7b tests/gpu_decode_attn256_test.c b8b71061ad97336543635e09ee508d15a18fd437 -tests/gpu_decode_attn_test.c ff35e2a039efa661a056ab6a289e47a9b43cc73b +tests/gpu_decode_attn_test.c f96aa75e728027f8b23601fd0eead5db4fa68f71 tests/gpu_decode_graph_test.c 8af07f1e423f3db54438749eb4a76a1c9f09443c tests/gpu_elementwise_test.c 7a270eb5f45e96aa89d2e6fed6963b2ee044d05b tests/gpu_exact_head_test.c 5258f3d84f5bc44eca597666f146bb2cc54bcdf0 @@ -362,7 +362,7 @@ tests/gpu_streams_test.c 621049e148681b8c7defb68e15c986cfbcc715b2 tests/gpu_tc_peak_test.c 5d2841cbafc3014775551c49531e0c9af3407992 tests/gpu_tc_probe_test.c 934e4a03c2eb6a13e03b9b63ae1284e1038dc109 tests/gpu_tcgemm_test.c 340ff8a63dc8b422c829161e4d43ef06bea743a1 -tests/gpu_tern_test.c 16dfca40fca26bb5a5a885697b7bdd5c0c3227af +tests/gpu_tern_test.c 48e91db2d504ad6a6aa3b1e578edbc45523cf46a tests/test_omega_blackwell_engine.c 5d79271fbd597624a92d3a1544a10b7bccffc960 tests/test_omega_codegen_freestanding.c a84887375200f9a27393096f33333821df503df8 tests/test_omega_gpu_code_alloc.c 2bebf3ca808f4cb38081a035fc633ebafc66dd8a