* [PATCH] lib/iov_iter: fix bvec iterator setup
@ 2024-11-02 1:42 Ming Lei
2024-11-02 14:45 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Ming Lei @ 2024-11-02 1:42 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Christoph Hellwig, Ming Lei, Eric Dumazet,
syzbot+71abe7ab2b70bca770fd
.bi_size of bvec iterator should be initialized as real max size for
walking, and .bi_bvec_done just counts how many bytes need to be
skipped in the 1st bvec, so .bi_size isn't related with .bi_bvec_done.
This patch fixes bvec iterator initialization, and the inner `size`
check isn't needed any more, so revert Eric Dumazet's commit
7bc802acf193 ("iov-iter: do not return more bytes than requested in
iov_iter_extract_bvec_pages()").
Cc: Eric Dumazet <edumazet@google.com>
Fixes: e4e535bff2bc ("iov_iter: don't require contiguous pages in iov_iter_extract_bvec_pages")
Reported-by: syzbot+71abe7ab2b70bca770fd@syzkaller.appspotmail.com
Tested-by: syzbot+71abe7ab2b70bca770fd@syzkaller.appspotmail.com
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
Hi Jens,
If possible, please merge this one with Eric's commit.
lib/iov_iter.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 3026bdcb4738..4a54c7af62c0 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1700,7 +1700,7 @@ static ssize_t iov_iter_extract_bvec_pages(struct iov_iter *i,
skip = 0;
}
bi.bi_idx = 0;
- bi.bi_size = maxsize + skip;
+ bi.bi_size = maxsize;
bi.bi_bvec_done = skip;
maxpages = want_pages_array(pages, maxsize, skip, maxpages);
@@ -1724,10 +1724,6 @@ static ssize_t iov_iter_extract_bvec_pages(struct iov_iter *i,
(*pages)[k++] = bv.bv_page;
size += bv.bv_len;
- if (size >= maxsize) {
- size = maxsize;
- break;
- }
if (k >= maxpages)
break;
--
2.46.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lib/iov_iter: fix bvec iterator setup
2024-11-02 1:42 [PATCH] lib/iov_iter: fix bvec iterator setup Ming Lei
@ 2024-11-02 14:45 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2024-11-02 14:45 UTC (permalink / raw)
To: Ming Lei, linux-block
Cc: Christoph Hellwig, Eric Dumazet, syzbot+71abe7ab2b70bca770fd
On 11/1/24 7:42 PM, Ming Lei wrote:
> .bi_size of bvec iterator should be initialized as real max size for
> walking, and .bi_bvec_done just counts how many bytes need to be
> skipped in the 1st bvec, so .bi_size isn't related with .bi_bvec_done.
>
> This patch fixes bvec iterator initialization, and the inner `size`
> check isn't needed any more, so revert Eric Dumazet's commit
> 7bc802acf193 ("iov-iter: do not return more bytes than requested in
> iov_iter_extract_bvec_pages()").
>
> Cc: Eric Dumazet <edumazet@google.com>
> Fixes: e4e535bff2bc ("iov_iter: don't require contiguous pages in iov_iter_extract_bvec_pages")
> Reported-by: syzbot+71abe7ab2b70bca770fd@syzkaller.appspotmail.com
> Tested-by: syzbot+71abe7ab2b70bca770fd@syzkaller.appspotmail.com
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> Hi Jens,
>
> If possible, please merge this one with Eric's commit.
I can just swap them out.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-02 14:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-02 1:42 [PATCH] lib/iov_iter: fix bvec iterator setup Ming Lei
2024-11-02 14:45 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).