From: "Christian A . Ehrhardt" <lk@c--e.de>
To: TJ Adams <tadamsjr@google.com>
Cc: Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: advance iterator after copy-in for SG_DXFER_TO_FROM_DEV
Date: Mon, 26 Oct 2026 19:03:16 +0100 [thread overview]
Message-ID: <at-V5NK237TLh8rE@cae.in-ulm.de> (raw)
In-Reply-To: <20260929160813.1599129-1-tadamsjr@google.com>
Hi,
On Tue, Sep 29, 2026 at 09:08:13AM -0700, TJ Adams wrote:
> When a passthrough request uses transfer direction SG_DXFER_TO_FROM_DEV,
> bio_copy_user_iov() sets up a temporary iterator iter2 with
> data_source = ITER_SOURCE to copy user data into the bio pages before
> execution.
>
> bio_copy_from_iter(bio, &iter2) copies the data and advances iter2, but
> the original iter is never advanced. Consequently, iov_iter_count(&i)
> remains non-zero in the caller loop in blk_rq_map_user_iov():
>
> i = *iter;
> do {
> if (copy)
> ret = bio_copy_user_iov(rq, map_data, &i, gfp_mask);
> ...
> } while (iov_iter_count(&i));
>
> Because i is never advanced, blk_rq_map_user_iov() loops indefinitely,
> continually allocating bios and consuming map_data pages until it
> exhausts pages and fails with -EINVAL.
>
> Fix this by calling iov_iter_advance(iter, bio->bi_iter.bi_size) in the
> map_data && map_data->from_user branch after bio_copy_from_iter().
Sorry for being lazy on this (and for messing it up).
Acked-by: Christian A. Ehrhardt <lk@c--e.de>
Thanks,
Christian
>
> Fixes: 13f3956eb568 ("block: Fix WARNING in _copy_from_iter")
> Signed-off-by: Terrence Adams <tadamsjr@google.com>
> Assisted-by: LLM
> ---
> block/blk-map.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/block/blk-map.c b/block/blk-map.c
> index 9cb9605d1f62..2685f6177ceb 100644
> --- a/block/blk-map.c
> +++ b/block/blk-map.c
> @@ -236,6 +236,7 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data,
> ret = bio_copy_from_iter(bio, &iter2);
> if (ret)
> goto cleanup;
> + iov_iter_advance(iter, bio->bi_iter.bi_size);
> } else {
> if (bmd->is_our_pages)
> zero_fill_bio(bio);
> --
> 2.56.0.rc1.315.gc6ed9934b7-goog
>
>
next prev parent reply other threads:[~2026-10-26 18:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 16:08 TJ Adams
2026-10-16 17:52 ` TJ Adams
2026-10-26 18:03 ` Christian A . Ehrhardt [this message]
2026-10-26 18:13 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=at-V5NK237TLh8rE@cae.in-ulm.de \
--to=lk@c--e.de \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tadamsjr@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®