Commit 4508ec17 authored by Paulo Alcantara's avatar Paulo Alcantara Committed by Steve French

smb: client: set correct id, uid and cruid for multiuser automounts

When uid, gid and cruid are not specified, we need to dynamically
set them into the filesystem context used for automounting otherwise
they'll end up reusing the values from the parent mount.

Fixes: 9fd29a5b ("cifs: use fs_context for automounts")
Reported-by: default avatarShane Nehring <snehring@iastate.edu>
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2259257
Cc: stable@vger.kernel.org # 6.2+
Signed-off-by: default avatarPaulo Alcantara (Red Hat) <pc@manguebit.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 79520587
...@@ -168,6 +168,21 @@ static char *automount_fullpath(struct dentry *dentry, void *page) ...@@ -168,6 +168,21 @@ static char *automount_fullpath(struct dentry *dentry, void *page)
return s; return s;
} }
static void fs_context_set_ids(struct smb3_fs_context *ctx)
{
kuid_t uid = current_fsuid();
kgid_t gid = current_fsgid();
if (ctx->multiuser) {
if (!ctx->uid_specified)
ctx->linux_uid = uid;
if (!ctx->gid_specified)
ctx->linux_gid = gid;
}
if (!ctx->cruid_specified)
ctx->cred_uid = uid;
}
/* /*
* Create a vfsmount that we can automount * Create a vfsmount that we can automount
*/ */
...@@ -205,6 +220,7 @@ static struct vfsmount *cifs_do_automount(struct path *path) ...@@ -205,6 +220,7 @@ static struct vfsmount *cifs_do_automount(struct path *path)
tmp.leaf_fullpath = NULL; tmp.leaf_fullpath = NULL;
tmp.UNC = tmp.prepath = NULL; tmp.UNC = tmp.prepath = NULL;
tmp.dfs_root_ses = NULL; tmp.dfs_root_ses = NULL;
fs_context_set_ids(&tmp);
rc = smb3_fs_context_dup(ctx, &tmp); rc = smb3_fs_context_dup(ctx, &tmp);
if (rc) { if (rc) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment