summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Mayhew <smayhew@redhat.com>2023-12-05 17:10:54 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-01-26 02:35:18 +0300
commit4ffac0013421295e055005e8ae47d8c5b8ada387 (patch)
tree957a68412f2e527ab0020dac796647445b13ac1d
parentb4b7dd1cb6083f88ea16fabca46baf317afbba99 (diff)
downloadlinux-4ffac0013421295e055005e8ae47d8c5b8ada387.tar.xz
NFS: Use parent's objective cred in nfs_access_login_time()
[ Upstream commit a10a9233073d984b239e22358ba21825e27e2e88 ] 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 <smayhew@redhat.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--fs/nfs/dir.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index e6a51fd94fea..9fc5061d51b2 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2968,7 +2968,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;