Skip to content

Commit 2675b6e

Browse files
committed
smb: client: set correct id, uid and cruid for multiuser automounts
jira LE-1907 Rebuild_History Non-Buildable kernel-5.14.0-427.37.1.el9_4 commit-author Paulo Alcantara <pc@manguebit.com> commit 4508ec1 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> (cherry picked from commit 4508ec1) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 92db1b0 commit 2675b6e

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
@@ -166,6 +166,21 @@ static char *automount_fullpath(struct dentry *dentry, void *page)
166166
return s;
167167
}
168168

169+
static void fs_context_set_ids(struct smb3_fs_context *ctx)
170+
{
171+
kuid_t uid = current_fsuid();
172+
kgid_t gid = current_fsgid();
173+
174+
if (ctx->multiuser) {
175+
if (!ctx->uid_specified)
176+
ctx->linux_uid = uid;
177+
if (!ctx->gid_specified)
178+
ctx->linux_gid = gid;
179+
}
180+
if (!ctx->cruid_specified)
181+
ctx->cred_uid = uid;
182+
}
183+
169184
/*
170185
* Create a vfsmount that we can automount
171186
*/
@@ -214,6 +229,7 @@ static struct vfsmount *cifs_do_automount(struct path *path)
214229
tmp.leaf_fullpath = NULL;
215230
tmp.UNC = tmp.prepath = NULL;
216231
tmp.dfs_root_ses = NULL;
232+
fs_context_set_ids(&tmp);
217233

218234
rc = smb3_fs_context_dup(ctx, &tmp);
219235
if (rc) {

0 commit comments

Comments
 (0)