]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
NFS: Fix up the automount fs_context to use the correct cred
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 28 Nov 2025 23:56:46 +0000 (18:56 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Jan 2026 15:31:19 +0000 (16:31 +0100)
[ 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>
fs/nfs/namespace.c

index 923b5c1eb47e9c65e20e53ece56ce87bf3e059e0..99ef1146096fe75de10acd22fd41d15b1fc2bdc3 100644 (file)
@@ -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);