Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2904425iog; Mon, 27 Jun 2022 05:28:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vqfiDSjcOi0xoWTqFWJ/u9YF+IZ9Td0D4BZKUnG4BHJRc5AcruY+klAOHrY5P6Fw86p5TV X-Received: by 2002:a17:902:dacd:b0:16a:4110:22a with SMTP id q13-20020a170902dacd00b0016a4110022amr14617727plx.11.1656332909370; Mon, 27 Jun 2022 05:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332909; cv=none; d=google.com; s=arc-20160816; b=S4BQ6fXFg+TEv6TD+FCOB+1zYY7Vg5sNj88Rz5ccFZ0C2ROjUtQGE3UyiOwf3xyrMZ R2NKZa+nCm8GlutgH0CvqFs3T1dA5yLEQFdmhgX2IhI+G0LvZipLaj/switmJyPX54sD dZHkPNv5/jYplAQ81Sfc2oqILwEZzGJBjT3cDJR+5xRi2ABu+QDI4IYEONQjHpXY8Grp mttr0W/9/VoWKXKFzYRxZdYf3M5VSrExuKbFsp3eWqlTZN4TVTgp45gd1Q4Che4XmAW1 yRLVkOw+IpPuVZgpa9TzQqLOadNPiDnru5vB5AX25fXoFTYzFrAedi6G49GDCo4ioI9Z 0HUA== 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=dRIHRMS+R82dsmiNGR4omIJWav1cnXjbnndfr7a0mcY=; b=NAYV9ehREgEabTXVBFMjhZPj7e9uxQo0Xh8pLpp7aiwW58KBj179TtjpxP7gXhouIl Jb30XKRPdV2LZSohztxWenGgjFNMWjfR2bbWjOF98EvhRrc5F1vGGnDfec4MTbVNlhfO cWHNRT7MkCnB/OiVUTqD6Yh4SIBuOrej7AFeTduh2o381rczza/oPrY8Ch4FuqoqB9Pw 6Ilo3zHX69N1WH51xnPqWtoF79Ppv6LIu3foLde2xu5lHPfNG84wiC1vsjhWqvZ6i219 KFwQwHVqGlL9iZ3h/yEcABCzZzilo/TnOQtUOVlvB3FFY+AO7FZSzGgoDbJmWsJgtW8x GAMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NAxAvQQc; 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 b21-20020a170902d31500b0016a28448c46si13277582plc.561.2022.06.27.05.28.17; Mon, 27 Jun 2022 05:28:29 -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=NAxAvQQc; 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 S235551AbiF0LcO (ORCPT + 99 others); Mon, 27 Jun 2022 07:32:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235555AbiF0Lbr (ORCPT ); Mon, 27 Jun 2022 07:31:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C70010CD; Mon, 27 Jun 2022 04:29:06 -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 B0E90B8111B; Mon, 27 Jun 2022 11:29:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE6E0C3411D; Mon, 27 Jun 2022 11:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329343; bh=SpUk5xopBVEJbsXDCPPzUrXYRKodP1EeLbPsa/mnV5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NAxAvQQc17HlJe5D1b1fxOQtfwrdnFzpCMxqCikoGmBCl8BGahtYbiowninu4ynjB LW0sh99vFJsb52KYSjcWfVy77orzlaoDfoMLnaMjP03Nj+0V6r8hPypjAKbiYzu/fy 9Ozt6noYLDIu9UND0KKY/D9nkrOlDgN9kzxRaCPQ= 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.4 27/60] afs: Fix dynamic root getattr Date: Mon, 27 Jun 2022 13:21:38 +0200 Message-Id: <20220627111928.485967575@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111927.641837068@linuxfoundation.org> References: <20220627111927.641837068@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 90eac3ec01cb..622363af4c1b 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -739,7 +739,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