code wiki / (root) / nx_boundscheck.nx

nx_boundscheck.nx

buildroot/runtime/nx_boundscheck.nx

11409 B228 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_boundscheck.nx -- LN3 RAW-POINTER PROVENANCE fixture organ (lang.plan rung LN3, watch symbol bck_ptr_provenance on /compare/lang row "Raw-pointer access prevented"). WHAT THIS IS. The runnable witness for the compiler's --ptrprov declared mode: a `let`-bound sys_mmap(<const>) pointer's indexing is bounds-checked like a typed array (nx_parse.nx, the LN3 block). Each phase is selected by argv so a single trap ends exactly one phase and the gate (nx_boundscheck_gate) can assert every outcome independently: nx_boundscheck ok in-range read+write+alias walk -> exit 0 under BOTH modes (the positive control: a deny mode that refuses everything fails here) nx_boundscheck read the 2026-07-08 READ-TO-NUL class (CWE-125): a scan with no length bound walks off a 64-byte allocation. Default build: the over-read SURVIVES on arena/page slack (exit 0 -- reading bytes that belong to a NEIGHBORING allocation, the silent-wrong-answer this rung exists to kill). --ptrprov build: traps exit 71 (NX_TRAP_BOUNDS) at index 64. nx_boundscheck write CWE-787, the corruption primitive: s[10] on a 10-element allocation. Default: lands in slack, exit 0. --ptrprov: traps exit 71. The sibling witness nx_boundscheck_constidx.nx carries the COMPILE-TIME leg (a constant out-of-range index refused before any binary exists). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_boundscheck.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main bck_ptr_provenance sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ bck_write_overrun sys_mmap ↻ bck_elide_dominated_witnes bck_elide_notdominated_wit bck_elide_perf_witness bck_elide_keylen_witness bck_inrange_control sys_mmap ↻

structs

none

consts

25const BCK_ALLOC: i64 = 64
26const BCK_FILL: i64 = 7
27const BCK_W_ELEMS: i64 = 10
31const BCK_W_BYTES: i64 = 80
84const BCK_E_ELEMS: i64 = 64
85const BCK_E_SMALL: i64 = 8
86const BCK_E_PERF_ITERS: i64 = 10000000

functions

36func bck_ptr_provenance() -> i64
called by 1: main calls 1: sys_mmap
47func bck_write_overrun() -> i64
called by 1: main calls 1: sys_mmap
56func bck_inrange_control() -> i64
called by 1: main calls 1: sys_mmap
94func bck_elide_dominated_witness(iters: i64) -> i64
called by 1: main
116func bck_elide_perf_witness(reps: i64) -> i64
called by 1: main
141func bck_elide_notdominated_witness(n: i64) -> i64
called by 1: main
157func bck_elide_keylen_witness(n: i64) -> i64
called by 1: main
171func main(argc: i64, argv: *i64) -> i64