mirror of
https://github.com/Droid-VM/crosvm.git
synced 2026-11-17 06:58:03 +00:00
reserve_dma_buffer() handed out a DmaBuffer carrying the size the caller asked for, never comparing it against the mapping it points into. That mapping is a fixed MMAP_SIZE (1 MB) window over the usbfs fd, while the size comes from the guest's transfer descriptor -- so a longer request produced a DmaBuffer whose size does not describe its mapping. Every caller trusts that size: as_mut_slice() built a slice running off the end of the window, and that slice's length is the only bound ScatterGatherBuffer::read() has, so the copy walked straight past it. A DisplayLink adapter, whose driver pushes a frame as one bulk transfer, killed crosvm the moment the guest enabled display output. From the crash: memcpy(dst=0x6d5b015000, src=0x6f69310000, 0x10000) with the destination base at 0x6d5af15000 -- the fault address is base + 0x100000, exactly MMAP_SIZE, on the 17th of the TD's 64 kB TRBs. The IN direction had the mirror of it: as_slice() read past the window and wrote what it found there into guest memory. So ask the mapping for its size. A request that does not fit is refused, and request_transfer_buffer() falls back to TransferBuffer::Vector, whose length does describe its allocation; that costs a copy into the kernel's own DMA buffer and is bounded. The check reads managed.buf.size() rather than MMAP_SIZE so it still holds if the window ever stops being that constant. The refusal is reported once per new maximum rather than per transfer: a device whose transfers never fit asks again for every frame, and the useful thing to have in the log is the size it settles on, not thousands of identical lines. Nothing is logged for the pre-existing fallback of a busy slot. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NrTFaLfTucJb9LBtxtU6Ab |
History
|
|
|---|---|---|
| .. | ||
| src | ||
| Android.bp | ||
| Cargo.toml | ||
| OWNERS | ||