diff options
author | 2024-06-28 19:41:00 -0400 | |
---|---|---|
committer | 2024-06-28 19:42:22 -0400 | |
commit | a0bd30e4ea9da9499c5527dc84a0e2d291f273d2 (patch) | |
tree | 8f4ff3552b562316a0124434cab105ac11ed8af1 | |
parent | bcachefs: Change bch2_fs_journal_stop() BUG_ON() to warning (diff) | |
download | wireguard-linux-a0bd30e4ea9da9499c5527dc84a0e2d291f273d2.tar.xz wireguard-linux-a0bd30e4ea9da9499c5527dc84a0e2d291f273d2.zip |
bcachefs: Fix shift greater than integer size
Reported-by: syzbot+e5292b50f1957164a4b6@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/bkey.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/bcachefs/bkey.c b/fs/bcachefs/bkey.c index 94a1d1982fa8..587d7318a2e8 100644 --- a/fs/bcachefs/bkey.c +++ b/fs/bcachefs/bkey.c @@ -660,8 +660,9 @@ int bch2_bkey_format_invalid(struct bch_fs *c, bch2_bkey_format_field_overflows(f, i)) { unsigned unpacked_bits = bch2_bkey_format_current.bits_per_field[i]; u64 unpacked_max = ~((~0ULL << 1) << (unpacked_bits - 1)); - u64 packed_max = f->bits_per_field[i] - ? ~((~0ULL << 1) << (f->bits_per_field[i] - 1)) + unsigned packed_bits = min(64, f->bits_per_field[i]); + u64 packed_max = packed_bits + ? ~((~0ULL << 1) << (packed_bits - 1)) : 0; prt_printf(err, "field %u too large: %llu + %llu > %llu", |