Commit f2326fd1 authored by Baokun Li's avatar Baokun Li Committed by Theodore Ts'o
Browse files

ext4: preserve SB_I_VERSION on remount



IMA testing revealed that after an ext4 remount, file accesses triggered
full measurements even without modifications, instead of skipping as
expected when i_version is unchanged.

Debugging showed `SB_I_VERSION` was cleared in reconfigure_super() during
remount due to commit 1ff20307 ("ext4: unconditionally enable the
i_version counter") removing the fix from commit 960e0ab6 ("ext4: fix
i_version handling on remount").

To rectify this, `SB_I_VERSION` is always set for `fc->sb_flags` in
ext4_init_fs_context(), instead of `sb->s_flags` in __ext4_fill_super(),
ensuring it persists across all mounts.

Cc: stable@kernel.org
Fixes: 1ff20307 ("ext4: unconditionally enable the i_version counter")
Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20250703073903.6952-2-libaokun@huaweicloud.com


Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 6a912e8a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1998,6 +1998,9 @@ int ext4_init_fs_context(struct fs_context *fc)
	fc->fs_private = ctx;
	fc->ops = &ext4_context_ops;

	/* i_version is always enabled now */
	fc->sb_flags |= SB_I_VERSION;

	return 0;
}

@@ -5316,9 +5319,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
	sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
		(test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);

	/* i_version is always enabled now */
	sb->s_flags |= SB_I_VERSION;

	/* HSM events are allowed by default. */
	sb->s_iflags |= SB_I_ALLOW_HSM;