code wiki / (root) / nx_pe_job_limit_test.nx

nx_pe_job_limit_test.nx

buildroot/runtime/nx_pe_job_limit_test.nx

15657 B247 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic pe
docsdependenciesstructsconstsfunctions

about

nx_pe_job_limit_test.nx -- W2b: sovereign Windows Job Object ENFORCEMENT, native, no HCS. Docker-replacement ladder rung W2b. Proves the Job Object does not just EXIST (W2a) but ENFORCES a resource limit -- the cgroups analog, native NT, kernel32-only, no VM/HCS. Mechanism: ActiveProcessLimit via SetInformationJobObject(JobObjectBasicLimitInformation). One emit fn parameterized by the limit value. main() emits TWO PEs differing ONLY in the ActiveProcessLimit immediate: nx_pe_job_limit_deny.exe (limit=1): self is the 1 allowed proc; spawning a child is DENIED -> exit 42 nx_pe_job_limit_allow.exe (limit=2): room for the child; spawn SUCCEEDS -> exit 50 Each PE: 1. CreateJobObjectW(NULL,NULL) -> hJob 2. SetInformationJobObject(hJob, 2, &basic, 0x40) LimitFlags=JOB_OBJECT_LIMIT_ACTIVE_PROCESS(0x8), ActiveProcessLimit=N 3. AssignProcessToJobObject(hJob, (HANDLE)-1) self joins the job (counts as 1) 4. CreateProcessW(NULL,"cmd.exe /c exit 0",...,CREATE_NO_WINDOW,...,&si,&pi) -> rax (BOOL) 5. ExitProcess( rax==0 ? 42 : 50 ) child auto-joins the job; denied if over limit NO-FALSE-GREEN: the gate requires deny->42 AND allow->50. The two binaries are byte-identical except the ActiveProcessLimit immediate, so a CreateProcessW arg bug would fail BOTH (deny AND allow -> 42) and a non-enforcing limit would pass BOTH (deny AND allow -> 50). Only a genuinely ENFORCED limit produces 42-then-50. (positive control = allow; negative control = deny.) HONEST SCOPE: proves ActiveProcessLimit ENFORCEMENT. Memory.max/CPU-rate caps + child-spawn-into-job supervision = later rungs. Founded on nx_pe_writer.nx (hand byte-layout, tutor-scaffold). genealogy_id: win32_job_objects_2000 + lmctfy_2013 + runc_cgroups_2016 lineage_id: substrate_pe_joblimit_v1

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_hal.nx nx_pe_writer.nx nx_pe_job_limit_test.nx

imports: nx_syscalls.nxnx_hal.nxnx_pe_writer.nx

imported by: nobody (leaf or entry point)

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

main nx_hal_alloc_pages nx_hal_active_shim nx_hal_alloc_pages_linux sys_mmap nx_hal_alloc_pages_bare_me nx_hal_alloc_pages_nishi_s nx_pe_emit_job_limit _w16 _w32 _w8 _w64 _w32 ↻ _emit_section_header _w8 ↻ _w32 ↻ _w16 ↻ nx_pe_write_to_file sys_openat_wr sys_write sys_close sys_write ↻

structs

none

consts

34const PE_JOBLIMIT_FILE_SIZE: i64 = 0x800 // 2048: headers + .text + .rdata + .idata

functions

38func nx_pe_emit_job_limit(buf: *u8, active_limit: i64) -> i64
222func main() -> i64