Skip to content

Commit cf3196e

Browse files
xshen053gregkh
authored andcommitted
ext4: fix timer use-after-free on failed mount
commit 0ce160c5bdb67081a62293028dc85758a8efb22a upstream. Syzbot has found an ODEBUG bug in ext4_fill_super The del_timer_sync function cancels the s_err_report timer, which reminds about filesystem errors daily. We should guarantee the timer is no longer active before kfree(sbi). When filesystem mounting fails, the flow goes to failed_mount3, where an error occurs when ext4_stop_mmpd is called, causing a read I/O failure. This triggers the ext4_handle_error function that ultimately re-arms the timer, leaving the s_err_report timer active before kfree(sbi) is called. Fix the issue by canceling the s_err_report timer after calling ext4_stop_mmpd. Signed-off-by: Xiaxi Shen <[email protected]> Reported-and-tested-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=59e0101c430934bc9a36 Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected] Signed-off-by: Xiangyu Chen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e783161 commit cf3196e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ext4/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5617,8 +5617,8 @@ failed_mount9: __maybe_unused
56175617
failed_mount3:
56185618
/* flush s_error_work before sbi destroy */
56195619
flush_work(&sbi->s_error_work);
5620-
del_timer_sync(&sbi->s_err_report);
56215620
ext4_stop_mmpd(sbi);
5621+
del_timer_sync(&sbi->s_err_report);
56225622
ext4_group_desc_free(sbi);
56235623
failed_mount:
56245624
if (sbi->s_chksum_driver)

0 commit comments

Comments
 (0)