Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1309356rwi; Thu, 13 Oct 2022 11:50:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pf8YtLIJmF2Z7EW1REE7ySc5qaAmwgp4Rg3g0x+sqVbdyJkn2hgrTUUbHogheFttqprpH X-Received: by 2002:a17:903:41cf:b0:183:5a22:c63e with SMTP id u15-20020a17090341cf00b001835a22c63emr1027661ple.61.1665687015447; Thu, 13 Oct 2022 11:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665687015; cv=none; d=google.com; s=arc-20160816; b=YkF0WCDiX43LL7owbv/EtIjHI9SaEx77nPciBpCtQNLJjbWqjGqi5gPdT1D1ea1mLA O3umUKiN7xL0bL7/26XVOn0ihgZlVSg0yC/1cjD79tFUxB2+hXEgfcrz/AJN8xA5WrIs bs88Iyy+opN9+CY0FMQZ0CH9arEMn/JivEyOAS++i8Wx5WcU1bFN/qO7S+SWFikjXeNa FSMvKNw7HGgrYH5K7jiTWlu92RbvY+qf6UfXzZP6BZFGjdnG6bvjTm75P/AVZ6LB46F1 tjZHi6FKH0yLW6mEt9Eiv94YmxjAF1Qpi35aG1ou+d3ZZosnXuoKbZy3E0FxJTjc4cnK PyHg== 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=PbVqZCW8RRFFc/hhN/Qms5B4I9kutBtDuhHdmcX+6yo=; b=EMaqdPeb5cSs7cA2aghXN03hQ0MWeKDzaYxbkmeuIpmsHs0v46xXvGifgNzNeGJSla ZjfeYu5UuM4y0vC83aVZ/SYUSCKY77ro0VWZPbgNzJWEK3iqm44VI0dKwLjDN8foCaI9 z1G4lnnlxiv318/p1seUILQRd5NICIuTL1IC0VNiUzSIVc5vj5Tv7O5zsc82rhfYolJB j8l6BXTt5Uk0DUdfpjLhi9cFro0qYH7AcChGjTUzuCceWHooj2Zld7gOHFrD24r+7kO+ kX0jxndTt+vwZt5WGqdhwlVv7gBL04bpMtfy1XQJmr/R86WG+KwLd7jMahHiG61YqHMv fXJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sATihKiy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k9-20020a170902c40900b0017d2311af5dsi627454plk.69.2022.10.13.11.50.03; Thu, 13 Oct 2022 11:50:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sATihKiy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231354AbiJMSG3 (ORCPT + 99 others); Thu, 13 Oct 2022 14:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231418AbiJMSEV (ORCPT ); Thu, 13 Oct 2022 14:04:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA92915B323; Thu, 13 Oct 2022 11:04:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7DF6E61962; Thu, 13 Oct 2022 18:00:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00E80C433C1; Thu, 13 Oct 2022 18:00:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684047; bh=cUcTAyfiGD90tgpRNKHa/Zr0CnwqHXDM72pjPAcUCIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sATihKiy6LaoDCJTM0nAEMIux2MbymKHOSIks0ESIj+6ogW2aTrylONm8t8LJJl++ udKCJiSQNIwX7oMzqV9PuyuMBBFRjLoy501sUMD51ufK7xCjRCz4F0GzhL0yYMKgH4 87sDxOKX2Pspxysyr4VSbvGwrcDzb5CQkTQWOn8k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ryusuke Konishi , syzbot+2b32eb36c1a825b7a74c@syzkaller.appspotmail.com, Tetsuo Handa , Andrew Morton Subject: [PATCH 6.0 01/34] nilfs2: fix NULL pointer dereference at nilfs_bmap_lookup_at_level() Date: Thu, 13 Oct 2022 19:52:39 +0200 Message-Id: <20221013175146.547686275@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ryusuke Konishi commit 21a87d88c2253350e115029f14fe2a10a7e6c856 upstream. If the i_mode field in inode of metadata files is corrupted on disk, it can cause the initialization of bmap structure, which should have been called from nilfs_read_inode_common(), not to be called. This causes a lockdep warning followed by a NULL pointer dereference at nilfs_bmap_lookup_at_level(). This patch fixes these issues by adding a missing sanitiy check for the i_mode field of metadata file's inode. Link: https://lkml.kernel.org/r/20221002030804.29978-1-konishi.ryusuke@gmail.com Signed-off-by: Ryusuke Konishi Reported-by: syzbot+2b32eb36c1a825b7a74c@syzkaller.appspotmail.com Reported-by: Tetsuo Handa Tested-by: Ryusuke Konishi Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/nilfs2/inode.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -440,6 +440,8 @@ int nilfs_read_inode_common(struct inode inode->i_atime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec); inode->i_ctime.tv_nsec = le32_to_cpu(raw_inode->i_ctime_nsec); inode->i_mtime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec); + if (nilfs_is_metadata_file_inode(inode) && !S_ISREG(inode->i_mode)) + return -EIO; /* this inode is for metadata and corrupted */ if (inode->i_nlink == 0) return -ESTALE; /* this inode is deleted */