* [PATCH] iomap: reject delalloc mappings during writeback
@ 2026-02-26 18:00 Darrick J. Wong
2026-02-26 21:29 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2026-02-26 18:00 UTC (permalink / raw)
To: Christoph Hellwig, Christian Brauner; +Cc: linux-fsdevel, xfs
From: Darrick J. Wong <djwong@kernel.org>
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>
---
fs/iomap/ioend.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/iomap/ioend.c b/fs/iomap/ioend.c
index 4d1ef8a2cee90b..62dd539e087c7d 100644
--- a/fs/iomap/ioend.c
+++ b/fs/iomap/ioend.c
@@ -216,6 +216,7 @@ ssize_t iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, struct folio *folio,
switch (wpc->iomap.type) {
case IOMAP_INLINE:
+ case IOMAP_DELALLOC:
WARN_ON_ONCE(1);
return -EIO;
case IOMAP_HOLE:
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iomap: reject delalloc mappings during writeback
2026-02-26 18:00 [PATCH] iomap: reject delalloc mappings during writeback Darrick J. Wong
@ 2026-02-26 21:29 ` Christoph Hellwig
2026-02-26 23:33 ` Darrick J. Wong
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2026-02-26 21:29 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Christoph Hellwig, Christian Brauner, linux-fsdevel, xfs
On Thu, Feb 26, 2026 at 10:00:58AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> 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.
Maybe switch to to explicitly listing the acceptable types and rejecting
the rest instead?
diff --git a/fs/iomap/ioend.c b/fs/iomap/ioend.c
index e4d57cb969f1..2dd49677905f 100644
--- a/fs/iomap/ioend.c
+++ b/fs/iomap/ioend.c
@@ -169,17 +169,18 @@ ssize_t iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, struct folio *folio,
WARN_ON_ONCE(!folio->private && map_len < dirty_len);
switch (wpc->iomap.type) {
- case IOMAP_INLINE:
- WARN_ON_ONCE(1);
- return -EIO;
+ case IOMAP_UNWRITTEN:
+ ioend_flags |= IOMAP_IOEND_UNWRITTEN;
+ fallthrough;
+ case IOMAP_MAPPED:
+ break;
case IOMAP_HOLE:
return map_len;
default:
- break;
+ WARN_ON_ONCE(1);
+ return -EIO;
}
- if (wpc->iomap.type == IOMAP_UNWRITTEN)
- ioend_flags |= IOMAP_IOEND_UNWRITTEN;
if (wpc->iomap.flags & IOMAP_F_SHARED)
ioend_flags |= IOMAP_IOEND_SHARED;
if (folio_test_dropbehind(folio))
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iomap: reject delalloc mappings during writeback
2026-02-26 21:29 ` Christoph Hellwig
@ 2026-02-26 23:33 ` Darrick J. Wong
0 siblings, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2026-02-26 23:33 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Christian Brauner, linux-fsdevel, xfs
On Thu, Feb 26, 2026 at 01:29:37PM -0800, Christoph Hellwig wrote:
> On Thu, Feb 26, 2026 at 10:00:58AM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > 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.
>
> Maybe switch to to explicitly listing the acceptable types and rejecting
> the rest instead?
Yeah, that's a better solution, particularly if we ever add a new
mapping type.
--D
> diff --git a/fs/iomap/ioend.c b/fs/iomap/ioend.c
> index e4d57cb969f1..2dd49677905f 100644
> --- a/fs/iomap/ioend.c
> +++ b/fs/iomap/ioend.c
> @@ -169,17 +169,18 @@ ssize_t iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, struct folio *folio,
> WARN_ON_ONCE(!folio->private && map_len < dirty_len);
>
> switch (wpc->iomap.type) {
> - case IOMAP_INLINE:
> - WARN_ON_ONCE(1);
> - return -EIO;
> + case IOMAP_UNWRITTEN:
> + ioend_flags |= IOMAP_IOEND_UNWRITTEN;
> + fallthrough;
> + case IOMAP_MAPPED:
> + break;
> case IOMAP_HOLE:
> return map_len;
> default:
> - break;
> + WARN_ON_ONCE(1);
> + return -EIO;
> }
>
> - if (wpc->iomap.type == IOMAP_UNWRITTEN)
> - ioend_flags |= IOMAP_IOEND_UNWRITTEN;
> if (wpc->iomap.flags & IOMAP_F_SHARED)
> ioend_flags |= IOMAP_IOEND_SHARED;
> if (folio_test_dropbehind(folio))
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-26 23:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 18:00 [PATCH] iomap: reject delalloc mappings during writeback Darrick J. Wong
2026-02-26 21:29 ` Christoph Hellwig
2026-02-26 23:33 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox