Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1278777rwb; Sat, 1 Oct 2022 20:24:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM659qDKm8xqQB461sIueTFr5Uz62yj/TsWXjF726lPZ5UnXtqmFEP7WJ4/MuO1IB7CzaV7R X-Received: by 2002:a63:f010:0:b0:446:13df:7018 with SMTP id k16-20020a63f010000000b0044613df7018mr4684675pgh.546.1664681049954; Sat, 01 Oct 2022 20:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664681049; cv=none; d=google.com; s=arc-20160816; b=IgJUs0pUatt5CxeUfnNriBIKX8Itmc3r9+ddfQHppwqokB/f/CoUM+HSP31WR7g3OS QLBmHkrIzqRQms/ppawasjmcEbZOCF8xUmcTesKcYbbE36iiIZaDdvSVioZMQfQpvoKr BJdPlT3iE1ervRyLG7PehMp0qJlg77miO5M+FzwrE6dYdA4BEzVA6syZUdhA8cXAwklA pvgs9K4F6bIxwkoh954wxCBTyIt3wv3nXaRSnoId4HWv5oE862w/phTxM3be1EBFXkIN ntvYNmr0zoTpBjVPNulqPs1hTj3n0epI5eJzlhtXTbkL1irM1WnHR6x6pT8A5+k+3n25 sQ+A== 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=H94AYH5YtHBkal/GiFTQVCFtPlhU2OjgiQ2dQ8FUTFw=; b=lgM74cbzah0imDzZxuP3oQ9ATouwiFVTved9nYUEenQj0ZzIXzD33VXMVbLd7G2CJV g1oS+jkLtvoEPJgeWr+XzKbLHVK23UjdIg5G/4QTpzD/RKFeli8yHVd6773HxVRzhi6N 1dVhmYp/FUefHO7jvK5HZKjwT4MybthM4mEbxqXF8Ekq9gdeaZcuDxx6km/+N0xEUyos nK934dh+xw/ho96VGVXXWyEHiceBo8veTy5hIl+1qKwTElIYcpBUrLaRD5sid4LDcJ0H mRM1V+XngMg0no03mj1zM0KMBO1rWcst7/KSPKcrwepgQ8sUXgpbU6f13FcHygjFVrve 0fCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qgbNytB8; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l1-20020a17090a850100b001f0311d12d0si12820114pjn.185.2022.10.01.20.23.56; Sat, 01 Oct 2022 20:24:09 -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=@gmail.com header.s=20210112 header.b=qgbNytB8; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229453AbiJBDIO (ORCPT + 99 others); Sat, 1 Oct 2022 23:08:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiJBDIK (ORCPT ); Sat, 1 Oct 2022 23:08:10 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6F4F2BE1C; Sat, 1 Oct 2022 20:08:09 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id i6so7501931pfb.2; Sat, 01 Oct 2022 20:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=H94AYH5YtHBkal/GiFTQVCFtPlhU2OjgiQ2dQ8FUTFw=; b=qgbNytB8z5Bj8JoQzwz8kS+Ikv4oEd/VUDI9jP8UhJGyS0e/YhY63cwuhgqUnwSOCa 5HIxK4LRq9UCO4rUodculT+kZBKOZMfQ7ly+s7k6B2igC9vQ4svXAOZE8kh8n2a0xeI0 //YeLO0OXjJAAqOoDkqneYmp30k7B+PACZ/WohdrOwT0Y3bL89DomMz5gMM1Ri4lGV1j xEFhSYS43RY1ueVJK5THxT3mwmMSMzII2gJRb4i9MazyXnwUqJFvhSeK2cD9a8ebN6f6 dBbgTkDPtGqko9cck0EYgH4m5IeqiGUbuwVPQ/UdW5K2kQlyWLuIBtJdg4W/4nQsAwz0 7keQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=H94AYH5YtHBkal/GiFTQVCFtPlhU2OjgiQ2dQ8FUTFw=; b=UY25YdoQFSHyeWQ7SSOu24zX07TZXcU/8utTt9q/8MbbDs37fpBbeDfYGe1UJC7Cc/ io+NfHx1fpcBjxX3/2n0DQOpUXItBuM/WpEbrKCx63/Qsx5LB2HeV6OeJNj+jDw2VxEy 61S6GrtJ0Qb5WVxZK84v5w94J4PUdCBKrEaeWzlHVpL2mQm/QJ0FDME/bfwKMuINzCgP +h4mBIaF3t9+M+AljuBxKrQbQB8xYnVCI5hKzYhhhlge6vzOeUluVGitgUTPu9IzxsPN ZwfM7x3IhYFd+Tm+2r3hFOKZY5Yj52BGy2KLCot/o6w9BUtuSTKeNMenHnsLG+EHDb6Y cvtQ== X-Gm-Message-State: ACrzQf1OdFa4snjBDHj/idKEo99wkRQhQNVbasSQ9iYCHOAWFU+ObMgK xtS0DfbIS32xHSYTpO14Oxk= X-Received: by 2002:a65:6cc4:0:b0:412:35fa:5bce with SMTP id g4-20020a656cc4000000b0041235fa5bcemr13374373pgw.466.1664680089138; Sat, 01 Oct 2022 20:08:09 -0700 (PDT) Received: from carrot.. (i220-109-170-101.s42.a014.ap.plala.or.jp. [220.109.170.101]) by smtp.gmail.com with ESMTPSA id lb12-20020a17090b4a4c00b00205fafa6768sm6677189pjb.6.2022.10.01.20.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 20:08:08 -0700 (PDT) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs , syzbot , syzkaller-bugs@googlegroups.com, LKML Subject: [PATCH] nilfs2: fix NULL pointer dereference at nilfs_bmap_lookup_at_level() Date: Sun, 2 Oct 2022 12:08:04 +0900 Message-Id: <20221002030804.29978-1-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <000000000000eb0ba805e9d6e30e@google.com> References: <000000000000eb0ba805e9d6e30e@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 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. Signed-off-by: Ryusuke Konishi Reported-by: syzbot+2b32eb36c1a825b7a74c@syzkaller.appspotmail.com Reported-by: Tetsuo Handa Tested-by: Ryusuke Konishi Cc: stable@vger.kernel.org --- fs/nilfs2/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index 67f63cfeade5..d4e653d51869 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -440,6 +440,8 @@ int nilfs_read_inode_common(struct inode *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 */ -- 2.34.1