Skip to content

Commit 96e86d1

Browse files
committed
ext4: define ext4_journal_destroy wrapper
jira VULN-65357 cve-pre CVE-2025-22113 commit-author Ojaswin Mujoo <ojaswin@linux.ibm.com> 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 <jack@suse.cz> Reviewed-by: Baokun Li <libaokun1@huawei.com> Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> Link: https://patch.msgid.link/c3ba78c5c419757e6d5f2d8ebb4a8ce9d21da86a.1742279837.git.ojaswin@linux.ibm.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> (cherry picked from commit 5a02a62) Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>
1 parent 5b83fb9 commit 96e86d1

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
@@ -1209,8 +1209,7 @@ static void ext4_put_super(struct super_block *sb)
12091209

12101210
if (sbi->s_journal) {
12111211
aborted = is_journal_aborted(sbi->s_journal);
1212-
err = jbd2_journal_destroy(sbi->s_journal);
1213-
sbi->s_journal = NULL;
1212+
err = ext4_journal_destroy(sbi, sbi->s_journal);
12141213
if ((err < 0) && !aborted) {
12151214
ext4_abort(sb, -err, "Couldn't clean up the journal");
12161215
}
@@ -4894,8 +4893,7 @@ static int ext4_load_and_init_journal(struct super_block *sb,
48944893
out:
48954894
/* flush s_sb_upd_work before destroying the journal. */
48964895
flush_work(&sbi->s_sb_upd_work);
4897-
jbd2_journal_destroy(sbi->s_journal);
4898-
sbi->s_journal = NULL;
4896+
ext4_journal_destroy(sbi, sbi->s_journal);
48994897
return -EINVAL;
49004898
}
49014899

@@ -5603,8 +5601,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
56035601
if (sbi->s_journal) {
56045602
/* flush s_sb_upd_work before journal destroy. */
56055603
flush_work(&sbi->s_sb_upd_work);
5606-
jbd2_journal_destroy(sbi->s_journal);
5607-
sbi->s_journal = NULL;
5604+
ext4_journal_destroy(sbi, sbi->s_journal);
56085605
}
56095606
failed_mount3a:
56105607
ext4_es_unregister_shrinker(sbi);
@@ -5858,7 +5855,7 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
58585855
return journal;
58595856

58605857
out_journal:
5861-
jbd2_journal_destroy(journal);
5858+
ext4_journal_destroy(EXT4_SB(sb), journal);
58625859
out_bdev:
58635860
ext4_blkdev_put(bdev);
58645861
return NULL;
@@ -5958,8 +5955,7 @@ static int ext4_load_journal(struct super_block *sb,
59585955
EXT4_SB(sb)->s_journal = journal;
59595956
err = ext4_clear_journal_err(sb, es);
59605957
if (err) {
5961-
EXT4_SB(sb)->s_journal = NULL;
5962-
jbd2_journal_destroy(journal);
5958+
ext4_journal_destroy(EXT4_SB(sb), journal);
59635959
return err;
59645960
}
59655961

@@ -5974,7 +5970,7 @@ static int ext4_load_journal(struct super_block *sb,
59745970
return 0;
59755971

59765972
err_out:
5977-
jbd2_journal_destroy(journal);
5973+
ext4_journal_destroy(EXT4_SB(sb), journal);
59785974
return err;
59795975
}
59805976

0 commit comments

Comments
 (0)