Skip to content

Commit

Permalink
block: Fix for_each_bvec()
Browse files Browse the repository at this point in the history
Commit 4550dd6 introduced for_each_bvec() which iterates over each
bvec attached to a bio or bip. However, the macro fails to check bi_size
before dereferencing which can lead to crashes while counting/mapping
integrity scatterlist segments.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Kent Overstreet <kmo@daterainc.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: <stable@vger.kernel.org> # v3.14+
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Martin K. Petersen authored and Jens Axboe committed Apr 9, 2014
1 parent 44bd70c commit b7aa84d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/linux/bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ static inline void bvec_iter_advance(struct bio_vec *bv, struct bvec_iter *iter,
}

#define for_each_bvec(bvl, bio_vec, iter, start) \
for ((iter) = start; \
(bvl) = bvec_iter_bvec((bio_vec), (iter)), \
(iter).bi_size; \
for (iter = (start); \
(iter).bi_size && \
((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \
bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))


Expand Down

0 comments on commit b7aa84d

Please sign in to comment.