HLE: bounds-check all four bytes of ACP notification writes in audio::submit #2524
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2524
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@reeledMarek on GitHub · 2026-11-25 15:16 UTC · original
reeledMarek:fix/hle-audio-bounds-and-wrap→main· +47 −3 · 1 files · 1 commits · openProblem
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.@Marvisak on GitHub · 2026-11-25 15:54 UTC · original · edited 2026-11-25 20:23 UTC
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
@reeledMarek on GitHub · 2026-11-25 20:05 UTC · original
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.@futurepro62 on GitHub · 2026-11-26 01:41 UTC · original
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
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.