diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-04 19:26:37 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-06 16:58:17 +0200 |
commit | db42549d402cb44fe67c95d08f1a9ea902d32e7e (patch) | |
tree | 031244e3d77637c1f0bcfdbd8a08c950ce2b2c10 /fs/bcachefs/bcachefs_format.h | |
parent | bcachefs: Fix lifetime issue in device iterator helpers (diff) | |
download | linux-db42549d402cb44fe67c95d08f1a9ea902d32e7e.tar.xz 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 'fs/bcachefs/bcachefs_format.h')
-rw-r--r-- | fs/bcachefs/bcachefs_format.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index f7fbfccd2b1e..8345a2b2d05b 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -591,6 +591,12 @@ struct bch_member { __le64 btree_allocated_bitmap; }; +/* + * This limit comes from the bucket_gens array - it's a single allocation, and + * kernel allocation are limited to INT_MAX + */ +#define BCH_MEMBER_NBUCKETS_MAX (INT_MAX - 64) + #define BCH_MEMBER_V1_BYTES 56 LE64_BITMASK(BCH_MEMBER_STATE, struct bch_member, flags, 0, 4) |