audio: XMA decoder slices can outlive ApuFree (use-after-free when a title frees live APU memory) #230
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX#230
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@kekonn on GitHub · 2026-11-26 12:10 UTC · original
In
crates/victory-hle/src/modules/audio.rs,heap_bytes(183) returns&'a mut [u8]with an unbound lifetime after theHEAPguard is dropped. The decoder thread writes output blocks through it (~541-548) and reads input packets (~611-623).heap_free(125) removes the block from the map and immediately callsstd::alloc::dealloc, with no synchronisation against the decoder.When: only if the title calls
ApuFreeon a voice's ring or input buffer while the voice is still enabled and mid-pass. The intended protocol is safe: disabling a voice takes the per-voice lock the decoder holds, and inputs are freed only after their valid bit is cleared. So this is a title bug that would also corrupt memory on the console. It's not a quick fix, but it is cheap insurance.Sketch (~18 lines): defer the host
dealloc. While the decoder thread exists,heap_freestill removes the block and gives the device range back, but pushes(ptr, layout)to aFREEDlist. The decoder drains that list after eachpump(), when no slice is held. TheApuFreetests check device-address ranges, which are still given back immediately.Upstream: no open PR touches
audio.rs.Generated by Claude Code