All of lore.kernel.org
 help / color / mirror / Atom feed
* fix workstation_name for multiuser mounts
@ 2021-12-22 16:04 Ryan Bair
  2021-12-22 16:04 ` [PATCH] cifs: " Ryan Bair
  0 siblings, 1 reply; 4+ messages in thread
From: Ryan Bair @ 2021-12-22 16:04 UTC (permalink / raw)
  To: linux-cifs

Long time user, first time contributor. 
Please let me know if I need to be doing something different. 

Thanks,
-Ryan



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] cifs: fix workstation_name for multiuser mounts
  2021-12-22 16:04 fix workstation_name for multiuser mounts Ryan Bair
@ 2021-12-22 16:04 ` Ryan Bair
  2022-02-01 17:22   ` Paulo Alcantara
  2022-02-03  3:32   ` Steve French
  0 siblings, 2 replies; 4+ messages in thread
From: Ryan Bair @ 2021-12-22 16:04 UTC (permalink / raw)
  To: linux-cifs; +Cc: Ryan Bair

Set workstation_name from the master_tcon for multiuser mounts.

Just in case, protect size_of_ntlmssp_blob against a NULL workstation_name.

Signed-off-by: Ryan Bair <ryandbair@gmail.com>
---
 fs/cifs/connect.c | 13 +++++++++++++
 fs/cifs/sess.c    |  6 +++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 1060164b984a..cefd0e9623ba 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1945,6 +1945,19 @@ cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses)
 		}
 	}
 
+	ctx->workstation_name = kstrdup(ses->workstation_name, GFP_KERNEL);
+	if (!ctx->workstation_name) {
+		cifs_dbg(FYI, "Unable to allocate memory for workstation_name\n");
+		rc = -ENOMEM;
+		kfree(ctx->username);
+		ctx->username = NULL;
+		kfree_sensitive(ctx->password);
+		ctx->password = NULL;
+		kfree(ctx->domainname);
+		ctx->domainname = NULL;
+		goto out_key_put;
+	}
+
 out_key_put:
 	up_read(&key->sem);
 	key_put(key);
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 035dc3e245dc..42133939f35d 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -675,7 +675,11 @@ static int size_of_ntlmssp_blob(struct cifs_ses *ses, int base_size)
 	else
 		sz += sizeof(__le16);
 
-	sz += sizeof(__le16) * strnlen(ses->workstation_name, CIFS_MAX_WORKSTATION_LEN);
+	if (ses->workstation_name)
+		sz += sizeof(__le16) * strnlen(ses->workstation_name,
+			CIFS_MAX_WORKSTATION_LEN);
+	else
+		sz += sizeof(__le16);
 
 	return sz;
 }
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cifs: fix workstation_name for multiuser mounts
  2021-12-22 16:04 ` [PATCH] cifs: " Ryan Bair
@ 2022-02-01 17:22   ` Paulo Alcantara
  2022-02-03  3:32   ` Steve French
  1 sibling, 0 replies; 4+ messages in thread
From: Paulo Alcantara @ 2022-02-01 17:22 UTC (permalink / raw)
  To: Ryan Bair, linux-cifs; +Cc: Ryan Bair

Ryan Bair <ryandbair@gmail.com> writes:

> Set workstation_name from the master_tcon for multiuser mounts.
>
> Just in case, protect size_of_ntlmssp_blob against a NULL workstation_name.
>
> Signed-off-by: Ryan Bair <ryandbair@gmail.com>
> ---
>  fs/cifs/connect.c | 13 +++++++++++++
>  fs/cifs/sess.c    |  6 +++++-
>  2 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 1060164b984a..cefd0e9623ba 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c

Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>

Steve, could you pick this up?  Please also add the following tags:

        Fixes: 49bd49f983b5 ("cifs: send workstation name during ntlmssp session setup")
        Cc: stable@vger.kernel.org # 5.16

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cifs: fix workstation_name for multiuser mounts
  2021-12-22 16:04 ` [PATCH] cifs: " Ryan Bair
  2022-02-01 17:22   ` Paulo Alcantara
@ 2022-02-03  3:32   ` Steve French
  1 sibling, 0 replies; 4+ messages in thread
From: Steve French @ 2022-02-03  3:32 UTC (permalink / raw)
  To: Ryan Bair; +Cc: CIFS, Paulo Alcantara

Missed this email thread during the holidays - will test it out later this week.

On Fri, Dec 24, 2021 at 5:07 AM Ryan Bair <ryandbair@gmail.com> wrote:
>
> Set workstation_name from the master_tcon for multiuser mounts.
>
> Just in case, protect size_of_ntlmssp_blob against a NULL workstation_name.
>
> Signed-off-by: Ryan Bair <ryandbair@gmail.com>
> ---
>  fs/cifs/connect.c | 13 +++++++++++++
>  fs/cifs/sess.c    |  6 +++++-
>  2 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 1060164b984a..cefd0e9623ba 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -1945,6 +1945,19 @@ cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses)
>                 }
>         }
>
> +       ctx->workstation_name = kstrdup(ses->workstation_name, GFP_KERNEL);
> +       if (!ctx->workstation_name) {
> +               cifs_dbg(FYI, "Unable to allocate memory for workstation_name\n");
> +               rc = -ENOMEM;
> +               kfree(ctx->username);
> +               ctx->username = NULL;
> +               kfree_sensitive(ctx->password);
> +               ctx->password = NULL;
> +               kfree(ctx->domainname);
> +               ctx->domainname = NULL;
> +               goto out_key_put;
> +       }
> +
>  out_key_put:
>         up_read(&key->sem);
>         key_put(key);
> diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
> index 035dc3e245dc..42133939f35d 100644
> --- a/fs/cifs/sess.c
> +++ b/fs/cifs/sess.c
> @@ -675,7 +675,11 @@ static int size_of_ntlmssp_blob(struct cifs_ses *ses, int base_size)
>         else
>                 sz += sizeof(__le16);
>
> -       sz += sizeof(__le16) * strnlen(ses->workstation_name, CIFS_MAX_WORKSTATION_LEN);
> +       if (ses->workstation_name)
> +               sz += sizeof(__le16) * strnlen(ses->workstation_name,
> +                       CIFS_MAX_WORKSTATION_LEN);
> +       else
> +               sz += sizeof(__le16);
>
>         return sz;
>  }
> --
> 2.33.1
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-03  3:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22 16:04 fix workstation_name for multiuser mounts Ryan Bair
2021-12-22 16:04 ` [PATCH] cifs: " Ryan Bair
2022-02-01 17:22   ` Paulo Alcantara
2022-02-03  3:32   ` Steve French

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.