memory leak in ext4_multi_mount_protect
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:
fs/ext4/super.c +0 -0
@@ -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();
group_desc = rcu_dereference(sbi->s_group_desc);
I look forward to hearing your perspective on this patch :)
With regards,
Pavel Skripkin