Skip to content

Commit 71dac24

Browse files
author
Kent Overstreet
committed
bcachefs: BCH_SB_LAYOUT_SIZE_BITS_MAX
Define a constant for the max superblock size, to avoid a too-large shift. Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent 88ab101 commit 71dac24

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

fs/bcachefs/bcachefs_format.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,8 @@ unsigned bcachefs_metadata_required_upgrade_below = bcachefs_metadata_version_re
903903
#define BCH_SB_SECTOR 8
904904
#define BCH_SB_MEMBERS_MAX 64 /* XXX kill */
905905

906+
#define BCH_SB_LAYOUT_SIZE_BITS_MAX 16 /* 32 MB */
907+
906908
struct bch_sb_layout {
907909
__uuid_t magic; /* bcachefs superblock UUID */
908910
__u8 layout_type;

fs/bcachefs/super-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ static int read_one_super(struct bch_sb_handle *sb, u64 offset, struct printbuf
649649

650650
bytes = vstruct_bytes(sb->sb);
651651

652-
if (bytes > 512 << sb->sb->layout.sb_max_size_bits) {
652+
if (bytes > 512ULL << min(BCH_SB_LAYOUT_SIZE_BITS_MAX, sb->sb->layout.sb_max_size_bits)) {
653653
prt_printf(err, "Invalid superblock: too big (got %zu bytes, layout max %lu)",
654654
bytes, 512UL << sb->sb->layout.sb_max_size_bits);
655655
return -BCH_ERR_invalid_sb_too_big;

0 commit comments

Comments
 (0)