Skip to content

Commit c1bd21b

Browse files
author
Kent Overstreet
committed
bcachefs: Fix invalid shift in member_to_text()
Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent 7d84d9f commit c1bd21b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fs/bcachefs/sb-members.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ static int validate_member(struct printbuf *err,
163163
return -BCH_ERR_invalid_sb_members;
164164
}
165165

166+
if (m.btree_bitmap_shift >= 64) {
167+
prt_printf(err, "device %u: invalid btree_bitmap_shift %u", i, m.btree_bitmap_shift);
168+
return -BCH_ERR_invalid_sb_members;
169+
}
170+
166171
return 0;
167172
}
168173

@@ -247,7 +252,10 @@ static void member_to_text(struct printbuf *out,
247252
prt_newline(out);
248253

249254
prt_printf(out, "Btree allocated bitmap blocksize:\t");
250-
prt_units_u64(out, 1ULL << m.btree_bitmap_shift);
255+
if (m.btree_bitmap_shift < 64)
256+
prt_units_u64(out, 1ULL << m.btree_bitmap_shift);
257+
else
258+
prt_printf(out, "(invalid shift %u)", m.btree_bitmap_shift);
251259
prt_newline(out);
252260

253261
prt_printf(out, "Btree allocated bitmap:\t");

0 commit comments

Comments
 (0)