Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5777758ioo; Wed, 1 Jun 2022 12:22:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw19zskstwRMfjKSsMSuy6G4qHd8OsolJNrNe2wrhoCdgvtjFfA0+D2ySCWWiSblZ01GC6b X-Received: by 2002:a17:902:a608:b0:161:f859:e8d1 with SMTP id u8-20020a170902a60800b00161f859e8d1mr978950plq.116.1654111361003; Wed, 01 Jun 2022 12:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654111361; cv=none; d=google.com; s=arc-20160816; b=a8ACEbk9aIulZUR3p9+a6jklApv9jmeaIO7iojhm5s3bqPfcMsmx1WOpTTYpdm1jMV U9mZCnAAvxJ5lTCIdTVzXhE0hrJAVG+tv51A5ZQIBL6rrJbWTDtTNxqjgPMsWKvKd61k ofw6kDt4Mhmxgwb20Ht/F9KTpU2jvwKgEhA+4aZKit2iBrnpdzpRC2h2FACGfS4BN1Rf 8me8hPr45gOzVegkj6F+uSeaUElYNuhecW/pFOIW2gm+APP6B+lIpbsRVH9Rkqme/W9T E8H4mlXarhEQ46DptBmgX6bA+2TFSdXYVQcGWOFvEMw8StOkHMwZaJHqkilTt8hktcC1 +k+w== 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:message-id:date:cc:to:from:subject:organization :dkim-signature; bh=A1XdIemq8frjYfv4a28xhmhvY/SFwVpocirLnr3lxtY=; b=Dy6UhNsGVzx9867t8yeFiJpl674xa01zmYAHsA3L1+OU+tzghx82y4zIutJl3OlB2C PVu6zHLYJ8bqu4nRqTCkmabypoNODAPw4AqPImHTDQB1MObK6EJmcwuJ5sErBciOfeVM nfiiAcAswD1uFcpEoWaTGe0qxjqF4iqGVTge6yMlD3tAXmN+x1rhcx+Ljw244j/Btx8v up3Rt+x6hnZfPJ6z1sr3BcRTn4n3ONJj7S/NXFpNO1HzSoLBQkQ5QIKVIsKJ/j0rfuP1 CEenQ/KctxeX3RwcwC2TdcUEEHntB8LUnfHPHv+Z7sviRc4HVHkFT8WajZxCZuD+81BO b/hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cKkjtT7A; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i5-20020a170902c28500b00163f8c2dec7si3014313pld.347.2022.06.01.12.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:22:40 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cKkjtT7A; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B18BC10BA; Wed, 1 Jun 2022 11:56:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345503AbiFALzZ (ORCPT + 99 others); Wed, 1 Jun 2022 07:55:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233840AbiFALzV (ORCPT ); Wed, 1 Jun 2022 07:55:21 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 135D76B7C0 for ; Wed, 1 Jun 2022 04:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654084519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=A1XdIemq8frjYfv4a28xhmhvY/SFwVpocirLnr3lxtY=; b=cKkjtT7ASb9L5OQE1eqFNtozHBzeXYLPiSycPsBeFJM6Ai3KYghEHQBmAD/UuAhQSCcEby DDPwXzLfzI0bCqPNt6wYo5c6TLU8+638OBUNgWT3M0OMo1POYMV6X9Gs87E+2d3WxWLt3c fISFhpsL0Jnl5vvbUhQkiyJxQVfrgfM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-AwrvSifIOhi-RiCzV8sH6w-1; Wed, 01 Jun 2022 07:55:13 -0400 X-MC-Unique: AwrvSifIOhi-RiCzV8sH6w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 481E22949BA3; Wed, 1 Jun 2022 11:55:09 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A37CC23DBF; Wed, 1 Jun 2022 11:55:08 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH] afs: Fix dynamic root getattr From: David Howells To: marc.dionne@auristor.com Cc: linux-afs@lists.infradead.org, dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 01 Jun 2022 12:55:07 +0100 Message-ID: <165408450783.1031787.7941404776393751186.stgit@warthog.procyon.org.uk> User-Agent: StGit/1.4 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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 cc: linux-afs@lists.infradead.org --- 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 30b066299d39..33ecbfea0199 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -745,7 +745,8 @@ int afs_getattr(struct user_namespace *mnt_userns, const struct path *path, _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))