bcachefs: Fix missing bounds checks in bch2_alloc_read()
PATCH 1/1 bcachefs: Fix missing bounds checks in bch2_alloc_read()
We were checking that the alloc key was for a valid device, but not a valid bucket.
This is the upgrade path from versions prior to bcachefs being mainlined.
Reported-by [email protected]
Signed-off-by Kent Overstreet <[email protected]>
--- fs/bcachefs/alloc_background.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/bcachefs/alloc_background.c +10 -0
@@ -639,6 +639,16 @@ int bch2_alloc_read(struct bch_fs *c)continue ; } +if (k.k->p.offset < ca->mi.first_bucket) { +bch2_btree_iter_set_pos (&iter,POS (k.k->p.inode, ca->mi.first_bucket)); +continue ; + } + +if (k.k->p.offset >= ca->mi.nbuckets) { +bch2_btree_iter_set_pos (&iter,POS (k.k->p.inode +1 ,0 )); +continue ; + } +struct bch_alloc_v4 a; *bucket_gen (ca, k.k->p.offset) =bch2_alloc_to_v4 (k, &a)->gen;0 ;
Signature · 1 line
2.45.2