Bounds-check audio submit notifications and avoid u32 wrap in pump #460

Closed
github-bot wants to merge 660 commits from github-bot/gh-460 into main AGit
Owner

@⁠ahmetbagci8 on GitHub · 2026-11-29 20:50 UTC · original
ahmetbagci8:fix/hle-audio-notification-and-pump-bounds → main · +60050 −5435 · 206 files · 660 commits · closed without merging

Problem

In crates/victory-hle/src/modules/audio.rs:

  1. submit() validated
    otification with heap_unmap(notification) (which only checks that 1 byte is in bounds and does not check 4-byte alignment) before executing word.cast::().write_volatile(1). A notification address within the last 3 bytes of a heap block writes up to 3 bytes out of bounds, and an unaligned address triggers unaligned write_volatile UB.
  2. pump() computed let address = context.get(7) as usize + write as usize * BLOCK_BYTES; and cast ddress as u32, silently wrapping past u32::MAX into low APU addresses instead of returning None.
  3. heap_bytes() used unchecked offset + len <= size.

Fix

  • Require 4-byte alignment and full 4-byte bounds via heap_bytes(notification, size_of::()) in submit().
  • Use checked_add + u32::try_from in pump(), and offset.checked_add(len) in heap_bytes().
  • Add unit test submit_notification_requires_aligned_in_bounds_u32 covering both rejected unaligned/OOB notifications and valid aligned writes.

Verification

  • cargo test -p victory-hle --lib audio::tests (9 passed, 0 failed)
  • cargo clippy -p victory-hle --tests (0 warnings)
**@⁠ahmetbagci8** on GitHub · 2026-11-29 20:50 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/460) `ahmetbagci8:fix/hle-audio-notification-and-pump-bounds` → `main` · +60050 −5435 · 206 files · 660 commits · closed without merging ## Problem In crates/victory-hle/src/modules/audio.rs: 1. submit() validated otification with heap_unmap(notification) (which only checks that 1 byte is in bounds and does not check 4-byte alignment) before executing word.cast::<u32>().write_volatile(1). A notification address within the last 3 bytes of a heap block writes up to 3 bytes out of bounds, and an unaligned address triggers unaligned write_volatile UB. 2. pump() computed let address = context.get(7) as usize + write as usize * BLOCK_BYTES; and cast ddress as u32, silently wrapping past u32::MAX into low APU addresses instead of returning None. 3. heap_bytes() used unchecked offset + len <= size. ## Fix - Require 4-byte alignment and full 4-byte bounds via heap_bytes(notification, size_of::<u32>()) in submit(). - Use checked_add + u32::try_from in pump(), and offset.checked_add(len) in heap_bytes(). - Add unit test submit_notification_requires_aligned_in_bounds_u32 covering both rejected unaligned/OOB notifications and valid aligned writes. ## Verification - cargo test -p victory-hle --lib audio::tests (9 passed, 0 failed) - cargo clippy -p victory-hle --tests (0 warnings)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 20:51:45 +00:00
github-bot closed this pull request 2026-11-30 17:08:27 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-30 17:05 UTC · original

main has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current main and open a new PR; I'll review it there.

**@⁠TaynanGT** on GitHub · 2026-11-30 17:05 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/460#issuecomment-7285699538) `main` has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current `main` and open a new PR; I'll review it there.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.