HLE: bounds-check all four bytes of ACP notification writes in audio::submit #2522
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2524"
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 Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T15:16:40Z.
Problem
audio::submit, ACP notification writes usedheap_unmap(notification)(which only verifies 1 byte inside an APU heap block) and unconditionally executedword.cast::<u32>().write_volatile(1). A notification address in the last 1–3 bytes of a block writes past the end of the heap allocation, and any non-4-byte-aligned address triggers misaligned volatile write UB.audio::pump,context.get(7) as usize + write as usize * BLOCK_BYTEScast backas u32silently wrapped 32-bit device addresses nearu32::MAX.heap_bytesperformed uncheckedoffset + len.Fix
heap_bytes(notification, 4)andbytes.as_ptr().cast::<u32>().is_aligned().checked_mul/checked_addfor XMA output ring address computation inpumpandchecked_addinheap_bytes.Testing
acp_notification_rejects_out_of_bounds_and_unaligned_addressesandpump_ignores_wrapping_output_ring_addressincrates/victory-hle/src/modules/audio.rs.cargo test -p xtask --lockedpasses asset policy.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:54:21Z.
Automated triage for the maintainers.
Merge candidate. In
submit(crates/victory-hle/src/modules/audio.rs), the ACP notification word was written throughheap_unmap, which only checks that its first byte is inside a heap block. It is now written throughheap_bytes(notification, 4), which requires all four bytes in one block, withcopy_from_slice(&1u32.to_le_bytes()). A notification at the last 1–3 bytes of a block no longer writes past it. An unaligned in-bounds notification is still written, now without the misalignedwrite_volatile. The new test covers the tail cases (nothing written), an unaligned write at +1 and an aligned write at +12.Reply to the author: both points from the last triage are addressed. Unaligned notifications are written instead of dropped, and the
pump/heap_bytesoverflow guards and their test are gone. The PR description still lists the dropped changes and the old test names, so please update it before merge.CI:
checkpassing.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T20:05:21Z.
Updated to address the triage feedback:
heap_bytes(notification, 4)insubmitand switched tobytes.copy_from_slice(&1u32.to_le_bytes())so unaligned in-bounds notifications still complete instead of being silently dropped.pump/heap_bytesandpump_ignores_wrapping_output_ring_address.[PR #2524] HLE: bounds-check ACP notification writes and XMA pump address arithmeticto [PR #2524] HLE: bounds-check all four bytes of ACP notification writes in audio::submitImported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T01:41:13Z.
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head
5d6fbb4(on its base13f91ca).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 774 passed, 0 failed, 9 ignored.acp_notification_checks_all_four_bytes_and_allows_unaligned.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:20:39Z.
Review: COMMENTED
Reviewed and verified against
main(63bcca43) on Windows 11 — clean bounds fix and ready to merge:audio::submit's ACP notification write fromheap_unmaptoheap_bytes(notification, 4)(crates/victory-hle/src/modules/audio.rs:212-220, 905-909) validates all 4 bytes againstblock.size(rejecting+13/+14/+15on a 16-byte block) while supporting valid unaligned addresses safely.Local verification:
cargo test --locked -p victory-hle: 155/155 passed (includingacp_notification_checks_all_four_bytes_and_allows_unaligned)cargo clippy --all-targets -- -D warnings(default &--all-features) +cargo xtask policy(191 files ok): 0 warningsImported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T02:05:05Z.
Independent CPU-only verification on Windows (Rust 1.100.0/MSVC, worktree-local
CARGO_TARGET_DIR,CARGO_BUILD_JOBS=2, no game data).5d6fbb4, merge base13f91ca.cargo test --locked -p victory-hle --lib -- modules::audio::tests::acp_notification_checks_all_four_bytes_and_allows_unaligned --exact --test-threads=1 --quiet->test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 146 filtered out.git diff --check 13f91ca HEAD-> exit 0.13f91ca(git grep -c ... crates/victory-hle/src/modules/audio.rs-> exit 1). The PR body names a different, stale test name.Note: only the named synthetic test was replayed; the full crate suite was not run. GPU/driver: N/A (CPU-only HLE test). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM involved.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.