aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/bcachefs/super.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-05-04 13:26:37 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-05-06 10:58:17 -0400
commitdb42549d402cb44fe67c95d08f1a9ea902d32e7e (patch)
tree031244e3d77637c1f0bcfdbd8a08c950ce2b2c10 /fs/bcachefs/super.c
parentbcachefs: Fix lifetime issue in device iterator helpers (diff)
downloadwireguard-linux-db42549d402cb44fe67c95d08f1a9ea902d32e7e.tar.xz
wireguard-linux-db42549d402cb44fe67c95d08f1a9ea902d32e7e.zip
bcachefs: Add a better limit for maximum number of buckets
The bucket_gens array is a single array allocation (one byte per bucket), and kernel allocations are still limited to INT_MAX. Check this limit to avoid failing the bucket_gens array allocation. Reported-by: syzbot+b29f436493184ea42e2b@syzkaller.appspotmail.com Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to '')
-rw-r--r--fs/bcachefs/super.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index c2c80e6890ae..dddf57ec4511 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -1959,6 +1959,13 @@ int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets)
goto err;
}
+ if (nbuckets > BCH_MEMBER_NBUCKETS_MAX) {
+ bch_err(ca, "New device size too big (%llu greater than max %u)",
+ nbuckets, BCH_MEMBER_NBUCKETS_MAX);
+ ret = -BCH_ERR_device_size_too_big;
+ goto err;
+ }
+
if (bch2_dev_is_online(ca) &&
get_capacity(ca->disk_sb.bdev->bd_disk) <
ca->mi.bucket_size * nbuckets) {