diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-11-03 20:19:04 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2018-11-03 20:19:04 -0400 |
commit | b12d1535f33661c5f11925d9a2debe28be661088 (patch) | |
tree | 95ed0ba65ef0afe6ebea09a533b0f790553f2087 | |
parent | a780698e2947c2c072071e44aaa9eed1b59258b1 (diff) |
bcachefs: fix bounds checks in bch2_bio_map()
-rw-r--r-- | fs/bcachefs/util.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index 5cfaed5b305c..4df96ef0bcd0 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -526,15 +526,17 @@ void bch2_bio_map(struct bio *bio, void *base) BUG_ON(!bio->bi_iter.bi_size); BUG_ON(bio->bi_vcnt); + BUG_ON(!bio->bi_max_vecs); bv->bv_offset = base ? offset_in_page(base) : 0; goto start; for (; size; bio->bi_vcnt++, bv++) { + BUG_ON(bio->bi_vcnt >= bio->bi_max_vecs); + bv->bv_offset = 0; start: bv->bv_len = min_t(size_t, PAGE_SIZE - bv->bv_offset, size); - BUG_ON(bio->bi_vcnt >= bio->bi_max_vecs); if (base) { bv->bv_page = is_vmalloc_addr(base) ? vmalloc_to_page(base) |