]> git.itanic.dy.fi Git - linux-stable/commitdiff
cifs: reinstate original behavior again for forceuid/forcegid
authorTakayuki Nagata <tnagata@redhat.com>
Mon, 15 Apr 2024 07:47:49 +0000 (16:47 +0900)
committerSteve French <stfrench@microsoft.com>
Mon, 22 Apr 2024 15:50:31 +0000 (10:50 -0500)
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>
fs/smb/client/fs_context.c
fs/smb/client/fs_context.h

index 6c727d8c31e870ddd0f809db12b21aae76ac80cd..3bbac925d0766b8c456d731355e71b1594b94af3 100644 (file)
@@ -748,6 +748,16 @@ static int smb3_fs_context_validate(struct fs_context *fc)
        /* set the port that we got earlier */
        cifs_set_port((struct sockaddr *)&ctx->dstaddr, ctx->port);
 
+       if (ctx->uid_specified && !ctx->forceuid_specified) {
+               ctx->override_uid = 1;
+               pr_notice("enabling forceuid mount option implicitly because uid= option is specified\n");
+       }
+
+       if (ctx->gid_specified && !ctx->forcegid_specified) {
+               ctx->override_gid = 1;
+               pr_notice("enabling forcegid mount option implicitly because gid= option is specified\n");
+       }
+
        if (ctx->override_uid && !ctx->uid_specified) {
                ctx->override_uid = 0;
                pr_notice("ignoring forceuid mount option specified with no uid= option\n");
@@ -1019,12 +1029,14 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
                        ctx->override_uid = 0;
                else
                        ctx->override_uid = 1;
+               ctx->forceuid_specified = true;
                break;
        case Opt_forcegid:
                if (result.negated)
                        ctx->override_gid = 0;
                else
                        ctx->override_gid = 1;
+               ctx->forcegid_specified = true;
                break;
        case Opt_perm:
                if (result.negated)
index a947bddeba273ea850b3502f07555a19316266a6..cf577ec0dd0ac4a8f5a3131e8ed0c3ce9574a4d7 100644 (file)
@@ -165,6 +165,8 @@ enum cifs_param {
 };
 
 struct smb3_fs_context {
+       bool forceuid_specified;
+       bool forcegid_specified;
        bool uid_specified;
        bool cruid_specified;
        bool gid_specified;