Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2922565iog; Mon, 27 Jun 2022 05:51:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1udimJZAAy/N0XCZ7TDzNYXsGkX7G4ERa2bqXi82io/Q0NGrKpqfQS4mB35LtIbJjivHNGZ X-Received: by 2002:a63:330b:0:b0:411:1ba5:174b with SMTP id z11-20020a63330b000000b004111ba5174bmr1758136pgz.602.1656334268621; Mon, 27 Jun 2022 05:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656334268; cv=none; d=google.com; s=arc-20160816; b=avnml3mj5mgSZnK8DZH2ANptDU89dIsZ7wa+jiVCJ2MvKgwtLfl3Hc5I+tj1KTGd6G fNFnqRmmicqxkk59B62momjqV7p+wMFDIERyHbZ5oHBVXZqBTWC3SxiMW8dHQpheSAZq Hm3Dt5gIq/FKbUhgvXDG6b5kWpkBTGglYyYs3xDW9DhkLMWyyaBaBJkscoDVB4RffKcK 7Hm0AkiZhp+daLf0OSHp5jneUOTCl9VfYgMoUZS8FHp651BCJZCVbyj/kwZCVzwP7TSZ Sl004F02Y/3ziD5/x9OXyt1OmG6mOdBDPXnJQOwOB8dkfDcIPBMrQfPWyzrQQYrZCCzE ++8g== 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=cMBhBkvPUGP17V79xF0fPu1t0dniPpWmiv+UvbLbVnE=; b=bkfhlh0TU9QiO6IdLl8LpuprMN5e+m+04AFCOSBidisJ4cfv8Pg3R3i475N0bPjESr hlZ6L3/KYdfEAW8vwDYhQRLlEWZV9+TlGYQ5XzT6IgPpQ2Hf9/AeiWOFsNZgMVPH7ZGk gxZGlDwsrwxF3OB20S1TxxzXi0oysLjfhlqx4ZG7IFljoefxEhXTILVqZ6ugJPTfIw3d 5m5t1pG/u2q7uD20w4qUa/mWHrpB2lygHsS37P1++a8LEIqX6optLs70jsZrPBr0gqBD C1puRC5AFgIZLTFEROum4DXP3ucxvSmpCGzJPxZhWDo40uE9NHYbAn7Y3pmPlbJdk4C5 jGRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1B1ZvubF; 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 hk8-20020a17090b224800b001ecd7df15a5si13111142pjb.46.2022.06.27.05.50.54; Mon, 27 Jun 2022 05:51:08 -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=1B1ZvubF; 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 S235197AbiF0L2S (ORCPT + 99 others); Mon, 27 Jun 2022 07:28:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235168AbiF0L1F (ORCPT ); Mon, 27 Jun 2022 07:27:05 -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 6098A9FC9; Mon, 27 Jun 2022 04:26:55 -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 F2C4161460; Mon, 27 Jun 2022 11:26:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BFE1C341CB; Mon, 27 Jun 2022 11:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329214; bh=bGl2TNNWVIQtfI6S6KPuTnnxACIF1gHxJti+5lW9KW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1B1ZvubF9cfg6YDSqzBByPxe67HEM3Cq87C4WlTjyQxc4GdDRkqSuEwUI8y//662h QvF9Ebhi7ful9WpRyM2iFKN/pcUbVAp6tr0DnygVPhGsiZFOOlRyJ/qOktuD/0U/aM FINBBL5TV3YgldMuwNWgprj0d3W3lRBaikBd2FUQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Dionne , David Howells , linux-afs@lists.infradead.org, Linus Torvalds , Sasha Levin Subject: [PATCH 5.10 048/102] afs: Fix dynamic root getattr Date: Mon, 27 Jun 2022 13:20:59 +0200 Message-Id: <20220627111934.896763562@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 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,T_SCC_BODY_TEXT_LINE 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: David Howells [ Upstream commit cb78d1b5efffe4cf97e16766329dd7358aed3deb ] The recent patch to make afs_getattr consult the server didn't account for the pseudo-inodes employed by the dynamic root-type afs superblock not having a volume or a server to access, and thus an oops occurs if such a directory is stat'd. Fix this by checking to see if the vnode->volume pointer actually points anywhere before following it in afs_getattr(). This can be tested by stat'ing a directory in /afs. It may be sufficient just to do "ls /afs" and the oops looks something like: BUG: kernel NULL pointer dereference, address: 0000000000000020 ... RIP: 0010:afs_getattr+0x8b/0x14b ... Call Trace: vfs_statx+0x79/0xf5 vfs_fstatat+0x49/0x62 Fixes: 2aeb8c86d499 ("afs: Fix afs_getattr() to refetch file status if callback break occurred") Reported-by: Marc Dionne Signed-off-by: David Howells Reviewed-by: Marc Dionne Tested-by: Marc Dionne cc: linux-afs@lists.infradead.org Link: https://lore.kernel.org/r/165408450783.1031787.7941404776393751186.stgit@warthog.procyon.org.uk/ Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/afs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 7e7a9454bcb9..826fae22a8cc 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -734,7 +734,8 @@ int afs_getattr(const struct path *path, struct kstat *stat, _enter("{ ino=%lu v=%u }", inode->i_ino, inode->i_generation); - if (!(query_flags & AT_STATX_DONT_SYNC) && + if (vnode->volume && + !(query_flags & AT_STATX_DONT_SYNC) && !test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags)) { key = afs_request_key(vnode->volume->cell); if (IS_ERR(key)) -- 2.35.1