Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp309650rdb; Tue, 5 Dec 2023 06:12:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGmy2Pyh0UPWGotAkxUNVmBUijBr3s07j+ZeQjWcpCQJgCRI/Stq1HnuHOUN4si3LrCz1qI X-Received: by 2002:a17:902:b70d:b0:1d0:8c3c:a123 with SMTP id d13-20020a170902b70d00b001d08c3ca123mr2417207pls.38.1701785557693; Tue, 05 Dec 2023 06:12:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701785557; cv=none; d=google.com; s=arc-20160816; b=nC8fz35/pNKUzHx0Lxai7cxNjGo/dPK/Nj7xhisdkNcrx5FcgKVk+zob28rYGpKblS jNvW5/bFcalQx5vmWspfq8+sCaGsIYRJ9jSCAYqPSboqLEWt08Pjma2t2WYUJKWDXPbg 7wXSRJoqUEf+PLX+6IVfJDkUgo+fVrSdLGzoWjhyJQo+EltM7eQcXobucHxtsKSOoS2/ auigSnNEK9G6+PDu8uVIFrPYlNtxOb8wMFL/fzc8k3DhK3uimleX2VViId0poEyDmTOn abcGCEZTB7A0jAAxejZQU+olxVNKtIk6Sig14wPQ63+0+B2mVkTPderRYkMItk+M6vYI DGbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JPGfzHqlo357oRYfBXaut/FurUkgeu5VDfyF70luaZs=; fh=kMe8ipV+H2zZMCwplNV8b/uzUHICYp+b9TeU6KoaKrQ=; b=ZKvSOvKaeLqLenyV3ylQ4QwuDQcRtrQjXZk9GJWEZ6d6L2FWkzfD/9TnGQpMP0ziPc Lq/HY3pcYLB6M4sE24E5CHACnbmtkLQ6Z0O/dfb9YiPTtdfbiy5LCzUiBLrEiyOSmqYI Dl7nhKd3lmrO/jX1+Uc4x5NysVkG5WZVKkoF3CH+1fWFr3XNCAmeLdBQ9+TDuQa+KmCq zeycUeWd4k7Bu64d5mnHffKOo+uWCaP+gamHzjhWcrTTRU09lwzUdXIx50VbyweqmqSG Rp5VKStU7HtIRbBQsJ0u0kVzMrwRhZRVJFVf2BS3ztH9OMvBojHi3VQNcWwpn+rJLiZz 8Lnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SM8g0vXg; spf=pass (google.com: domain of linux-nfs+bounces-335-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-335-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i6-20020a170902c94600b001d0b37ba1e5si2800524pla.435.2023.12.05.06.12.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:12:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-335-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SM8g0vXg; spf=pass (google.com: domain of linux-nfs+bounces-335-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-335-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8B6E1B20A5F for ; Tue, 5 Dec 2023 14:12:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B28E61FCA; Tue, 5 Dec 2023 14:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SM8g0vXg" X-Original-To: linux-nfs@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD68A19F for ; Tue, 5 Dec 2023 06:12:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701785548; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JPGfzHqlo357oRYfBXaut/FurUkgeu5VDfyF70luaZs=; b=SM8g0vXgXgoAnRVQFFQ8LR6S1j2hVn5wWNKLvUnBu8c63AuqGKwui3DOs5vVBnqeROTinZ lBjEJMN2PPUB1fxvZEX4/n2B7c03roYaIIBhtOf0M1v1yF0Bob4euu2q48LA7r8GDTUn56 NVBKMBSsdv9YTI7r+1Ln4AqpJDV7L8U= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-471-wnzRVV8gN5SH-TfWWpJWRg-1; Tue, 05 Dec 2023 09:10:56 -0500 X-MC-Unique: wnzRVV8gN5SH-TfWWpJWRg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C1D82185A792; Tue, 5 Dec 2023 14:10:55 +0000 (UTC) Received: from aion.redhat.com (unknown [10.22.32.220]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A3641121312; Tue, 5 Dec 2023 14:10:55 +0000 (UTC) Received: from aion.redhat.com (localhost [IPv6:::1]) by aion.redhat.com (Postfix) with ESMTP id 10831EB05E; Tue, 5 Dec 2023 09:10:55 -0500 (EST) From: Scott Mayhew To: trond.myklebust@hammerspace.com, anna@kernel.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH RFC 1/1] NFS: Use parent's objective cred in nfs_access_login_time() Date: Tue, 5 Dec 2023 09:10:54 -0500 Message-ID: <20231205141054.1759563-2-smayhew@redhat.com> In-Reply-To: <20231205141054.1759563-1-smayhew@redhat.com> References: <20231205141054.1759563-1-smayhew@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 The subjective cred (task->cred) can potentially be overridden and subsquently freed in non-RCU context, which could lead to a panic if we try to use it in cred_fscmp(). Use __task_cred(), which returns the objective cred (task->real_cred) instead. Fixes: 0eb43812c027 ("NFS: Clear the file access cache upon login") Fixes: 5e9a7b9c2ea1 ("NFS: Fix up a sparse warning") Signed-off-by: Scott Mayhew --- fs/nfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 13dffe4201e6..273c0b68abf4 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2963,7 +2963,7 @@ static u64 nfs_access_login_time(const struct task_struct *task, rcu_read_lock(); for (;;) { parent = rcu_dereference(task->real_parent); - pcred = rcu_dereference(parent->cred); + pcred = __task_cred(parent); if (parent == task || cred_fscmp(pcred, cred) != 0) break; task = parent; -- 2.41.0