diff options
author | 2024-05-05 22:02:28 -0400 | |
---|---|---|
committer | 2024-05-06 10:58:17 -0400 | |
commit | 6b8cbfc3db7582d6f26c6b757d8e949174641709 (patch) | |
tree | 509a2147c5f3b92d9a41458be38a14374b9fbd22 /fs/bcachefs/alloc_background.h | |
parent | bcachefs: fix overflow in fiemap (diff) | |
download | wireguard-linux-6b8cbfc3db7582d6f26c6b757d8e949174641709.tar.xz wireguard-linux-6b8cbfc3db7582d6f26c6b757d8e949174641709.zip |
bcachefs: Fix assert in bch2_alloc_v4_invalid()
Reported-by: syzbot+10827fa6b176e1acf1d0@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to '')
-rw-r--r-- | fs/bcachefs/alloc_background.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h index 052b2fac25d6..2790e516383d 100644 --- a/fs/bcachefs/alloc_background.h +++ b/fs/bcachefs/alloc_background.h @@ -126,13 +126,17 @@ static inline struct bpos alloc_freespace_pos(struct bpos pos, struct bch_alloc_ return pos; } -static inline unsigned alloc_v4_u64s(const struct bch_alloc_v4 *a) +static inline unsigned alloc_v4_u64s_noerror(const struct bch_alloc_v4 *a) { - unsigned ret = (BCH_ALLOC_V4_BACKPOINTERS_START(a) ?: + return (BCH_ALLOC_V4_BACKPOINTERS_START(a) ?: BCH_ALLOC_V4_U64s_V0) + BCH_ALLOC_V4_NR_BACKPOINTERS(a) * (sizeof(struct bch_backpointer) / sizeof(u64)); +} +static inline unsigned alloc_v4_u64s(const struct bch_alloc_v4 *a) +{ + unsigned ret = alloc_v4_u64s_noerror(a); BUG_ON(ret > U8_MAX - BKEY_U64s); return ret; } |