hw_oracle/drm: harden ELF64 bounds, subprocess timeouts, and temp cleanup #2328
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2328
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/hw-oracle-drm-elf-safety"
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?
Pull request successfully merged and closed
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.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).#2328 | head 6455daffeef71ab7f06c3a1a6023e1d774eeac42 (merged cleanly with main 33db04a70) |
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.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.