| From stable+bounces-172471-greg=kroah.com@vger.kernel.org Fri Aug 22 19:03:15 2025 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Fri, 22 Aug 2025 13:01:24 -0400 |
| Subject: ext4: preserve SB_I_VERSION on remount |
| To: stable@vger.kernel.org |
| Cc: Baokun Li <libaokun1@huawei.com>, stable@kernel.org, Jan Kara <jack@suse.cz>, Theodore Ts'o <tytso@mit.edu>, Sasha Levin <sashal@kernel.org> |
| Message-ID: <20250822170124.1319222-1-sashal@kernel.org> |
| |
| From: Baokun Li <libaokun1@huawei.com> |
| |
| [ Upstream commit f2326fd14a224e4cccbab89e14c52279ff79b7ec ] |
| |
| 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 1ff20307393e ("ext4: unconditionally enable the |
| i_version counter") removing the fix from commit 960e0ab63b2e ("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: 1ff20307393e ("ext4: unconditionally enable the i_version counter") |
| Signed-off-by: Baokun Li <libaokun1@huawei.com> |
| Reviewed-by: Jan Kara <jack@suse.cz> |
| Link: https://patch.msgid.link/20250703073903.6952-2-libaokun@huaweicloud.com |
| Signed-off-by: Theodore Ts'o <tytso@mit.edu> |
| [ Adjust context ] |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| fs/ext4/super.c | 6 +++--- |
| 1 file changed, 3 insertions(+), 3 deletions(-) |
| |
| --- a/fs/ext4/super.c |
| +++ b/fs/ext4/super.c |
| @@ -1937,6 +1937,9 @@ int ext4_init_fs_context(struct fs_conte |
| fc->fs_private = ctx; |
| fc->ops = &ext4_context_ops; |
| |
| + /* i_version is always enabled now */ |
| + fc->sb_flags |= SB_I_VERSION; |
| + |
| return 0; |
| } |
| |
| @@ -5113,9 +5116,6 @@ static int __ext4_fill_super(struct fs_c |
| 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; |
| - |
| if (ext4_check_feature_compatibility(sb, es, silent)) |
| goto failed_mount; |
| |