Commit 0c7cee63 authored by Ming Lei's avatar Ming Lei Committed by Greg Kroah-Hartman

block: allow for_each_bvec to support zero len bvec

commit 7e249690 upstream.

Block layer usually doesn't support or allow zero-length bvec. Since
commit 1bdc76ae ("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.

Fixes: 1bdc76ae ("iov_iter: use bvec iterator to implement iterate_bvec()")
Reported-by: default avatarsyzbot <syzbot+61acc40a49a3e46e25ea@syzkaller.appspotmail.com>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Tested-by: default avatarTetsuo 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>
Link: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2262077.htmlSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f6648920
......@@ -88,10 +88,17 @@ static inline void bvec_iter_advance(const struct bio_vec *bv,
}
}
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 ? (void)bvec_iter_advance((bio_vec), &(iter), \
(bvl).bv_len) : bvec_iter_skip_zero_bvec(&(iter)))
#endif /* __LINUX_BVEC_ITER_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment