Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp831675pxb; Tue, 3 Nov 2020 13:49:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyuRH8+C+u7GEqpZFasb/t8teWnayRG0uheKHsXp1NCnPl1IUhqCJYNCO4EGkDm6+cB2HHN X-Received: by 2002:a50:decd:: with SMTP id d13mr24241267edl.202.1604440162987; Tue, 03 Nov 2020 13:49:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604440162; cv=none; d=google.com; s=arc-20160816; b=coJTxoYWp5eVX3lmyBxYV2ptGknJEEiZ8+aFGXaX2HcgXBShVpUatLE8C2u1R7L7CH RnvuKVGbN3nWUK1MfSR7CHo71UBISzg21CwVrfUpzZYpoz0yDdC08K4qlSfDttRM9ZIc JXd8v35gZ9g52JcDjDlp3cQE6vymSeASiesBJpDils1OuoNNmNQynyKKxTWhqnWWBXWr Jn5/1y1iIJtYL7QyYxB3Wodv1zDZZTFLbVlleB333BWdNa2ADDYdTtciGjTwQADFXRWZ PcDv+bo04Od/sy8R8jKAV/50AeH2bwhwpvjcGX0sOxAhl0hR8dEUK4gEZXLK8YIhhvSw u6yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1ujoJ2lekfbE1BVbaoF6mT5JO4AlAvvENPv68em3HE8=; b=k0HRieQKRAxzK/iwq7vTr/CZwkrRusjwxC3xX9A8+ZITH9fd2qz5aXGI8ga4SIPe5A Xwm/Kvwc6CAtk85i0QNnFMqwIwctvWzZJXNSa2WExP2i7IJSh582OQ9e0WZA0Z/uzpVz LcIR3JVBv3Kbt8Mh6j4eAubLoBrGC6h6w1sJ0mM1TQBxPCc22ZO7uiFZCHcaoiKqq1ae s2qYQeRxcBJQSXgu/CtV4/vM9ErGmunyuBnircsxDl9KOMN9pYA2x3qUzBrnjc3JEq8O befy97g2B+r7L2eXtxGcrHu8RY+LdFumzN7FUNVYE4LmobPq9L/pWAx7GEsjnB3d0Mnh 8RwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="re/RrvKD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm7si83031ejb.166.2020.11.03.13.49.00; Tue, 03 Nov 2020 13:49:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="re/RrvKD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731766AbgKCUxp (ORCPT + 99 others); Tue, 3 Nov 2020 15:53:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:52022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732432AbgKCUxn (ORCPT ); Tue, 3 Nov 2020 15:53:43 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A516A2053B; Tue, 3 Nov 2020 20:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436823; bh=aV0qCIPO+iS/XjCmfg4PGIsNk4ENNrlKeymShUIKL4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=re/RrvKD7g2yqnESo8ckhuVcnXCVmIs57I22YZNp0tstipH8t4zWvfNRKwIhHBG19 /Qlbet9FQfT9cK7d/pFDNJfeIq0eQ5o/xXI4bcpBtZtrplzriL1N/th9etE0v1+jmb uDcjuxxKr52OJ/Znni5Jo/h7yFRFKdmd7LHI4MiQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+0eac6f0bbd558fd866d7@syzkaller.appspotmail.com, Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.4 026/214] f2fs: fix uninit-value in f2fs_lookup Date: Tue, 3 Nov 2020 21:34:34 +0100 Message-Id: <20201103203252.490705866@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu [ Upstream commit 6d7ab88a98c1b7a47c228f8ffb4f44d631eaf284 ] As syzbot reported: Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x21c/0x280 lib/dump_stack.c:118 kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:122 __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:219 f2fs_lookup+0xe05/0x1a80 fs/f2fs/namei.c:503 lookup_open fs/namei.c:3082 [inline] open_last_lookups fs/namei.c:3177 [inline] path_openat+0x2729/0x6a90 fs/namei.c:3365 do_filp_open+0x2b8/0x710 fs/namei.c:3395 do_sys_openat2+0xa88/0x1140 fs/open.c:1168 do_sys_open fs/open.c:1184 [inline] __do_compat_sys_openat fs/open.c:1242 [inline] __se_compat_sys_openat+0x2a4/0x310 fs/open.c:1240 __ia32_compat_sys_openat+0x56/0x70 fs/open.c:1240 do_syscall_32_irqs_on arch/x86/entry/common.c:80 [inline] __do_fast_syscall_32+0x129/0x180 arch/x86/entry/common.c:139 do_fast_syscall_32+0x6a/0xc0 arch/x86/entry/common.c:162 do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:205 entry_SYSENTER_compat_after_hwframe+0x4d/0x5c In f2fs_lookup(), @res_page could be used before being initialized, because in __f2fs_find_entry(), once F2FS_I(dir)->i_current_depth was been fuzzed to zero, then @res_page will never be initialized, causing this kmsan warning, relocating @res_page initialization place to fix this bug. Reported-by: syzbot+0eac6f0bbd558fd866d7@syzkaller.appspotmail.com Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/dir.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index e9af46dc06f72..78d041f9775a4 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -303,16 +303,15 @@ struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, unsigned int max_depth; unsigned int level; + *res_page = NULL; + if (f2fs_has_inline_dentry(dir)) { - *res_page = NULL; de = f2fs_find_in_inline_dir(dir, fname, res_page); goto out; } - if (npages == 0) { - *res_page = NULL; + if (npages == 0) goto out; - } max_depth = F2FS_I(dir)->i_current_depth; if (unlikely(max_depth > MAX_DIR_HASH_DEPTH)) { @@ -323,7 +322,6 @@ struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, } for (level = 0; level < max_depth; level++) { - *res_page = NULL; de = find_in_level(dir, level, fname, res_page); if (de || IS_ERR(*res_page)) break; -- 2.27.0