From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B16E367; Wed, 31 Aug 2022 04:34:32 +0000 (UTC) Received: by mail-pf1-f174.google.com with SMTP id y127so13339493pfy.5; Tue, 30 Aug 2022 21:34:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc; bh=2wlBh69S5T/T9iHDDZDeIpM5ED2QS1+ze35Ex3GUlR0=; b=5ECHLoyEAUJXjnouGIezSxk7WoWGkcx8ho28HbmRMgwKZNv680ARHHGnsDFDAEj7YE nDKafMEKdbqIzJ7R66aqfaMKyfevERji8DHMaXsgO4Y19hm2FhUnNDkafrbnk4VzfNuG PTtdvDnxgvujya3iu78bGFQztfz/RxGUoJVJ0rAf2qhb3Ilj+Vk8YALEjbyg+Obf7z78 +Xbry93oTJAq1n0T5XqelANTSxQ7xuIuTiHGXzOQknrbI9r/KWrPgNXOzGFr25+zD52L hoyyj3l4TlBiHpk45tq0h3RgauVEfDxceky5y4uoxpn3YWnpJF49U679h8F7lUg1EOkN 4KLA== X-Gm-Message-State: ACgBeo0bFetPaa1Mf429H6+9jgYFYfO20y/3BU5xstpxUMO4rRbVacED IVaLRf/DPn6lfFqUbQmaZww= X-Google-Smtp-Source: AA6agR4aRTLQgVsfv0pPYxAQbQfzQbA1lqOd5fp6MfoDJ0xxr78O1KzjwNP50pFkW8SiSA/HlkkMhA== X-Received: by 2002:a63:8a44:0:b0:42b:351d:e309 with SMTP id y65-20020a638a44000000b0042b351de309mr20133305pgd.426.1661920471855; Tue, 30 Aug 2022 21:34:31 -0700 (PDT) Received: from karthik-strix-linux.karthek.com ([117.241.13.19]) by smtp.gmail.com with ESMTPSA id q16-20020a63e950000000b0041d6d37deb5sm107851pgj.81.2022.08.30.21.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 21:34:31 -0700 (PDT) Date: Wed, 31 Aug 2022 10:04:25 +0530 From: Karthik Alapati To: Konstantin Komarov , Nathan Chancellor , Nick Desaulniers , Tom Rix Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] fs/ntfs3: fix memory leak in put_ntfs() Message-ID: Precedence: bulk X-Mailing-List: ntfs3@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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: [] kmalloc include/linux/slab.h:600 [inline] [] kzalloc include/linux/slab.h:733 [inline] [] ntfs_init_fs_context+0x22/0x1e0 fs/ntfs3/super.c:1397 [] alloc_fs_context+0x225/0x3b0 fs/fs_context.c:290 [] do_new_mount fs/namespace.c:3025 [inline] [] path_mount+0x6f3/0x10d0 fs/namespace.c:3370 [] do_mount fs/namespace.c:3383 [inline] [] __do_sys_mount fs/namespace.c:3591 [inline] [] __se_sys_mount fs/namespace.c:3568 [inline] [] __x64_sys_mount+0x18e/0x1d0 fs/namespace.c:3568 [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] [] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 [] 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: [] kmemdup_nul+0x2d/0x70 mm/util.c:152 [] vfs_parse_fs_string+0x6e/0xd0 fs/fs_context.c:178 [] generic_parse_monolithic+0xe0/0x130 fs/fs_context.c:224 [] do_new_mount fs/namespace.c:3036 [inline] [] path_mount+0xb94/0x10d0 fs/namespace.c:3370 [] do_mount fs/namespace.c:3383 [inline] [] __do_sys_mount fs/namespace.c:3591 [inline] [] __se_sys_mount fs/namespace.c:3568 [inline] [] __x64_sys_mount+0x18e/0x1d0 fs/namespace.c:3568 [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] [] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 [] entry_SYSCALL_64_after_hwframe+0x63/0xcd Link: https://syzkaller.appspot.com/bug?id=332ba47915d0e39e94b42a622f195f0804ecb67f Reported-by: syzbot+9d67170b20e8f94351c8@syzkaller.appspotmail.com Signed-off-by: Karthik Alapati --- 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