[DragonFlyBSD - Bug #3461] (New) msdosfs: uiomovebp() makes sibling clusters read as zeros when the cluster size is smaller than a page
sigttou
bugtracker-admin at leaf.dragonflybsd.org
Wed Nov 4 06:30:04 PST 2026
Issue #3461 has been reported by sigttou.
----------------------------------------
Bug #3461: msdosfs: uiomovebp() makes sibling clusters read as zeros when the cluster size is smaller than a page
http://bugs.dragonflybsd.org/issues/3461
* Author: sigttou
* Status: New
* Priority: Normal
* Category: Driver
* Target version: 6.6
* Start date: 2026-11-04
----------------------------------------
@uiomovebp()@ (@sys/kern/kern_subr.c@) fixes up the last VM page of a buffer when it is not fully valid: @vm_page_zero_invalid(m, TRUE)@ zero-fills every invalid @DEV_BSIZE@ chunk and marks the whole page valid. With clusters smaller than a page (FAT16 with 512-byte clusters: 8 clusters per page) the first cluster read of a page therefore marks the other chunks of that page valid with zeros. Reads of the sibling clusters then find the VM backed buffer valid and are served the zeros from the cache without any I/O, although the data on disk is correct. Writes through the same path are affected the same way.
Symptom: single all-zero 512-byte clusters inside files after umount/mount, stuck until the page is evicted. Reproduced on real hardware (USB stick on xHCI, FAT16, 512-byte clusters).
Fix: for clusters smaller than a page, msdosfs no longer uses @uiomovebp()@ for the user copy and never touches user memory while a buffer is held (a fault into an mmap of the same file would recurse into the pager on the held buffer, which is the reason the fix-up exists).
read: copy the cluster out of the buffer, @bqrelse()@, then @uiomove()@ from the bounce buffer.
write: @uiomove()@ into a bounce buffer before @getblk()@/@bread()@, then @bcopy()@ into the buffer. On the @NOOFFSET@ and bread failure paths the uio offset and resid are rewound and the bounce is freed.
Not covered: @UIO_NOCOPY@ writes still use @uiomovebp()@. other callers of @uiomovebp()@ are untouched, a UFS fragment case with the same pattern is a guess, not tested yet. The generic alternative (what the TODO in the uiomovebp() header comment sketches: copy through a system buffer without holding the buffer or vnode lock) would fix all callers but is a larger change.
---Files--------------------------------
0002-msdosfs-Do-not-use-uiomovebp-for-sub-page-clusters.patch (5.73 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