[PR #2328] hw_oracle/drm: harden ELF64 bounds, subprocess timeouts, and temp cleanup #2332

Open
opened 2026-11-26 21:20:51 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2328
Author: @kirigayakazima
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/hw-oracle-drm-elf-safety


📝 Commits (1)

  • 6455daf hw_oracle/drm: harden ELF64 bounds, subprocess timeouts, and temp cleanup

📊 Changes

2 files changed (+209 additions, -21 deletions)

View changed files

➕ tests/test_hw_oracle_drm_safety.py (+138 -0)
📝 tools/hw_oracle/drm.py (+71 -21)

📄 Description

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

  • Add ELF64 section header, string table, symbol table, .text slice, and kernel descriptor bounds checks (including value < address underflow protection) in tools/hw_oracle/drm.py so truncated or corrupt objects raise ValueError instead of struct.error or out-of-range indexing.
  • Reject blank LEONIDA_HW_DRM_NODE values in find_node() with Unavailable.
  • Add SUBPROCESS_TIMEOUT = 120 to pkg-config, compiler, launcher device probe, assembler, and _launch() subprocess invocations, converting (OSError, subprocess.TimeoutExpired) into Unavailable, (None, str(e)), or (-1, "", str(e)).
  • Stage compiled hw_oracle_drm binaries in _build_launcher() with tempfile.mkstemp() and unlink temporary binaries on build or replace failure.
  • Add standard-library unit tests in tests/test_hw_oracle_drm_safety.py.

Tested

  • python -I tests/test_hw_oracle_drm_safety.py -v: 3 passed, 0 failed (detached upstream/main baseline 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, and git diff --cached --check: passed.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2328 **Author:** [@kirigayakazima](https://github.com/kirigayakazima) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/hw-oracle-drm-elf-safety` --- ### 📝 Commits (1) - [`6455daf`](https://github.com/ubiquitarianism/leonida/commit/6455daffeef71ab7f06c3a1a6023e1d774eeac42) hw_oracle/drm: harden ELF64 bounds, subprocess timeouts, and temp cleanup ### 📊 Changes **2 files changed** (+209 additions, -21 deletions) <details> <summary>View changed files</summary> ➕ `tests/test_hw_oracle_drm_safety.py` (+138 -0) 📝 `tools/hw_oracle/drm.py` (+71 -21) </details> ### 📄 Description 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 - Add ELF64 section header, string table, symbol table, `.text` slice, and kernel descriptor bounds checks (including `value < address` underflow protection) in `tools/hw_oracle/drm.py` so truncated or corrupt objects raise `ValueError` instead of `struct.error` or out-of-range indexing. - Reject blank `LEONIDA_HW_DRM_NODE` values in `find_node()` with `Unavailable`. - Add `SUBPROCESS_TIMEOUT = 120` to `pkg-config`, compiler, launcher device probe, assembler, and `_launch()` subprocess invocations, converting `(OSError, subprocess.TimeoutExpired)` into `Unavailable`, `(None, str(e))`, or `(-1, "", str(e))`. - Stage compiled `hw_oracle_drm` binaries in `_build_launcher()` with `tempfile.mkstemp()` and unlink temporary binaries on build or replace failure. - Add standard-library unit tests in `tests/test_hw_oracle_drm_safety.py`. ### Tested - `python -I tests/test_hw_oracle_drm_safety.py -v`: 3 passed, 0 failed (detached `upstream/main` baseline 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`, and `git diff --cached --check`: passed. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2332
No description provided.