Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1383948rwi; Thu, 13 Oct 2022 12:56:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5XReecARgBaUISjAzXQ4xiQCSJ67OuYl729xIwBu2Cc0W3fixLrv2Kum2OfXbOHz3epKbd X-Received: by 2002:a17:907:b07:b0:78d:ce2b:1999 with SMTP id h7-20020a1709070b0700b0078dce2b1999mr1038344ejl.267.1665690981364; Thu, 13 Oct 2022 12:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665690981; cv=none; d=google.com; s=arc-20160816; b=hN1mcHWPERdsWPfD7jkvkLtCFdMbgDrXPtVtvXAwA2VWulzZtgdGNa5LZmYxZbtRrT sk5GZpzlSp+1MC+Jk5YKk8MQr7pgWBBarYlRGCgwdYtXLs2VfSNVWLKHChzfpE2GoQNy ZaGz2l6piGY7eU642N5i6AEJ8FvEZzijXZ9zTYXWvtRm1Y/3LmXc4AceDmCeetUrCwQN xdB9AHmKfhx2zFpSdbgH/8QZeLtrtRWG4Izwop2GlgowXhp1a0t1HzZ7jko+vHgtSwps YaS8lnb8XXA7uR1ZZDedKGX3RR7ij9U2n+GumYdRRIcucURJijN7Fd+pp4DycGili7bz R2lw== 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=lWdkHADEAWRagmndVw21PRmH2Y3CiYPP5FG0jNmonY0=; b=I6q1wAlmXAY/tjiyMPd1+oMrMkWpDyiZbqfI/j0TCkP7DEep9vYTlAP3MCzpWADJ/r 2rxU1HOb75GABg3CTRmaVc45PuRTz0bQ0kn+97mkMCOlZurdfW+YVNPsE0sjhT45utHN DLIUz3Lztw45u5x6nxmnB4PCkO5e/ydjqI2XhvT+hkkJFvrubFXCPKquUZW/yO/uoFob FGfa7gkgI1X3xjUuIuIUJ82p+zr6fIXLb9bpAwKFlkAZlGNycFSSf++MXDsI7lgoOW4E kya4/AyxW9gQOg5FSNJSvkopBCyzMGWqxR33hNcpWoXeC7NsSEaI017e9ao9koX8B0K0 RhBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RGE4OGid; 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 hz5-20020a1709072ce500b0078ca4d67cf9si532451ejc.294.2022.10.13.12.55.52; Thu, 13 Oct 2022 12:56:21 -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=RGE4OGid; 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 S229757AbiJMTgL (ORCPT + 99 others); Thu, 13 Oct 2022 15:36:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbiJMTgH (ORCPT ); Thu, 13 Oct 2022 15:36:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADC1216C208; Thu, 13 Oct 2022 12:35:59 -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 ams.source.kernel.org (Postfix) with ESMTPS id 95E07B82024; Thu, 13 Oct 2022 17:58:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9D7EC433C1; Thu, 13 Oct 2022 17:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683931; bh=LqRQGRhWyZ0+e1yG6TSGRqdcEv6T4Hu9NwRgAch/cPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RGE4OGidX1rKphXFIs9hdL7NVxCsX1kq4EXpY4gk96WMWfniH/PPre/zW+EgZ8ef0 BYEHwEIDXq8DNioEvk7n+FFgHw2mp7cFtw5RSvWrhkc1EE7Cs0JiMks1DbLhZFh4vf xPgqGDAQjZTZ1HsUq0ximlam5tr+fezlfDIew1z4= 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 5.15 01/27] nilfs2: fix NULL pointer dereference at nilfs_bmap_lookup_at_level() Date: Thu, 13 Oct 2022 19:52:30 +0200 Message-Id: <20221013175143.569904170@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@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,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 @@ -444,6 +444,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 */