Skip to content

Commit

Permalink
NFS: Use parent's objective cred in nfs_access_login_time()
Browse files Browse the repository at this point in the history
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: 0eb4381 ("NFS: Clear the file access cache upon login")
Fixes: 5e9a7b9 ("NFS: Fix up a sparse warning")

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
  • Loading branch information
scottmayhew authored and amschuma-ntap committed Jan 4, 2024
1 parent b4d4fd6 commit a10a923
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a10a923

Please sign in to comment.