DirectStorage: execute allocates 4-12 GiB from unvalidated request sizes before checking source/file/pages #1392
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#1392
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?
@microwave805 on GitHub · 2026-11-24 15:31 UTC · original
Checked on
main(930e8b4).Problem
dstorage::execute(crates/xcl/src/hle/dstorage.rs:872-893, 919) allocates heap buffers sized directly from guest-supplied 32-bitsource_sizeanddestination_sizebefore validating that the source or destination can actually supply/accept that many bytes:vec![0u8; r.source_size as usize]allocates up to ~4 GiB beforeshader::readable(line880, which rejects spans > 256 MiB) orread_physical_pages(line876).vec![0u8; r.source_size as usize]allocates up to ~4 GiB before checkingf.metadata()?.len().DEST_PHYS_PAGES_BITis set, line869skipswritable(), anddest_pagesare not validated until line935. For BC6H/BC7 (block = 16,stride = 32),bcpack::decode(bcpack/mod.rs:63) allocatesvec andvictory::decode(bcpack/victory.rs:112) allocatesvec — ~12 GiB total — before inspecting any input byte or validatingdest_pages.Minimal trigger
Enqueue a DirectStorage request with
DEST_PHYS_PAGES_BITand a 512 KiB page-number array:source_size = destination_size = 0xFFFF_FFFF) against a 1-byte file → allocates 4 GiB beforeread_exact_atreturnsE_END_OF_FILE.source_size = destination_size = 0xFFFF_FFFF) → allocates 4 GiB beforeshader::readablerejects it.source_size = 16, destination_size = 0xFFFF_FFF0) → allocates ~12 GiB acrossbcpack::decode+victory::decodebefore failing.This causes an unrecoverable worker-thread OOM abort crashing XCL instead of returning
E_END_OF_FILE/E_ACCESS_VIOLATION/E_DECOMPRESSION/E_OUTOFMEMORY.Suggested fix
Validate
shader::readable(memory),r.offset.checked_add(r.source_size as u64) <= f.metadata()?.len()(file), anddest_pagesvalidity before allocatingsrcor BCPack staging buffers, and usetry_reserve_exact(returningE_OUTOFMEMORY) for large request allocations.AI use: Antigravity (Gemini 4 Neon) performed the read-only source audit and drafted this issue; checked and verified on
930e8b4before opening.github-bot referenced this issue2026-11-26 04:53:52 +00:00
github-bot referenced this issue2026-11-26 04:59:09 +00:00