Skip to content

Commit 5e47868

Browse files
riteshharjanitytso
authored andcommitted
ext4: unregister sysfs path before destroying jbd2 journal
Call ext4_unregister_sysfs(), before destroying jbd2 journal, since below might cause, NULL pointer dereference issue. This got reported with LTP tests. ext4_put_super() cat /sys/fs/ext4/loop2/journal_task | ext4_attr_show(); ext4_jbd2_journal_destroy(); | | journal_task_show() | | | task_pid_vnr(NULL); sbi->s_journal = NULL; Signed-off-by: Ritesh Harjani <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent f1eec3b commit 5e47868

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/ext4/super.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,13 @@ static void ext4_put_super(struct super_block *sb)
10241024

10251025
destroy_workqueue(sbi->rsv_conversion_wq);
10261026

1027+
/*
1028+
* Unregister sysfs before destroying jbd2 journal.
1029+
* Since we could still access attr_journal_task attribute via sysfs
1030+
* path which could have sbi->s_journal->j_task as NULL
1031+
*/
1032+
ext4_unregister_sysfs(sb);
1033+
10271034
if (sbi->s_journal) {
10281035
aborted = is_journal_aborted(sbi->s_journal);
10291036
err = jbd2_journal_destroy(sbi->s_journal);
@@ -1034,7 +1041,6 @@ static void ext4_put_super(struct super_block *sb)
10341041
}
10351042
}
10361043

1037-
ext4_unregister_sysfs(sb);
10381044
ext4_es_unregister_shrinker(sbi);
10391045
del_timer_sync(&sbi->s_err_report);
10401046
ext4_release_system_zone(sb);

0 commit comments

Comments
 (0)