]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: tree-checker: introduce checks for FREE_SPACE_BITMAP
authorZhengYuan Huang <gality369@gmail.com>
Tue, 10 Mar 2026 21:56:10 +0000 (08:26 +1030)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 Apr 2026 16:56:02 +0000 (18:56 +0200)
commit94e445085c7be52c1cc937959fa8254b56cdf672
tree0b9a69bf90e5d031976a6a31f524a30e980ec9bd
parentb4a1246298d9c0a7cbcbc05d437c5803eb6a9994
btrfs: tree-checker: introduce checks for FREE_SPACE_BITMAP

Introduce checks for FREE_SPACE_BITMAP item, which include:

- Key alignment check
  Same as FREE_SPACE_EXTENT, the objectid is the logical bytenr of the
  free space, and offset is the length of the free space, so both
  should be aligned to the fs block size.

- Non-zero range check
  A zero key->offset would describe an empty bitmap, which is invalid.

- Item size check
  The item must hold exactly DIV_ROUND_UP(key->offset >> sectorsize_bits,
  BITS_PER_BYTE) bytes.  A mismatch indicates a truncated or otherwise
  corrupt bitmap item; without this check, the bitmap loading path would
  walk past the end of the leaf and trigger a NULL dereference in
  assert_eb_folio_uptodate().

Signed-off-by: ZhengYuan Huang <gality369@gmail.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tree-checker.c