Linux-ext4 Archive on
 help / color / Atom feed
* memory leak in ext4_multi_mount_protect
@ 2021-04-13 13:11 Pavel Skripkin
  0 siblings, 0 replies; 2+ messages in thread
From: Pavel Skripkin @ 2021-04-13 13:11 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: linux-ext4, kernel list


I've done debugging on this issue
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: 

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)
-	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));
+	}
 	group_desc = rcu_dereference(sbi->s_group_desc);

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

With regards,
Pavel Skripkin

^ permalink raw reply	[flat|nested] 2+ messages in thread

* memory leak in ext4_multi_mount_protect
@ 2020-12-24  9:55 syzbot
  0 siblings, 0 replies; 2+ messages in thread
From: syzbot @ 2020-12-24  9:55 UTC (permalink / raw)
  To: adilger.kernel, linux-ext4, linux-kernel, syzkaller-bugs, tytso


syzbot found the following issue on:

HEAD commit:    467f8165 Merge tag 'close-range-cloexec-unshare-v5.11' of ..
git tree:       upstream
console output:
kernel config:
dashboard link:
compiler:       gcc (GCC) 10.1.0-syz 20200507
syz repro:

IMPORTANT: if you fix the issue, please add the following tag to the commit:

BUG: memory leak
unreferenced object 0xffff88812560f120 (size 32):
  comm "syz-executor.3", pid 11391, jiffies 4294966956 (age 10.520s)
  hex dump (first 32 bytes):
    28 2a e4 20 81 88 ff ff 00 f8 32 24 81 88 ff ff  (*. ......2$....
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    [<000000001fd6256c>] kmalloc include/linux/slab.h:552 [inline]
    [<000000001fd6256c>] ext4_multi_mount_protect+0x4a6/0x5d0 fs/ext4/mmp.c:367
    [<00000000ab3084f2>] ext4_fill_super+0x551e/0x5ac0 fs/ext4/super.c:4779
    [<00000000b7304a28>] mount_bdev+0x223/0x260 fs/super.c:1366
    [<00000000b580b323>] legacy_get_tree+0x2b/0x90 fs/fs_context.c:592
    [<000000005310f7d7>] vfs_get_tree+0x28/0x100 fs/super.c:1496
    [<000000006fc429ab>] do_new_mount fs/namespace.c:2875 [inline]
    [<000000006fc429ab>] path_mount+0xc5e/0x1170 fs/namespace.c:3205
    [<000000004f8c23d3>] do_mount fs/namespace.c:3218 [inline]
    [<000000004f8c23d3>] __do_sys_mount fs/namespace.c:3426 [inline]
    [<000000004f8c23d3>] __se_sys_mount fs/namespace.c:3403 [inline]
    [<000000004f8c23d3>] __x64_sys_mount+0x18e/0x1d0 fs/namespace.c:3403
    [<000000002cff8f95>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
    [<00000000779cd3d5>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

This report is generated by a bot. It may contain errors.
See for more information about syzbot.
syzbot engineers can be reached at

syzbot will keep track of this issue. See: for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 13:11 memory leak in ext4_multi_mount_protect Pavel Skripkin
  -- strict thread matches above, loose matches on Subject: below --
2020-12-24  9:55 syzbot

Linux-ext4 Archive on

Archives are clonable:
	git clone --mirror linux-ext4/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-ext4 linux-ext4/ \
	public-inbox-index linux-ext4

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone