Skip to content

Commit 9fd6e31

Browse files
pvts-matPlaidCat
authored andcommitted
ext4: define ext4_journal_destroy wrapper
jira VULN-65358 cve-pre CVE-2025-22113 commit-author Ojaswin Mujoo <[email protected]> commit 5a02a62 Define an ext4 wrapper over jbd2_journal_destroy to make sure we have consistent behavior during journal destruction. This will also come useful in the next patch where we add some ext4 specific logic in the destroy path. Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Baokun Li <[email protected]> Signed-off-by: Ojaswin Mujoo <[email protected]> Link: https://patch.msgid.link/c3ba78c5c419757e6d5f2d8ebb4a8ce9d21da86a.1742279837.git.ojaswin@linux.ibm.com Signed-off-by: Theodore Ts'o <[email protected]> (cherry picked from commit 5a02a62) Signed-off-by: Marcin Wcisło <[email protected]>
1 parent 100c273 commit 9fd6e31

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

fs/ext4/ext4_jbd2.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,4 +513,18 @@ static inline int ext4_should_dioread_nolock(struct inode *inode)
513513
return 1;
514514
}
515515

516+
/*
517+
* Pass journal explicitly as it may not be cached in the sbi->s_journal in some
518+
* cases
519+
*/
520+
static inline int ext4_journal_destroy(struct ext4_sb_info *sbi, journal_t *journal)
521+
{
522+
int err = 0;
523+
524+
err = jbd2_journal_destroy(journal);
525+
sbi->s_journal = NULL;
526+
527+
return err;
528+
}
529+
516530
#endif /* _EXT4_JBD2_H */

fs/ext4/super.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,8 +1214,7 @@ static void ext4_put_super(struct super_block *sb)
12141214

12151215
if (sbi->s_journal) {
12161216
aborted = is_journal_aborted(sbi->s_journal);
1217-
err = jbd2_journal_destroy(sbi->s_journal);
1218-
sbi->s_journal = NULL;
1217+
err = ext4_journal_destroy(sbi, sbi->s_journal);
12191218
if ((err < 0) && !aborted) {
12201219
ext4_abort(sb, -err, "Couldn't clean up the journal");
12211220
}
@@ -4897,8 +4896,7 @@ static int ext4_load_and_init_journal(struct super_block *sb,
48974896
out:
48984897
/* flush s_sb_upd_work before destroying the journal. */
48994898
flush_work(&sbi->s_sb_upd_work);
4900-
jbd2_journal_destroy(sbi->s_journal);
4901-
sbi->s_journal = NULL;
4899+
ext4_journal_destroy(sbi, sbi->s_journal);
49024900
return -EINVAL;
49034901
}
49044902

@@ -5637,8 +5635,7 @@ failed_mount8: __maybe_unused
56375635
if (sbi->s_journal) {
56385636
/* flush s_sb_upd_work before journal destroy. */
56395637
flush_work(&sbi->s_sb_upd_work);
5640-
jbd2_journal_destroy(sbi->s_journal);
5641-
sbi->s_journal = NULL;
5638+
ext4_journal_destroy(sbi, sbi->s_journal);
56425639
}
56435640
failed_mount3a:
56445641
ext4_es_unregister_shrinker(sbi);
@@ -5917,7 +5914,7 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
59175914
return journal;
59185915

59195916
out_journal:
5920-
jbd2_journal_destroy(journal);
5917+
ext4_journal_destroy(EXT4_SB(sb), journal);
59215918
out_bdev:
59225919
blkdev_put(bdev, sb);
59235920
return NULL;
@@ -6034,8 +6031,7 @@ static int ext4_load_journal(struct super_block *sb,
60346031
EXT4_SB(sb)->s_journal = journal;
60356032
err = ext4_clear_journal_err(sb, es);
60366033
if (err) {
6037-
EXT4_SB(sb)->s_journal = NULL;
6038-
jbd2_journal_destroy(journal);
6034+
ext4_journal_destroy(EXT4_SB(sb), journal);
60396035
return err;
60406036
}
60416037

@@ -6053,7 +6049,7 @@ static int ext4_load_journal(struct super_block *sb,
60536049
return 0;
60546050

60556051
err_out:
6056-
jbd2_journal_destroy(journal);
6052+
ext4_journal_destroy(EXT4_SB(sb), journal);
60576053
return err;
60586054
}
60596055

0 commit comments

Comments
 (0)