hw_oracle/drm: harden ELF64 bounds, subprocess timeouts, and temp cleanup #2328
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2328"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-26T13:51:06Z.
Claimed in the coordination issue as: HW-ORACLE-DRM-ELF-BOUNDS-TIMEOUT-AND-TEMP-CLEANUP (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193870891)
What and why
.textslice, and kernel descriptor bounds checks (includingvalue < addressunderflow protection) intools/hw_oracle/drm.pyso truncated or corrupt objects raiseValueErrorinstead ofstruct.erroror out-of-range indexing.LEONIDA_HW_DRM_NODEvalues infind_node()withUnavailable.SUBPROCESS_TIMEOUT = 120topkg-config, compiler, launcher device probe, assembler, and_launch()subprocess invocations, converting(OSError, subprocess.TimeoutExpired)intoUnavailable,(None, str(e)), or(-1, "", str(e)).hw_oracle_drmbinaries in_build_launcher()withtempfile.mkstemp()and unlink temporary binaries on build or replace failure.tests/test_hw_oracle_drm_safety.py.Tested
python -I tests/test_hw_oracle_drm_safety.py -v: 3 passed, 0 failed (detachedupstream/mainbaseline with only the new test file fails with 2 errors).python -I tests/test_hw_oracle.py -v: 59 tests (OK, 3 skipped without AMD clang / libdrm gcc on host).python -I tests/test_ci_registration.py: 16 passed.python -I tests/test_text_write_line_endings.py: 3 passed.python -I scripts/check_no_game_data.py,python -I -m compileall -q tools/hw_oracle/drm.py tests/test_hw_oracle_drm_safety.py, andgit diff --cached --check: passed.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T04:42:29Z.
Review: APPROVED
Approving
6455daffe.The ELF64 reader now checks the header size, the section table,
shstrndx, each string table and string, the symbol table and the kernel descriptor against the file's length, so a truncated or hostile file raises aValueErrorinstead of indexing past the end. The helper build writes to amkstempname next to the executable and removes it on failure, and the subprocesses have timeouts that end asUnavailable.Merged onto
maind1dff7949in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13.tests/test_hw_oracle_drm_safety.py: 3 passed (new). AI-assisted (Claude Code, Claude Opus 5.5).Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T10:03:42Z.
#2328 | head
6455daffee(merged cleanly with main33db04a70) |python -I tests/test_hw_oracle_drm_safety.py| red on main:FAILED (errors=2)(malformed ELF64 headers/sections fail withstruct.error/ out-of-bounds reads instead ofValueError, andSUBPROCESS_TIMEOUTis absent) | green on PR+main:3 tests OK(-k test_elf64_bounds_reject_malformed_headers_and_descriptors:1 test OK) | Windows 11, Python 3.12.10 | AI-assisted: yesAudited
_symbols,text_section,kernel_registers, andDrmOraclesubprocess timeout /mkstempcleanup handling intools/hw_oracle/drm.py, and verified bothPR + main(33db04a70) and a combinedmain + #2328 + #2326merge (0conflicts;3 OK+3 OK). Also passedtests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK),tests/test_runner_calls_all_tests.py(3 OK), andscripts/check_no_game_data.py.Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T10:58:34Z.
Merged, thank you @kirigayakazima! This PR (hw_oracle/drm: harden ELF64 bounds, subprocess timeouts, and temp cleanup) was checked by zmasi or sodove and then by our own local run of its tests with main merged in, and it passed cleanly, so it went in with its reviewed batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.