mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] iomap: release pages on atomic dio size mismatch
@ 2026-06-12  4:40 Fengnan Chang
  2026-06-12  8:12 ` Christoph Hellwig
  2026-06-17 13:17 ` Christian Brauner
  0 siblings, 2 replies; 3+ messages in thread
From: Fengnan Chang @ 2026-06-12  4:40 UTC (permalink / raw)
  To: brauner, djwong, hch, linux-xfs, linux-fsdevel, linux-kernel
  Cc: Fengnan Chang

If bio_iov_iter_get_pages() or the bounce helper succeeds but builds a
short bio, the REQ_ATOMIC size check rejects it before submission.  The
old error path only dropped the bio reference, leaving any pages already
attached to the bio unreleased.

Release or unbounce the pages before falling through to out_put_bio on
this error path.

This bug was reported by sashiko:
https://sashiko.dev/#/patchset/20260608073134.95964-1-changfengnan%40bytedance.com

Fixes: 9e0933c21c12 ("fs: iomap: Atomic write support")
Signed-off-by: Fengnan Chang <changfengnan@bytedance.com>
---
 fs/iomap/direct-io.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index b36ee619cdcdd..9fedf367c3ebe 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -369,7 +369,7 @@ static ssize_t iomap_dio_bio_iter_one(struct iomap_iter *iter,
 	 */
 	if ((op & REQ_ATOMIC) && WARN_ON_ONCE(ret != iomap_length(iter))) {
 		ret = -EINVAL;
-		goto out_put_bio;
+		goto out_bio_release_pages;
 	}
 
 	if (iter->iomap.flags & IOMAP_F_INTEGRITY) {
@@ -393,6 +393,11 @@ static ssize_t iomap_dio_bio_iter_one(struct iomap_iter *iter,
 	iomap_dio_submit_bio(iter, dio, bio, pos);
 	return ret;
 
+out_bio_release_pages:
+	if (dio->flags & IOMAP_DIO_BOUNCE)
+		bio_iov_iter_unbounce(bio, true, false);
+	else
+		bio_release_pages(bio, false);
 out_put_bio:
 	bio_put(bio);
 	return ret;
-- 
2.39.5 (Apple Git-154)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] iomap: release pages on atomic dio size mismatch
  2026-06-12  4:40 [PATCH v1] iomap: release pages on atomic dio size mismatch Fengnan Chang
@ 2026-06-12  8:12 ` Christoph Hellwig
  2026-06-17 13:17 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-06-12  8:12 UTC (permalink / raw)
  To: Fengnan Chang
  Cc: brauner, djwong, hch, linux-xfs, linux-fsdevel, linux-kernel

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] iomap: release pages on atomic dio size mismatch
  2026-06-12  4:40 [PATCH v1] iomap: release pages on atomic dio size mismatch Fengnan Chang
  2026-06-12  8:12 ` Christoph Hellwig
@ 2026-06-17 13:17 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2026-06-17 13:17 UTC (permalink / raw)
  To: djwong, hch, linux-xfs, linux-fsdevel, linux-kernel, Fengnan Chang
  Cc: Christian Brauner

On Fri, 12 Jun 2026 12:40:41 +0800, Fengnan Chang wrote:
> If bio_iov_iter_get_pages() or the bounce helper succeeds but builds a
> short bio, the REQ_ATOMIC size check rejects it before submission.  The
> old error path only dropped the bio reference, leaving any pages already
> attached to the bio unreleased.
> 
> Release or unbounce the pages before falling through to out_put_bio on
> this error path.
> 
> [...]

Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] iomap: release pages on atomic dio size mismatch
      https://git.kernel.org/vfs/vfs/c/7d9491184bf7

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-17 13:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-12  4:40 [PATCH v1] iomap: release pages on atomic dio size mismatch Fengnan Chang
2026-06-12  8:12 ` Christoph Hellwig
2026-06-17 13:17 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®