Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH v4 0/2] ext4: reject impossible group free cluster counts
@ 2026-11-24  3:38 Zhao Gongyi
  2026-11-24  4:04 ` sashiko-bot
  2026-11-24 14:55 ` Theodore Tso
  0 siblings, 2 replies; 3+ messages in thread
From: Zhao Gongyi @ 2026-11-24  3:38 UTC (permalink / raw)
  To: linux-ext4
  Cc: 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 and checks the descriptors again
after fast commit replay. Both halves of the group free-cluster count
are read under the group lock.

Changes since v3

- Reject loss of HAS_JOURNAL before fast commit replay or journal
  reset.
- Recheck the extra inode size settings and the checksum seed,
  including EA_INODE and CSUM_SEED without METADATA_CSUM.
- Validate feature and field changes that affect mount setup.
  Recheck encryption constraints and initialize the VFS encoding
  when replay applies online feature enablement.
- Preserve JBD2's failed-commit diagnostic when recovery uses a
  validation callback. Document the callback context and lifetime.

Changes since v2

- Skip restoring and writing out superblock error information when
  journal load fails.
- Drain deferred EA inode evictions before checking descriptors after
  fast commit replay. If replay fails, drain the work before restoring
  the read-only flag. Leave fast commit state cleanup to the mount
  failure path.
- Reject changes to the casefold feature and encoding settings during
  journal recovery.
- The JBD2 patch is unchanged.

Changes since v1

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

Testing

Built v4 with arm64 GCC 15.2 and W=1 at both patch boundaries
for fs/jbd2/ and fs/ext4/, with CONFIG_UNICODE enabled.
Also built the complete series with CONFIG_UNICODE disabled
and CONFIG_FS_ENCRYPTION enabled.

A host-side control-flow test covered the failed-commit diagnostic
for callback and legacy callers, callback errors, and fast commit
replay ordering.

Ran v4 in an instrumented amd64 QEMU/KVM guest on 7.4.0-rc2-syz
(7475ea8b5), with both patches applied to that test tree.

- Recovery accepted valid descriptors after block replay. The callback
  rejected out-of-range free-cluster counts with an empty journal and
  when corruption persisted in a separate descriptor block after block
  replay.
- Recovery of an online resize grew the filesystem from 32 to 128
  groups, reloaded the descriptor table from one block to two, and
  completed a read-write mount.
- Read-write recovery with fast commit enabled reached the second
  callback and passed descriptor validation. Read-only recovery
  reached the first callback and mounted without errors or warnings.
- Recovery mounted an existing casefold filesystem. On the empty
  journal path, failed descriptor validation left the superblock
  unchanged.

Earlier v3 tests covered deferred EA inode eviction on successful
read-only fast commit recovery and on fast commit replay failure.

Application of fast commit tags and the read-only path through the
second callback remain unverified on v4. Replay of online feature
enablement and rejection of invalid replayed superblock settings,
including casefold settings, still need runtime coverage.

Link: https://lore.kernel.org/linux-ext4/20261102042428.65204-1-zhaogongyi@bytedance.com/
Link: https://lore.kernel.org/linux-ext4/20261119122601.85293-1-zhaogongyi@bytedance.com/
Link: https://lore.kernel.org/linux-ext4/sashiko-outbox-223131@kernel.org/
Link: https://lore.kernel.org/linux-ext4/20261120025459.70290-1-zhaogongyi@bytedance.com/
Link: https://sashiko.dev/#/patchset/20261120025459.70290-1-zhaogongyi@bytedance.com?part=2

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      | 452 +++++++++++++++++++++++++++++++++----------
 fs/jbd2/journal.c    |  33 +++-
 fs/jbd2/recovery.c   |  42 ++--
 include/linux/jbd2.h |   7 +-
 6 files changed, 425 insertions(+), 121 deletions(-)

base-commit: 4aa05e642bade8cf8405936b03cabf848fe6c456

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

* Re: [PATCH v4 0/2] ext4: reject impossible group free cluster counts
  2026-11-24  3:38 [PATCH v4 0/2] ext4: reject impossible group free cluster counts Zhao Gongyi
@ 2026-11-24  4:04 ` sashiko-bot
  2026-11-24 14:55 ` Theodore Tso
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-24  4:04 UTC (permalink / raw)
  To: Zhao Gongyi, linux-ext4; +Cc: tytso

Sashiko has finished reviewing this 2-patch series:

- Patch 1: no issues found.
- Patch 2 ("ext4: reject impossible group free cluster counts"): 2
  potential issues (2 Medium)

A detailed review has been sent as a separate reply to patch 2.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124033900.76700-1-zhaogongyi@bytedance.com

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

* Re: [PATCH v4 0/2] ext4: reject impossible group free cluster counts
  2026-11-24  3:38 [PATCH v4 0/2] ext4: reject impossible group free cluster counts Zhao Gongyi
  2026-11-24  4:04 ` sashiko-bot
@ 2026-11-24 14:55 ` Theodore Tso
  1 sibling, 0 replies; 3+ messages in thread
From: Theodore Tso @ 2026-11-24 14:55 UTC (permalink / raw)
  To: Zhao Gongyi
  Cc: linux-ext4, linux-kernel, adilger.kernel, libaokun, jack, ojaswin,
	ritesh.list, yi.zhang

On Tue, Nov 24, 2026 at 11:38:58AM -0500, Zhao Gongyi wrote:
> 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 and checks the descriptors again
> after fast commit replay. Both halves of the group free-cluster count
> are read under the group lock.

Note: in the future, could you send your patches so that each of the
patches are sent as a reply to the cover letter, so becomes easy to
find all of the patches associated with the patch series?  This makes
life much easier for patch reviews, and it also allows me to use the
"b4" command to gether up and apply all of the patches once the patch
review is complete.

The way I do that is to put in my ~/.gitconfig:

[sendemail]
	chainreplyto = no
	thread = yes

See the discussion of the --thread and --[no-]chain-reply-to options
in the man pages for git-send-mail and git-format-patch for more details.

Many thanks!

       	   	     		       - Ted

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

end of thread, other threads:[~2026-11-24 14:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  3:38 [PATCH v4 0/2] ext4: reject impossible group free cluster counts Zhao Gongyi
2026-11-24  4:04 ` sashiko-bot
2026-11-24 14:55 ` Theodore Tso

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