diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-11-04 03:19:04 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:08:10 +0300 |
commit | 636ad1d391b9e0f22107ace04e6dbc07d8875739 (patch) | |
tree | 1cdf12df659eea899c1af638f2912fac3e12bbb8 /fs | |
parent | ac10a9611d8794c849092a777a5febc4f69788ae (diff) | |
download | linux-636ad1d391b9e0f22107ace04e6dbc07d8875739.tar.xz |
bcachefs: fix bounds checks in bch2_bio_map()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-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 75053322d0f0..ed90bd3a5d18 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -529,15 +529,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) |