diff mbox series

memory leak in ext4_multi_mount_protect

Message ID d37a412f244eaa0f1352b394fdf933ce75d9968c.camel@gmail.com
State Superseded
Headers show
Series memory leak in ext4_multi_mount_protect | expand

Commit Message

Pavel Skripkin April 13, 2021, 1:11 p.m. UTC
Hi!

I've done debugging on this issue
https://syzkaller.appspot.com/bug?id=420258a304e5d92cfef6b0097f87b42506e1db08
and I want to ask you about 
proper way of fixing it. The problem was in case sbi->s_mmp_tsk hasn’t
started at the time of kthread_stop() call. In that case allocated data
won't be freed.

I wrote fix patch, but I am confused about it, because I didn't find
any kernel code like this. I don't think, that adding new members to
struct super_block is good idea, that's why I came to that decision: 

 	group_desc = rcu_dereference(sbi->s_group_desc);


I look forward to hearing your perspective on this patch :)

With regards,
Pavel Skripkin
diff mbox series

Patch

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b9693680463a..9c33e97bd5c5 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5156,8 +5156,10 @@  static int ext4_fill_super(struct super_block
*sb, void *data, int silent)
 failed_mount3:
 	flush_work(&sbi->s_error_work);
 	del_timer_sync(&sbi->s_err_report);
-	if (sbi->s_mmp_tsk)
-		kthread_stop(sbi->s_mmp_tsk);
+	if (sbi->s_mmp_tsk) {
+		if (kthread_stop(sbi->s_mmp_tsk) == -EINTR)
+			kfree(kthread_data(sbi->s_mmp_tsk));
+	}
 failed_mount2:
 	rcu_read_lock();