Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iomap: reject delalloc mappings during writeback

Filesystems should never provide a delayed allocation mapping to
writeback; they're supposed to allocate the space before replying.
This can lead to weird IO errors and crashes in the block layer if the
filesystem is being malicious, or if it hadn't set iomap->dev because
it's a delalloc mapping.

Fix this by failing writeback on delalloc mappings. Currently no
filesystems actually misbehave in this manner, but we ought to be
stricter about things like that.

Cc: stable@vger.kernel.org # v5.5
Fixes: 598ecfbaa742ac ("iomap: lift the xfs writeback code to iomap")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://patch.msgid.link/20260302173002.GL13829@frogsfrogsfrogs
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Darrick J. Wong and committed by
Christian Brauner
d320f160 d3ccc4d8

+7 -6
+7 -6
fs/iomap/ioend.c
··· 215 215 WARN_ON_ONCE(!folio->private && map_len < dirty_len); 216 216 217 217 switch (wpc->iomap.type) { 218 - case IOMAP_INLINE: 219 - WARN_ON_ONCE(1); 220 - return -EIO; 218 + case IOMAP_UNWRITTEN: 219 + ioend_flags |= IOMAP_IOEND_UNWRITTEN; 220 + break; 221 + case IOMAP_MAPPED: 222 + break; 221 223 case IOMAP_HOLE: 222 224 return map_len; 223 225 default: 224 - break; 226 + WARN_ON_ONCE(1); 227 + return -EIO; 225 228 } 226 229 227 - if (wpc->iomap.type == IOMAP_UNWRITTEN) 228 - ioend_flags |= IOMAP_IOEND_UNWRITTEN; 229 230 if (wpc->iomap.flags & IOMAP_F_SHARED) 230 231 ioend_flags |= IOMAP_IOEND_SHARED; 231 232 if (folio_test_dropbehind(folio))