Skip to content

Commit 4508ec1

Browse files
Paulo AlcantaraSteve French
authored andcommitted
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: 9fd29a5 ("cifs: use fs_context for automounts") Reported-by: Shane Nehring <snehring@iastate.edu> Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2259257 Cc: stable@vger.kernel.org # 6.2+ Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 7952058 commit 4508ec1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

fs/smb/client/namespace.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,21 @@ static char *automount_fullpath(struct dentry *dentry, void *page)
168168
return s;
169169
}
170170

171+
static void fs_context_set_ids(struct smb3_fs_context *ctx)
172+
{
173+
kuid_t uid = current_fsuid();
174+
kgid_t gid = current_fsgid();
175+
176+
if (ctx->multiuser) {
177+
if (!ctx->uid_specified)
178+
ctx->linux_uid = uid;
179+
if (!ctx->gid_specified)
180+
ctx->linux_gid = gid;
181+
}
182+
if (!ctx->cruid_specified)
183+
ctx->cred_uid = uid;
184+
}
185+
171186
/*
172187
* Create a vfsmount that we can automount
173188
*/
@@ -205,6 +220,7 @@ static struct vfsmount *cifs_do_automount(struct path *path)
205220
tmp.leaf_fullpath = NULL;
206221
tmp.UNC = tmp.prepath = NULL;
207222
tmp.dfs_root_ses = NULL;
223+
fs_context_set_ids(&tmp);
208224

209225
rc = smb3_fs_context_dup(ctx, &tmp);
210226
if (rc) {

0 commit comments

Comments
 (0)