Skip to content

Commit d320f16

Browse files
Darrick J. Wongbrauner
authored andcommitted
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: [email protected] # v5.5 Fixes: 598ecfb ("iomap: lift the xfs writeback code to iomap") Signed-off-by: Darrick J. Wong <[email protected]> Link: https://patch.msgid.link/20260302173002.GL13829@frogsfrogsfrogs Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Carlos Maiolino <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent d3ccc4d commit d320f16

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

fs/iomap/ioend.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,18 @@ ssize_t iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, struct folio *folio,
215215
WARN_ON_ONCE(!folio->private && map_len < dirty_len);
216216

217217
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;
221223
case IOMAP_HOLE:
222224
return map_len;
223225
default:
224-
break;
226+
WARN_ON_ONCE(1);
227+
return -EIO;
225228
}
226229

227-
if (wpc->iomap.type == IOMAP_UNWRITTEN)
228-
ioend_flags |= IOMAP_IOEND_UNWRITTEN;
229230
if (wpc->iomap.flags & IOMAP_F_SHARED)
230231
ioend_flags |= IOMAP_IOEND_SHARED;
231232
if (folio_test_dropbehind(folio))

0 commit comments

Comments
 (0)