linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Shilovsky <piastryyy@gmail.com>
To: Ronnie Sahlberg <lsahlber@redhat.com>
Cc: linux-cifs <linux-cifs@vger.kernel.org>,
	Steve French <smfrench@gmail.com>
Subject: Re: [PATCH] cifs: use helpers when parsing uid/gid mount options and validate them
Date: Thu, 8 Jul 2021 15:11:46 -0700	[thread overview]
Message-ID: <CAKywueSiuJU4YipMtsyf+CYDywSX3ySgMrmsvt9swJT4GkjTZg@mail.gmail.com> (raw)
In-Reply-To: <20210707232416.2694911-2-lsahlber@redhat.com>

ср, 7 июл. 2021 г. в 16:25, Ronnie Sahlberg <lsahlber@redhat.com>:
>
> Use the nice helpers to initialize and the uid/gid/cred_uid when passed as mount arguments.
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/fs_context.c | 24 +++++++++++++++++++-----
>  fs/cifs/fs_context.h |  1 +
>  2 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
> index 92d4ab029c91..553adfbcc22a 100644
> --- a/fs/cifs/fs_context.c
> +++ b/fs/cifs/fs_context.c
> @@ -322,7 +322,6 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
>         new_ctx->UNC = NULL;
>         new_ctx->source = NULL;
>         new_ctx->iocharset = NULL;
> -
>         /*
>          * Make sure to stay in sync with smb3_cleanup_fs_context_contents()
>          */
> @@ -792,6 +791,8 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
>         int i, opt;
>         bool is_smb3 = !strcmp(fc->fs_type->name, "smb3");
>         bool skip_parsing = false;
> +       kuid_t uid;
> +       kgid_t gid;
>
>         cifs_dbg(FYI, "CIFS: parsing cifs mount option '%s'\n", param->key);
>
> @@ -904,18 +905,31 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
>                 }
>                 break;
>         case Opt_uid:
> -               ctx->linux_uid.val = result.uint_32;
> +               uid = make_kuid(current_user_ns(), result.uint_32);
> +               if (!uid_valid(uid))
> +                       goto cifs_parse_mount_err;
> +               ctx->linux_uid = uid;
>                 ctx->uid_specified = true;
>                 break;
>         case Opt_cruid:
> -               ctx->cred_uid.val = result.uint_32;
> +               uid = make_kuid(current_user_ns(), result.uint_32);
> +               if (!uid_valid(uid))
> +                       goto cifs_parse_mount_err;
> +               ctx->cred_uid = uid;
> +               ctx->cruid_specified = true;
>                 break;
>         case Opt_backupgid:
> -               ctx->backupgid.val = result.uint_32;
> +               gid = make_kgid(current_user_ns(), result.uint_32);
> +               if (!gid_valid(gid))
> +                       goto cifs_parse_mount_err;
> +               ctx->backupgid = gid;
>                 ctx->backupgid_specified = true;
>                 break;
>         case Opt_gid:
> -               ctx->linux_gid.val = result.uint_32;
> +               gid = make_kgid(current_user_ns(), result.uint_32);
> +               if (!gid_valid(gid))
> +                       goto cifs_parse_mount_err;
> +               ctx->linux_gid = gid;
>                 ctx->gid_specified = true;
>                 break;
>         case Opt_port:
> diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h
> index 2a71c8e411ac..b6243972edf3 100644
> --- a/fs/cifs/fs_context.h
> +++ b/fs/cifs/fs_context.h
> @@ -155,6 +155,7 @@ enum cifs_param {
>
>  struct smb3_fs_context {
>         bool uid_specified;
> +       bool cruid_specified;

Is it going to be used somewhere?

>         bool gid_specified;
>         bool sloppy;
>         bool got_ip;
> --
> 2.30.2
>

Acked-by: Pavel Shilovsky <pshilovsky@samba.org>

--
Best regards,
Pavel Shilovsky

  parent reply	other threads:[~2021-07-08 22:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07 23:24 [PATCH 0/1] cifs: use helpers when parsing uid/gid mount options and Ronnie Sahlberg
2021-07-07 23:24 ` [PATCH] cifs: use helpers when parsing uid/gid mount options and validate them Ronnie Sahlberg
2021-07-08  0:57   ` Steve French
2021-07-08 22:11   ` Pavel Shilovsky [this message]
2021-07-08 23:25     ` ronnie sahlberg
2021-07-09  0:20       ` Steve French

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKywueSiuJU4YipMtsyf+CYDywSX3ySgMrmsvt9swJT4GkjTZg@mail.gmail.com \
    --to=piastryyy@gmail.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=lsahlber@redhat.com \
    --cc=smfrench@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).