summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2025-11-28 18:56:46 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-01-17 16:39:28 +0100
commit4b5c2d46daa051f33d79e776434010e77f301b56 (patch)
tree817cb0ed4c296ce505d6fbc3455edf842095c3c1
parenta5c5e97945ff38626c0f71deea377d50d75dae4e (diff)
NFS: Fix up the automount fs_context to use the correct cred
[ Upstream commit a2a8fc27dd668e7562b5326b5ed2f1604cb1e2e9 ] When automounting, the fs_context should be fixed up to use the cred from the parent filesystem, since the operation is just extending the namespace. Authorisation to enter that namespace will already have been provided by the preceding lookup. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--fs/nfs/namespace.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 663f1a3f7cc3..5cbbe59e5623 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -170,6 +170,11 @@ struct vfsmount *nfs_d_automount(struct path *path)
if (!ctx->clone_data.fattr)
goto out_fc;
+ if (fc->cred != server->cred) {
+ put_cred(fc->cred);
+ fc->cred = get_cred(server->cred);
+ }
+
if (fc->net_ns != client->cl_net) {
put_net(fc->net_ns);
fc->net_ns = get_net(client->cl_net);