Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cifs: reinstate original behavior again for forceuid/forcegid

forceuid/forcegid should be enabled by default when uid=/gid= options are
specified, but commit 24e0a1eff9e2 ("cifs: switch to new mount api")
changed the behavior. Due to the change, a mounted share does not show
intentional uid/gid for files and directories even though uid=/gid=
options are specified since forceuid/forcegid are not enabled.

This patch reinstates original behavior that overrides uid/gid with
specified uid/gid by the options.

Fixes: 24e0a1eff9e2 ("cifs: switch to new mount api")
Signed-off-by: Takayuki Nagata <tnagata@redhat.com>
Acked-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
Acked-by: Ronnie Sahlberg <lsahlber@redhat.com>
Acked-by: Tom Talpey <tom@talpey.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Takayuki Nagata and committed by
Steve French
77d8aa79 18d86965

+14
+12
fs/smb/client/fs_context.c
··· 748 748 /* set the port that we got earlier */ 749 749 cifs_set_port((struct sockaddr *)&ctx->dstaddr, ctx->port); 750 750 751 + if (ctx->uid_specified && !ctx->forceuid_specified) { 752 + ctx->override_uid = 1; 753 + pr_notice("enabling forceuid mount option implicitly because uid= option is specified\n"); 754 + } 755 + 756 + if (ctx->gid_specified && !ctx->forcegid_specified) { 757 + ctx->override_gid = 1; 758 + pr_notice("enabling forcegid mount option implicitly because gid= option is specified\n"); 759 + } 760 + 751 761 if (ctx->override_uid && !ctx->uid_specified) { 752 762 ctx->override_uid = 0; 753 763 pr_notice("ignoring forceuid mount option specified with no uid= option\n"); ··· 1029 1019 ctx->override_uid = 0; 1030 1020 else 1031 1021 ctx->override_uid = 1; 1022 + ctx->forceuid_specified = true; 1032 1023 break; 1033 1024 case Opt_forcegid: 1034 1025 if (result.negated) 1035 1026 ctx->override_gid = 0; 1036 1027 else 1037 1028 ctx->override_gid = 1; 1029 + ctx->forcegid_specified = true; 1038 1030 break; 1039 1031 case Opt_perm: 1040 1032 if (result.negated)
+2
fs/smb/client/fs_context.h
··· 165 165 }; 166 166 167 167 struct smb3_fs_context { 168 + bool forceuid_specified; 169 + bool forcegid_specified; 168 170 bool uid_specified; 169 171 bool cruid_specified; 170 172 bool gid_specified;