]> git.ipfire.org Git - thirdparty/kernel/linux.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)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Sat, 29 Nov 2025 22:23:03 +0000 (17:23 -0500)
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>
fs/nfs/namespace.c

index 9e4d94f41fc674c4b887df615495ba314c8801ca..af9be0c5f516300b3edaf124ebd09a6c7a46fc28 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);