Skip to content

Commit 7e24969

Browse files
Ming Leiaxboe
authored andcommitted
block: allow for_each_bvec to support zero len bvec
Block layer usually doesn't support or allow zero-length bvec. Since commit 1bdc76a ("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: 1bdc76a ("iov_iter: use bvec iterator to implement iterate_bvec()") Reported-by: syzbot <[email protected]> Signed-off-by: Ming Lei <[email protected]> Tested-by: Tetsuo Handa <[email protected]> Cc: Al Viro <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: <[email protected]> Link: https://www.mail-archive.com/[email protected]/msg2262077.html Signed-off-by: Jens Axboe <[email protected]>
1 parent e11d80a commit 7e24969

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

include/linux/bvec.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,18 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv,
117117
return true;
118118
}
119119

120+
static inline void bvec_iter_skip_zero_bvec(struct bvec_iter *iter)
121+
{
122+
iter->bi_bvec_done = 0;
123+
iter->bi_idx++;
124+
}
125+
120126
#define for_each_bvec(bvl, bio_vec, iter, start) \
121127
for (iter = (start); \
122128
(iter).bi_size && \
123129
((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \
124-
bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
130+
(bvl).bv_len ? (void)bvec_iter_advance((bio_vec), &(iter), \
131+
(bvl).bv_len) : bvec_iter_skip_zero_bvec(&(iter)))
125132

126133
/* for iterating one bio from start to end */
127134
#define BVEC_ITER_ALL_INIT (struct bvec_iter) \

0 commit comments

Comments
 (0)