Skip to content

Commit 69e0099

Browse files
LiBaokun96smb49
authored andcommitted
ext4: update s_journal_inum if it changes after journal replay
BugLink: https://bugs.launchpad.net/bugs/2023225 [ Upstream commit 3039d8b ] 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@suse.de> Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20230107032126.4165860-3-libaokun1@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
1 parent d400506 commit 69e0099

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/ext4/super.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5385,8 +5385,11 @@ static int ext4_load_journal(struct super_block *sb,
53855385
if (!really_read_only && journal_devnum &&
53865386
journal_devnum != le32_to_cpu(es->s_journal_dev)) {
53875387
es->s_journal_dev = cpu_to_le32(journal_devnum);
5388-
5389-
/* Make sure we flush the recovery flag to disk. */
5388+
ext4_commit_super(sb);
5389+
}
5390+
if (!really_read_only && journal_inum &&
5391+
journal_inum != le32_to_cpu(es->s_journal_inum)) {
5392+
es->s_journal_inum = cpu_to_le32(journal_inum);
53905393
ext4_commit_super(sb);
53915394
}
53925395

0 commit comments

Comments
 (0)