Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6744442rwi; Mon, 24 Oct 2022 05:41:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6D93+hM8ANwG8Os8eM+THfWmpRfdktK4rcH9BtD4pTgJMbB2L9I7Ph5iBKwaVzthbfexgD X-Received: by 2002:a17:906:ee8e:b0:730:3646:d178 with SMTP id wt14-20020a170906ee8e00b007303646d178mr27781831ejb.426.1666615286755; Mon, 24 Oct 2022 05:41:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615286; cv=none; d=google.com; s=arc-20160816; b=v7Lt4hlZh64GhvoKcACE8C2ykD62Fusi5SckJ4EIZ3OwanR1ZawMEtQ/nUjQQ8+W7J cOLLKbhxM7p4EL77Z/RiOPhVFVO318znh+1U+YKrK7Uxa4xnco8nfpiSLQMAGwFTCycF b54tNMQV76lIBETCiW3wRjjXM1cP+E2uZ+CYjAAcY6djOuuoCKM9zoHqr2/mF7FWV1p8 aR43aZaN+deY67tIE4tkAAo4ayO92RyI8gb0DJp0doKOVvnP8jJwChWlGri8WoFT1Pa0 QZPh233Q/GsEvFK34bs/tbjnhPgjIVfnc5zFAvxtxqn2IQWAuK/cOEFjzqVByWDDNRzi sSQw== 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=rxnKb43PVueR95OuJku2w86yxCaPJHaugoFRDHBApWM=; b=CFD59vrBlqHWKkGCxFvIxvEbXJ/JO2VwYrkiDKIUT15AVcZZ57jrq20gsY9NB/47A5 7LhGXsY2fMBtileSm1SAcbPMHeE0uqwOK03OAdpPz3DERG5PDs9CinarMs8A4xxk3EFD NytOed5eLAARsmcX/H6+V9XJWnyeLb4kCIPzQDVoraRd1ZccIpqwAtKT4gG52qEAZ4pK rtMzZn8BfN174SXYEDCemaDzvROp1unQg6KHs2kZWLGOlVVFqmMe/Ay6MxByfm7uzvhs ZGuoAPNIjf0WWMRpQGlD4EBomr45+uoKeX0uMbOIRaH6Jw973L/V6zNANDBAz9FBk0Y7 Z5Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ChASDfRQ; 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 c6-20020a05640227c600b00461e3e1a628si1613938ede.110.2022.10.24.05.41.02; Mon, 24 Oct 2022 05:41:26 -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=ChASDfRQ; 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 S231234AbiJXMB4 (ORCPT + 99 others); Mon, 24 Oct 2022 08:01:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232616AbiJXL7X (ORCPT ); Mon, 24 Oct 2022 07:59:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B86E7C333; Mon, 24 Oct 2022 04:48:33 -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 8ADBD61252; Mon, 24 Oct 2022 11:48:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C542C433D6; Mon, 24 Oct 2022 11:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612094; bh=5bSnUp5dX34XQ99c1SQZmiSSKHcGvqw4nlmJQKpbDSk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ChASDfRQ3cezodCy6I3Y1VplWqK6hy+HSvbBzRNC3YoXKMQQyjNhuXCNHTAAzUOF5 lWbawIDtpu1GL79xj+UPa8zmzNX2O7sY6/7NXloK1nTg/tgG4tYkrddsOaVQlhWo9m C1s+l/qsCthU1MUzNXhWVGPDJH7bg63o/qmsb+QE= 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 4.14 036/210] nilfs2: fix NULL pointer dereference at nilfs_bmap_lookup_at_level() Date: Mon, 24 Oct 2022 13:29:13 +0200 Message-Id: <20221024112958.154110294@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 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 @@ -455,6 +455,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 */