From: sashiko-bot@kernel.org
To: "Zhao Gongyi" <zhaogongyi@bytedance.com>, linux-ext4@vger.kernel.org
Cc: tytso@mit.edu
Subject: Re: [PATCH v4 2/2] ext4: reject impossible group free cluster counts
Date: Tue, 24 Nov 2026 04:04:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-230493@kernel.org> (raw)
In-Reply-To: <20261124033900.76700-3-zhaogongyi@bytedance.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ext4: sbi->s_want_extra_isize not updated in
ext4_validate_replayed_metadata()
- [Medium] ext4: missing quota, hash, MMP, and ext3 checks in
ext4_validate_replayed_metadata()
--
commit 7e275abcaa17312423929e9a2ecee6c5701d57a7
Author: Zhao Gongyi <zhaogongyi@bytedance.com>
ext4: reject impossible group free cluster counts
This commit rejects block group descriptors whose free cluster count exceeds
the group's capacity, and adds a JBD2 recovery callback to revalidate
superblock fields and group descriptors after journal and fast commit replay.
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 359f9d4ed4479..68bd932608bc9 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
[ ... ]
> @@ -4939,88 +4990,254 @@ static int ext4_check_geometry(struct super_block *sb,
[ ... ]
> + /*
> + * These settings have already affected mount setup. Online tuning
> + * can enable some features, but cannot remove them.
> + */
> + if (es->s_creator_os != old->s_creator_os ||
> + (incompat & EXT4_FEATURE_INCOMPAT_INLINE_DATA) ||
> + (ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ||
> + (ro_compat & le32_to_cpu(old->s_feature_ro_compat) &
> + EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE) ||
> + (incompat & old_incompat & (EXT4_FEATURE_INCOMPAT_EA_INODE |
> + EXT4_FEATURE_INCOMPAT_CSUM_SEED |
> + EXT4_FEATURE_INCOMPAT_ENCRYPT |
> + EXT4_FEATURE_INCOMPAT_CASEFOLD)) ||
> + (test_opt2(sb, HURD_COMPAT) && ext4_has_feature_ea_inode(sb))) {
> + ext4_msg(sb, KERN_ERR, "incompatible mount settings after journal replay");
> + return -EFSCORRUPTED;
> + }
> +
> + err = ext4_check_extra_isize(sb, es);
> + if (err)
> + return err;
> + if (es->s_min_extra_isize != old->s_min_extra_isize ||
> + es->s_want_extra_isize != old->s_want_extra_isize) {
> + ext4_msg(sb, KERN_ERR, "extra inode size settings changed during journal replay");
> + return -EFSCORRUPTED;
> + }
[Severity: Medium]
Should ext4_validate_replayed_metadata() also update sbi->s_want_extra_isize
when journal replay enables EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE?
Before replay, ext4_inode_info_init() only applies es->s_want_extra_isize and
es->s_min_extra_isize to sbi->s_want_extra_isize if
ext4_has_feature_extra_isize(sb) is already set. If the unreplayed
superblock had s_want_extra_isize or s_min_extra_isize greater than
sizeof(struct ext4_inode) - EXT4_GOOD_OLD_INODE_SIZE (32 bytes) with
EXTRA_ISIZE cleared, and replay sets EXTRA_ISIZE, ext4_check_extra_isize()
succeeds while sbi->s_want_extra_isize stays at 32 bytes, below
s_min_extra_isize.
[ ... ]
> + if (!ext4_feature_set_ok(sb, replay->readonly))
> + return -EINVAL;
[Severity: Medium]
Does ext4_validate_replayed_metadata() also need to revalidate quota,
directory hash, MMP, and ext2/ext3 feature settings that were consumed before
journal replay?
Before ext4_load_and_init_journal(), __ext4_fill_super() configures
sb->s_qcop and sbi->s_qf_names[] from EXT4_FEATURE_RO_COMPAT_QUOTA and
validates EXT4_MOUNT_PRJQUOTA against EXT4_FEATURE_RO_COMPAT_PROJECT; if
replay toggles QUOTA or clears PROJECT, sb->s_qcop and the mount quota flags
are left inconsistent with ext4_enable_quotas() and ext4_orphan_cleanup().
Similarly, ext4_hash_info_init() initializes sbi->s_def_hash_version,
sbi->s_hash_seed, and sbi->s_hash_unsigned from es before replay (which
online tuning of DIR_INDEX or s_def_hash_version can change),
ext4_multi_mount_protect() checks EXT4_FEATURE_INCOMPAT_MMP and
es->s_mmp_block before replay, and ext4_check_feature_compatibility()
enforces ext2_feature_set_ok() / ext3_feature_set_ok() when IS_EXT2_SB(sb)
or IS_EXT3_SB(sb) is true.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124033900.76700-1-zhaogongyi@bytedance.com?part=2
prev parent reply other threads:[~2026-11-24 4:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 3:39 [PATCH v4 2/2] ext4: reject impossible group free cluster counts Zhao Gongyi
2026-11-24 4:04 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-230493@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
--cc=zhaogongyi@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.