summaryrefslogtreecommitdiff
path: root/fs/bcachefs/util.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-11-04 03:19:04 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:10 +0300
commit636ad1d391b9e0f22107ace04e6dbc07d8875739 (patch)
tree1cdf12df659eea899c1af638f2912fac3e12bbb8 /fs/bcachefs/util.c
parentac10a9611d8794c849092a777a5febc4f69788ae (diff)
downloadlinux-636ad1d391b9e0f22107ace04e6dbc07d8875739.tar.xz
bcachefs: fix bounds checks in bch2_bio_map()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/util.c')
-rw-r--r--fs/bcachefs/util.c4
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)