code wiki / (root) / nx_livecloexec_gate.nx

nx_livecloexec_gate.nx

buildroot/runtime/nx_livecloexec_gate.nx

21557 B445 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_livecloexec_gate.nx -- does any LIVE process hold a listening socket WITHOUT FD_CLOEXEC? WHY THIS EXISTS ALONGSIDE nx_cloexec_gate (debt 1785521781). That gate is excellent at what it does: it calls the SHIPPING nx_http_server_listen and proves the returned fd carries FD_CLOEXEC, with a control and a reader neg-control. But it measures THE PRIMITIVE, and a primitive is not a fleet: (a) a LIB fix reaches an organ only on ITS NEXT REBUILD -- a daemon deployed before the fix still runs the old code, and the gate is GREEN the whole time; (b) a daemon that binds by some OTHER path (raw sys_socket + bind + listen instead of the shared helper) is not covered by the primitive at all. So nx_cloexec_gate GREEN + a wedged port are perfectly consistent, which is exactly what happened 2026-07-31: the gate passed while :18098 was unreachable for every seat. THIS gate measures the OTHER side: it walks /proc/<pid>/fd, finds sockets, and reads the REAL FD_CLOEXEC bit out of /proc/<pid>/fdinfo/<fd> (`flags:` octal, 02000000 = O_CLOEXEC). It reports what is TRUE OF RUNNING PROCESSES RIGHT NOW, not what the library would do if called today. ★ A GREEN PRIMITIVE GATE IS NOT EVIDENCE ABOUT DEPLOYED BINARIES. ⚠ ADVISORY BY DESIGN, exit 0 unless the SCAN ITSELF fails. A non-CLOEXEC socket is not automatically a defect: most are ACCEPTED connections (short-lived, no port to hostage) and inherited-fd risk applies to LISTENERS. Distinguishing listener from accepted socket needs /proc/net/tcp inode correlation -- see nx_portdup for that lane. Reporting a count with an honest caveat beats a RED verdict this gate cannot justify. What it DOES prove non-vacuously: the scan reached real fds and read real flags. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_livecloexec_gate.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 lc_p lc_len sys_write sys_mmap lc_load_listeners lc_slurp sys_openat_rd sys_read sys_close lc_cat lc_catn sys_mmap ↻ lc_slurp ↻ sys_readlinkat sys_mmap ↻ sys_munmap lc_has lc_len ↻ lc_flags lc_link_inode lc_is_listener lc_pn sys_mmap ↻ sys_write ↻ sys_write ↻ sys_openat_append lc_wf lc_len ↻ sys_write ↻ lc_pnf sys_mmap ↻ sys_write ↻ sys_close ↻

structs

none

consts

35const LC_MAXPID: i64 = 65536
36const LC_LOG: *u8 = "knowledge/status/livecloexec_gate.log"
37const LC_MODE: i64 = 420

functions

39func lc_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 3: lc_plc_wflc_has
40func lc_p(s: *u8) -> i64 { let n: i64 = lc_len(s); sys_write(1, s, n); return 0 }
called by 1: main calls 2: lc_lensys_write
41func lc_wf(fd: i64, s: *u8) -> i64 { let n: i64 = lc_len(s); sys_write(fd, s, n); return 0 }
called by 1: main calls 2: lc_lensys_write
42func lc_pnf(fd: i64, v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
53func lc_pn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
65func lc_cat(dst: *u8, o0: i64, s: *u8) -> i64
called by 1: main
72func lc_catn(dst: *u8, o0: i64, v: i64) -> i64
called by 1: main calls 1: sys_mmap
86func lc_slurp(path: *u8, buf: *u8, cap: i64) -> i64
97func lc_has(buf: *u8, n: i64, needle: *u8) -> i64
called by 1: main calls 1: lc_len
115func lc_flags(buf: *u8, n: i64) -> i64
called by 1: main
156func lc_load_listeners(path: *u8, buf: *u8, cap: i64, inodes: *i64, n0: i64, maxn: i64) -> i64
called by 1: main calls 1: lc_slurp
229func lc_is_listener(inodes: *i64, n: i64, ino: i64) -> i64
called by 1: main
260func main() -> i64