[PATCH] fs/ntfs3: fix memory leak in put_ntfs()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



free options in put_ntfs() rather than in ntfs_put_super()

BUG: memory leak
unreferenced object 0xffff8881104f3720 (size 32):
  comm "syz-executor634", pid 3605, jiffies 4294945517 (age 12.630s)
  hex dump (first 32 bytes):
    e0 36 4f 10 81 88 ff ff 80 57 e1 85 ff ff ff ff  .6O......W......
    00 00 00 00 00 00 00 00 c0 ff c0 ff 00 00 00 00  ................
  backtrace:
    [<ffffffff81b23ef2>] kmalloc include/linux/slab.h:600 [inline]
    [<ffffffff81b23ef2>] kzalloc include/linux/slab.h:733 [inline]
    [<ffffffff81b23ef2>] ntfs_init_fs_context+0x22/0x1e0 fs/ntfs3/super.c:1397
    [<ffffffff81650045>] alloc_fs_context+0x225/0x3b0 fs/fs_context.c:290
    [<ffffffff8162bed3>] do_new_mount fs/namespace.c:3025 [inline]
    [<ffffffff8162bed3>] path_mount+0x6f3/0x10d0 fs/namespace.c:3370
    [<ffffffff8162cffe>] do_mount fs/namespace.c:3383 [inline]
    [<ffffffff8162cffe>] __do_sys_mount fs/namespace.c:3591 [inline]
    [<ffffffff8162cffe>] __se_sys_mount fs/namespace.c:3568 [inline]
    [<ffffffff8162cffe>] __x64_sys_mount+0x18e/0x1d0 fs/namespace.c:3568
    [<ffffffff845e4855>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [<ffffffff845e4855>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [<ffffffff84800087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd

BUG: memory leak
unreferenced object 0xffff8881104f36e0 (size 32):
  comm "syz-executor634", pid 3605, jiffies 4294945517 (age 12.630s)
  hex dump (first 32 bytes):
    6d 61 63 63 79 72 69 6c 6c 69 63 00 00 00 00 00  maccyrillic.....
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff814c5b1d>] kmemdup_nul+0x2d/0x70 mm/util.c:152
    [<ffffffff8164f66e>] vfs_parse_fs_string+0x6e/0xd0 fs/fs_context.c:178
    [<ffffffff8164f7b0>] generic_parse_monolithic+0xe0/0x130 fs/fs_context.c:224
    [<ffffffff8162c374>] do_new_mount fs/namespace.c:3036 [inline]
    [<ffffffff8162c374>] path_mount+0xb94/0x10d0 fs/namespace.c:3370
    [<ffffffff8162cffe>] do_mount fs/namespace.c:3383 [inline]
    [<ffffffff8162cffe>] __do_sys_mount fs/namespace.c:3591 [inline]
    [<ffffffff8162cffe>] __se_sys_mount fs/namespace.c:3568 [inline]
    [<ffffffff8162cffe>] __x64_sys_mount+0x18e/0x1d0 fs/namespace.c:3568
    [<ffffffff845e4855>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [<ffffffff845e4855>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [<ffffffff84800087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd

Link: https://syzkaller.appspot.com/bug?id=332ba47915d0e39e94b42a622f195f0804ecb67f
Reported-by: syzbot+9d67170b20e8f94351c8@xxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Karthik Alapati <mail@xxxxxxxxxxx>
---
 fs/ntfs3/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 47012c9bf505..ffb76a5bfd4f 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -439,6 +439,7 @@ static void init_once(void *foo)
  */
 static noinline void put_ntfs(struct ntfs_sb_info *sbi)
 {
+	put_mount_options(sbi->options);
 	kfree(sbi->new_rec);
 	kvfree(ntfs_put_shared(sbi->upcase));
 	kfree(sbi->def_table);
@@ -482,7 +483,6 @@ static void ntfs_put_super(struct super_block *sb)
 	/* Mark rw ntfs as clear, if possible. */
 	ntfs_set_state(sbi, NTFS_DIRTY_CLEAR);
 
-	put_mount_options(sbi->options);
 	put_ntfs(sbi);
 	sb->s_fs_info = NULL;
 
-- 
2.37.2





[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux