From patchwork Mon Oct 24 11:28:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp422568wru; Mon, 24 Oct 2022 05:22:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6a9R/j/LxoXs+VpwW4J3RFeSSh+YIxmvhW4B9lrCU0peFKdT2LYC8XEIUaVv7TvWfMpx4w X-Received: by 2002:a50:a44c:0:b0:45c:6451:363d with SMTP id v12-20020a50a44c000000b0045c6451363dmr30574686edb.115.1666614177436; Mon, 24 Oct 2022 05:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614177; cv=none; d=google.com; s=arc-20160816; b=fZZRh9Dye5W8l4QPAyYKFnIHe17KAFMrfGmLLq8lOUd82ggshsPy3NNssKxxqQ2fDh lCnGTyTMZnHMZ2lJ3hmXTL/Y1G523NEpteU+MWR5Fbfz7z3Pk9owZSdNeDs+qk7v0ndJ SUF1s0fxWPEREWagM6lqMFpXTf9RR/3kQsAgURwbiGt2vkQgTA19x2Zh8pXQk7SGgPu6 KY8Z6VHzK1dFa14+PRKurgjenzIFaYcefT69f8S71dhrDEGzEqW+MC57KRLx689zF1/v 3E5PyMgf7nAZPxwi5UXx5Q+ZOkIZOWhv72yVdHhUyvgckEgXKIKLLPek5VqwmSD3PghJ 6rVA== 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=rOBkAhKcePJSZfI0be+tPaBSsuf21vdCx3kTaKZI1w8=; b=iTEpyqgZoiG0WaJcMtDY5mexVpGb1NqIan5Jj76nSbeYwOEolfS/q7LiBTqNZl4U9E veSWu+vPEva3AWRDAwzzKf6LA23VrcobD9+y5PKlx9slwZwsToCNb0c2Qf/I8dqMI3tk 9yD/WNCCECJJs8+agcDO4B/n6+KcGxNZVnjS8DhnAHdG8vomtHc5ZEoAU4QFy+ygb1M1 bK8DCvwe2CGKoxHoV86XDc9oksojWuWaUV/zZDKHqp5TEUa1jnwJx0foGrDUUJeGia6V ZbPim+btipoEBLneisIKbQ6BXO+RFVBqBLxMOq5ksRczq86DMk65jvg0qX/LXh9F8WbZ fQVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=irx3rxgJ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg16-20020a170907971000b00782686da1d1si26661140ejc.761.2022.10.24.05.22.33; Mon, 24 Oct 2022 05:22:57 -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=irx3rxgJ; 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 S233404AbiJXMVe (ORCPT + 99 others); Mon, 24 Oct 2022 08:21:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233483AbiJXMTk (ORCPT ); Mon, 24 Oct 2022 08:19:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FE1282D14; Mon, 24 Oct 2022 04:58:02 -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 ED61F6129E; Mon, 24 Oct 2022 11:56:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08E1EC433C1; Mon, 24 Oct 2022 11:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612566; bh=F//YHv1bkUtABcaNo0CCRonpfHuEaxZGVHMrMkrR4lY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=irx3rxgJzsVnCmLHJ6evza4kILRLkyt+7bdDU/PUq2mozPOu39yDa97x+uOYvEa5A dEs1kNtYW+3KBRjSH+tg79A2feGobG+uLZRxM7UamsHJ6KsWr5AJzv1YcfPmld7npz xG3hedm6vN3d290U9UgcvzVSaFH7kCgyzhhk9QhE= 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.19 018/229] nilfs2: fix NULL pointer dereference at nilfs_bmap_lookup_at_level() Date: Mon, 24 Oct 2022 13:28:57 +0200 Message-Id: <20221024112959.727858779@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747571627583661694?= X-GMAIL-MSGID: =?utf-8?q?1747571627583661694?= 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 @@ -451,6 +451,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 */