From 6546b3032b014c8ea8f1d1ddabf4b2be666b1802 Mon Sep 17 00:00:00 2001 From: Ye Bin Date: Wed, 29 Mar 2023 11:19:44 +0800 Subject: [PATCH] ext4: make sure fs error flag setted before clear journal error mainline inclusion from mainline-v6.3-rc2 commit f57886ca1606ba74cc4ec4eb5cbf073934ffa559 category: bugfix bugzilla: 188471,https://gitee.com/openeuler/kernel/issues/I6MR1V CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f57886ca1606ba74cc4ec4eb5cbf073934ffa559 -------------------------------- Now, jounral error number maybe cleared even though ext4_commit_super() failed. This may lead to error flag miss, then fsck will miss to check file system deeply. Signed-off-by: Ye Bin Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/20230307061703.245965-3-yebin@huaweicloud.com Signed-off-by: Baokun Li Reviewed-by: Zhang Yi Reviewed-by: Yang Erkun Signed-off-by: Jialin Zhang --- fs/ext4/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 96792a06fd8d..ffac35e66bd9 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5778,11 +5778,13 @@ static int ext4_clear_journal_err(struct super_block *sb, errstr = ext4_decode_error(sb, j_errno, nbuf); ext4_warning(sb, "Filesystem error recorded " "from previous mount: %s", errstr); - ext4_warning(sb, "Marking fs in need of filesystem check."); EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; es->s_state |= cpu_to_le16(EXT4_ERROR_FS); - ext4_commit_super(sb); + j_errno = ext4_commit_super(sb); + if (j_errno) + return j_errno; + ext4_warning(sb, "Marked fs in need of filesystem check."); jbd2_journal_clear_err(journal); jbd2_journal_update_sb_errno(journal); -- GitLab