[DragonFlyBSD - Bug #3460] (New) u4b: DMA page table assumes page-aligned busdma segments (wrong data for USB storage reads with sub-page buffers)

sigttou bugtracker-admin at leaf.dragonflybsd.org
Wed Nov 4 06:30:02 PST 2026


Issue #3460 has been reported by sigttou.

----------------------------------------
Bug #3460: u4b: DMA page table assumes page-aligned busdma segments (wrong data for USB storage reads with sub-page buffers)
http://bugs.dragonflybsd.org/issues/3460

* Author: sigttou
* Status: New
* Priority: Normal
* Category: Driver
* Target version: 6.6
* Start date: 2026-11-04
----------------------------------------
@usb_pc_common_mem_cb()@ builds the page table from the busdma segment list and assumes that every segment after the first starts on a page boundary. busdma also splits at @maxsegsz@, so a segment can end in the middle of a page and its continuation start in the middle of a page. The walk then records the same page frame twice and shifts every later entry by one page. @usbd_get_page()@ hands the controller wrong bus addresses for all pages after the duplicated entry.

Effect: a multi-page read into a buffer whose first byte is not page aligned returns the content of the following page and leaves the tail of the transfer with unrelated memory. 1 KiB and 2 KiB block filesystems on USB storage are affected (ext2 1 KiB: wrong data after remount), 4 KiB blocks and single page transfers are not.

It needs a mid-page start together with such a split, so it is rare (about 0.006 % of buffer loads in my runs).

Fix: index the page table by buffer byte position instead (entry j is the frame containing buffer byte @j * USB_PAGE_SIZE - rem@, found in whichever segment covers it). The rem adjustment in @usbd_get_page()@ already matches this layout. FreeBSD's @usb_busdma.c@ has the same walk.


---Files--------------------------------
0001-u4b-Do-not-assume-page-aligned-busdma-segments-in-the-DMA-page-table.patch (3.7 KB)


-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account


More information about the Bugs mailing list