Skip to content

ext4: tighten mount-time superblock geometry validation

Baokun Li linux-ext4 sashiko-reviews 2 versions Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 13 repliesApplied
  2. v11 patch 2 repliesSuperseded

Changes in v2 from the cover letter

* Patch 1: Removed a spurious newline in the error message format string.
* Added Patches 2 and 3 to fix additional issues reported by Sashiko (independent of Patch 1).

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3ext4: reject mount if clusters/inodes per group are not 8-alignedfs/ext4/super.c+6 -42 replies
2/3ext4: reduce max cluster size to match documented 256MB limitfs/ext4/ext4.h+1 -15 replies
3/3ext4: reject mount if inodes per group is not a multiple of inodes per blockfs/ext4/super.c+2 -15 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchZhang YiAndreas DilgerJan Kara
1/3R-b R-b
2/3R-b
3/3R-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/3] ext4: tighten mount-time superblock geometry validation

Changes since v1:
* Patch 1: Removed a spurious newline in the error message format string.
* Added Patches 2 and 3 to fix additional issues reported by Sashiko (independent of Patch 1).

v1: https://patch.msgid.link/[email protected]

This series adds missing mount-time sanity checks for superblock geometry parameters, preventing crafted filesystem images from causing bitmap checksum corruption, integer overflow, or out-of-bounds inode table access.

Patch 1 rejects filesystems where s_clusters_per_group or s_inodes_per_group is not 8-aligned, since the bitmap checksum functions operate on whole bytes and would leave trailing bits unprotected.

Patch 2 reduces EXT4_MAX_CLUSTER_LOG_SIZE from 30 to 28 to match the documented 256MB limit in mke2fs, preventing a 32-bit overflow in the blocks-per-group consistency check on bigalloc filesystems.

Patch 3 rejects filesystems where s_inodes_per_group is not a multiple of s_inodes_per_block, preventing truncation in the s_itb_per_group calculation that could lead __ext4_get_inode_loc() to read beyond the inode table.

Baokun Li (3):
ext4: reject mount if clusters/inodes per group are not 8-aligned
ext4: reduce max cluster size to match documented 256MB limit
ext4: reject mount if inodes per group is not a multiple of inodes per
block

 fs/ext4/ext4.h  |  2 +-
 fs/ext4/super.c | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)
Signature · 1 line
2.43.7