Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp865042pxx; Tue, 27 Oct 2020 02:20:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9cnupSHcyGVnYL3//NHOWWNvubBLEIDpINb07pqu+pP5mY3zSkqlAEWP1PYGdXOaFfLsf X-Received: by 2002:a17:906:a149:: with SMTP id bu9mr1381873ejb.115.1603790419396; Tue, 27 Oct 2020 02:20:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603790419; cv=none; d=google.com; s=arc-20160816; b=qslP/DlBKQIjLutpi3O+iHvOcndxD6EYSjwT5UHHTV0fr/5s0VRMc1z0J3AIB/9ttk VXneDWQQnI8GRM0N90nDYOcTBcjTMpwDEaljMVITUqplNTk6UG9DV2U3El8BQkUaAIsv at/+cVnBhEiazemjh+Xht+ZmituFA1NiQkCPrjXHjYLFz4AHcgKOwCgf12cNkmLhDKGt eoYiflq9Lukv1I1Zp9yUXJVRbPrX7vQCgRirpbDEHh9V5gxMzCg6uIdz8klILUhPBIRx JzzpXbLjJ7IpEIZN1bwxLzbW1M2ccbb92u99K7NPwI/Ms0FfFhRCFrMPWeX3u3+SI5qp li8A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GRxzDmmQ1CeaUoh2OL0L4VG650WxkSxkmB4RYALkzIw=; b=xmoT1IUPHPsktsq0akW+mSwN0vl0iKFLbNo41tORxeUsn9A7PeweHKS9MdN6nPIOOJ 40CKeiWPRf9OlxxHsa2I6xbdajP6t8OLSslL8nXI+Wc1qUZN3krVA+j8MPtfer2NActc 9WrEQFFL8sDgMgky1kBFwZuGVfHs1Ou/b6vFKAyAZckQmOj1QuVRAqNORYZ7NG2ZU1Nx /Iicyn1dt+bz4kwss8haHKAOiuCwkXoVMtKlm8HOnmjPQk+PQM3hs2oWzIHejO224F50 nx1g/K9jEIV43pn26TyYcJ0a7Yh0QghDkoJqvfDxEZRXAqFrFTRpu7Fdr6KmPiIWrNP8 oJ0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w0vZLPrY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si565646ejd.450.2020.10.27.02.19.57; Tue, 27 Oct 2020 02:20:19 -0700 (PDT) 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=w0vZLPrY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408714AbgJZXt1 (ORCPT + 99 others); Mon, 26 Oct 2020 19:49:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:47164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408661AbgJZXtU (ORCPT ); Mon, 26 Oct 2020 19:49:20 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AD7A520773; Mon, 26 Oct 2020 23:49:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756159; bh=VdYd0jj9ZMGqyNWWvSiCMk9u7hXc40vpCtEkyfaY488=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w0vZLPrYMeUm/rQ5ySLyRr3RZWd+SsDyBMO1dXCRH0JY0oCSavCv9a/PcsvSKNcNJ 0m9+4/Q1tJyPgLXOE9YsZGXEP6Dn94kHEHWO1oyjucC1nnndeoGQBWgDRuvN2cQHLa kRNShqV5ACVIs1lFJj2mk+b+XxKzjcMPQO4eZcI4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chao Yu , syzbot+0eac6f0bbd558fd866d7@syzkaller.appspotmail.com, Jaegeuk Kim , Sasha Levin , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH AUTOSEL 5.9 011/147] f2fs: fix uninit-value in f2fs_lookup Date: Mon, 26 Oct 2020 19:46:49 -0400 Message-Id: <20201026234905.1022767-11-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 069f498af1e38..ceb4431b56690 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -357,16 +357,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)) { @@ -377,7 +376,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.25.1