Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH v2 0/2] ext4: reject impossible group free cluster counts
@ 2026-11-19 12:25 Zhao Gongyi
  2026-11-19 12:26 ` [PATCH v2 1/2] jbd2: add a metadata validation hook to journal recovery Zhao Gongyi
  2026-11-19 12:26 ` [PATCH v2 2/2] ext4: reject impossible group free cluster counts Zhao Gongyi
  0 siblings, 2 replies; 5+ messages in thread
From: Zhao Gongyi @ 2026-11-19 12:25 UTC (permalink / raw)
  To: linux-ext4
  Cc: Zhao Gongyi, linux-kernel, tytso, adilger.kernel, libaokun, jack,
	ojaswin, ritesh.list, yi.zhang

ext4 initializes its free-space counters from the group descriptors. A
corrupt descriptor can advertise more free clusters than its group can
hold. Journal block replay can also replace the superblock and group
descriptors that were examined when mounting.

This series adds an optional JBD2 recovery callback and uses it in ext4
to validate the recovered geometry and group descriptors. It checks the
metadata before fast commit replay consumes it and checks the
descriptors again after fast commit replay. The ext4 check reads both
halves of the free-cluster count while holding the group lock.

Changes since v1

- Defer full descriptor validation on recovery mounts until journal
  block replay completes. Keep the initial checks needed to load the
  internal journal.
- Revalidate the superblock geometry and reload the descriptor table
  when replay changes its layout. Validate the free-cluster counts
  against the recovered geometry.
- Put the JBD2 interface in its own patch. Sample the group free-cluster
  count under the existing group lock.

Testing

The earlier combined patch was tested in an amd64 QEMU/KVM guest
running a 7.4.0-rc2-based kernel. The runs covered these cases.

- ext4 rejected the corrupted bigalloc image before free-space
  accounting. Valid read-only mounts succeeded and read-only mounts
  with an out-of-range count failed.
- Ordinary journal recovery succeeded and mounted read-write when the
  recovered group descriptors were valid.
- The recovery callback rejected an out-of-range count with an empty
  journal and during recovery with a nonempty journal when corruption
  remained in a separate group descriptor block.

The recovery tests used additional diagnostic logging to identify the
callback. The QEMU runs preceded the split and group-lock change.
Fast commit replay and recovery from an online resize that crosses a
group descriptor block boundary still need runtime coverage.

Built fs/ext4/ and fs/jbd2/ on the ext4 dev base with arm64 GCC 15.2
and W=1 after applying each patch in the series.

Link: https://lore.kernel.org/linux-ext4/20261102042428.65204-1-zhaogongyi@bytedance.com/

Zhao Gongyi (2):
  jbd2: add a metadata validation hook to journal recovery
  ext4: reject impossible group free cluster counts

 fs/ext4/balloc.c     |  10 +-
 fs/ext4/ext4.h       |   2 +
 fs/ext4/super.c      | 294 +++++++++++++++++++++++++++++++++----------
 fs/jbd2/journal.c    |  22 +++-
 fs/jbd2/recovery.c   |  38 ++++--
 include/linux/jbd2.h |   7 +-
 6 files changed, 287 insertions(+), 86 deletions(-)

base-commit: 4aa05e642bade8cf8405936b03cabf848fe6c456

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-19 13:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 12:25 [PATCH v2 0/2] ext4: reject impossible group free cluster counts Zhao Gongyi
2026-11-19 12:26 ` [PATCH v2 1/2] jbd2: add a metadata validation hook to journal recovery Zhao Gongyi
2026-11-19 12:34   ` sashiko-bot
2026-11-19 12:26 ` [PATCH v2 2/2] ext4: reject impossible group free cluster counts Zhao Gongyi
2026-11-19 13:02   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox