diff options
| author | Gianfranco Trad <gianf.trad@gmail.com> | 2024-10-23 23:30:44 +0200 |
|---|---|---|
| committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-10-24 17:41:43 -0400 |
| commit | 2045fc4295c427d420aa1ff551b4de8179b6e5d5 (patch) | |
| tree | ecd78fa27c1db3b22f2827dfdf99cc0fc8f967e4 /fs/bcachefs/super-io.c | |
| parent | bcachefs: Set bch_inode_unpacked.bi_snapshot in old inode path (diff) | |
| download | linux-2045fc4295c427d420aa1ff551b4de8179b6e5d5.tar.gz linux-2045fc4295c427d420aa1ff551b4de8179b6e5d5.zip | |
bcachefs: Fix invalid shift in validate_sb_layout()
Add check on layout->sb_max_size_bits against BCH_SB_LAYOUT_SIZE_BITS_MAX
to prevent UBSAN shift-out-of-bounds in validate_sb_layout().
Reported-by: syzbot+089fad5a3a5e77825426@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=089fad5a3a5e77825426
Fixes: 03ef80b469d5 ("bcachefs: Ignore unknown mount options")
Tested-by: syzbot+089fad5a3a5e77825426@syzkaller.appspotmail.com
Signed-off-by: Gianfranco Trad <gianf.trad@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/super-io.c')
| -rw-r--r-- | fs/bcachefs/super-io.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index ce7410d72089..7c71594f6a8b 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -287,6 +287,11 @@ static int validate_sb_layout(struct bch_sb_layout *layout, struct printbuf *out return -BCH_ERR_invalid_sb_layout_nr_superblocks; } + if (layout->sb_max_size_bits > BCH_SB_LAYOUT_SIZE_BITS_MAX) { + prt_printf(out, "Invalid superblock layout: max_size_bits too high"); + return -BCH_ERR_invalid_sb_layout_sb_max_size_bits; + } + max_sectors = 1 << layout->sb_max_size_bits; prev_offset = le64_to_cpu(layout->sb_offset[0]); |
