* [PATCH V2] block: allow for_each_bvec to support zero len bvec
@ 2020-08-17 10:00 Ming Lei
2020-09-02 1:06 ` Ming Lei
2020-09-02 17:55 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Ming Lei @ 2020-08-17 10:00 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Ming Lei, syzbot, Tetsuo Handa, Al Viro,
Matthew Wilcox, stable
Block layer usually doesn't support or allow zero-length bvec. Since
commit 1bdc76aea115 ("iov_iter: use bvec iterator to implement
iterate_bvec()"), iterate_bvec() switches to bvec iterator. However,
Al mentioned that 'Zero-length segments are not disallowed' in iov_iter.
Fixes for_each_bvec() so that it can move on after seeing one zero
length bvec.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2262077.html
Fixes: 1bdc76aea115 ("iov_iter: use bvec iterator to implement iterate_bvec()")
Reported-by: syzbot <syzbot+61acc40a49a3e46e25ea@syzkaller.appspotmail.com>
Tested-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: <stable@vger.kernel.org>
---
V2:
- fix reported-by tag
include/linux/bvec.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index ac0c7299d5b8..9c4fab5f22a7 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -117,11 +117,18 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv,
return true;
}
+static inline void bvec_iter_skip_zero_bvec(struct bvec_iter *iter)
+{
+ iter->bi_bvec_done = 0;
+ iter->bi_idx++;
+}
+
#define for_each_bvec(bvl, bio_vec, iter, start) \
for (iter = (start); \
(iter).bi_size && \
((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \
- bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
+ (bvl).bv_len ? bvec_iter_advance((bio_vec), &(iter), \
+ (bvl).bv_len) : bvec_iter_skip_zero_bvec(&(iter)))
/* for iterating one bio from start to end */
#define BVEC_ITER_ALL_INIT (struct bvec_iter) \
--
2.25.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2] block: allow for_each_bvec to support zero len bvec
2020-08-17 10:00 [PATCH V2] block: allow for_each_bvec to support zero len bvec Ming Lei
@ 2020-09-02 1:06 ` Ming Lei
2020-09-02 17:55 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Ming Lei @ 2020-09-02 1:06 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, syzbot, Tetsuo Handa, Al Viro, Matthew Wilcox, stable
On Mon, Aug 17, 2020 at 06:00:55PM +0800, Ming Lei wrote:
> Block layer usually doesn't support or allow zero-length bvec. Since
> commit 1bdc76aea115 ("iov_iter: use bvec iterator to implement
> iterate_bvec()"), iterate_bvec() switches to bvec iterator. However,
> Al mentioned that 'Zero-length segments are not disallowed' in iov_iter.
>
> Fixes for_each_bvec() so that it can move on after seeing one zero
> length bvec.
>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> Link: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2262077.html
> Fixes: 1bdc76aea115 ("iov_iter: use bvec iterator to implement iterate_bvec()")
> Reported-by: syzbot <syzbot+61acc40a49a3e46e25ea@syzkaller.appspotmail.com>
> Tested-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Matthew Wilcox <willy@infradead.org>
> Cc: <stable@vger.kernel.org>
> ---
> V2:
> - fix reported-by tag
>
> include/linux/bvec.h | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/bvec.h b/include/linux/bvec.h
> index ac0c7299d5b8..9c4fab5f22a7 100644
> --- a/include/linux/bvec.h
> +++ b/include/linux/bvec.h
> @@ -117,11 +117,18 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv,
> return true;
> }
>
> +static inline void bvec_iter_skip_zero_bvec(struct bvec_iter *iter)
> +{
> + iter->bi_bvec_done = 0;
> + iter->bi_idx++;
> +}
> +
> #define for_each_bvec(bvl, bio_vec, iter, start) \
> for (iter = (start); \
> (iter).bi_size && \
> ((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \
> - bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
> + (bvl).bv_len ? bvec_iter_advance((bio_vec), &(iter), \
> + (bvl).bv_len) : bvec_iter_skip_zero_bvec(&(iter)))
>
> /* for iterating one bio from start to end */
> #define BVEC_ITER_ALL_INIT (struct bvec_iter) \
> --
> 2.25.2
>
Hello Jens,
Looks at least two reports can be fixed by this patch, so could you
take a look?
Thanks,
Ming
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V2] block: allow for_each_bvec to support zero len bvec
2020-08-17 10:00 [PATCH V2] block: allow for_each_bvec to support zero len bvec Ming Lei
2020-09-02 1:06 ` Ming Lei
@ 2020-09-02 17:55 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2020-09-02 17:55 UTC (permalink / raw)
To: Ming Lei
Cc: linux-block, syzbot, Tetsuo Handa, Al Viro, Matthew Wilcox, stable
On 8/17/20 4:00 AM, Ming Lei wrote:
> Block layer usually doesn't support or allow zero-length bvec. Since
> commit 1bdc76aea115 ("iov_iter: use bvec iterator to implement
> iterate_bvec()"), iterate_bvec() switches to bvec iterator. However,
> Al mentioned that 'Zero-length segments are not disallowed' in iov_iter.
>
> Fixes for_each_bvec() so that it can move on after seeing one zero
> length bvec.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-02 17:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17 10:00 [PATCH V2] block: allow for_each_bvec to support zero len bvec Ming Lei
2020-09-02 1:06 ` Ming Lei
2020-09-02 17:55 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.