Patch "ext4: update s_journal_inum if it changes after journal replay" has been added to the 6.2-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ext4: update s_journal_inum if it changes after journal replay

to the 6.2-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ext4-update-s_journal_inum-if-it-changes-after-journ.patch
and it can be found in the queue-6.2 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 76ef8fb8fe7fc30db41a92eaf30415462aeb6f67
Author: Baokun Li <libaokun1@xxxxxxxxxx>
Date:   Sat Jan 7 11:21:26 2023 +0800

    ext4: update s_journal_inum if it changes after journal replay
    
    [ Upstream commit 3039d8b8692408438a618fac2776b629852663c3 ]
    
    When mounting a crafted ext4 image, s_journal_inum may change after journal
    replay, which is obviously unreasonable because we have successfully loaded
    and replayed the journal through the old s_journal_inum. And the new
    s_journal_inum bypasses some of the checks in ext4_get_journal(), which
    may trigger a null pointer dereference problem. So if s_journal_inum
    changes after the journal replay, we ignore the change, and rewrite the
    current journal_inum to the superblock.
    
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=216541
    Reported-by: Luís Henriques <lhenriques@xxxxxxx>
    Signed-off-by: Baokun Li <libaokun1@xxxxxxxxxx>
    Reviewed-by: Jan Kara <jack@xxxxxxx>
    Link: https://lore.kernel.org/r/20230107032126.4165860-3-libaokun1@xxxxxxxxxx
    Signed-off-by: Theodore Ts'o <tytso@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index c81fa0fa9901a..e79ca9ef98316 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5967,8 +5967,11 @@ static int ext4_load_journal(struct super_block *sb,
 	if (!really_read_only && journal_devnum &&
 	    journal_devnum != le32_to_cpu(es->s_journal_dev)) {
 		es->s_journal_dev = cpu_to_le32(journal_devnum);
-
-		/* Make sure we flush the recovery flag to disk. */
+		ext4_commit_super(sb);
+	}
+	if (!really_read_only && journal_inum &&
+	    journal_inum != le32_to_cpu(es->s_journal_inum)) {
+		es->s_journal_inum = cpu_to_le32(journal_inum);
 		ext4_commit_super(sb);
 	}
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux