summaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
authorRyan Bair <ryandbair@gmail.com>2021-12-22 11:04:05 -0500
committerSteve French <stfrench@microsoft.com>2022-02-03 00:16:37 -0600
commitd3b331fb51f326d5b5326010bf2b5841bb86cdc6 (patch)
treebbbbfff67f0f4f0b29de3ca02cff16f72f34b722 /fs/cifs/connect.c
parent40c845c176953311c8fc232e977516f7733c64cd (diff)
downloadlinux-d3b331fb51f326d5b5326010bf2b5841bb86cdc6.tar.gz
linux-d3b331fb51f326d5b5326010bf2b5841bb86cdc6.tar.bz2
linux-d3b331fb51f326d5b5326010bf2b5841bb86cdc6.zip
cifs: fix workstation_name for multiuser mounts
Set workstation_name from the master_tcon for multiuser mounts. Just in case, protect size_of_ntlmssp_blob against a NULL workstation_name. Fixes: 49bd49f983b5 ("cifs: send workstation name during ntlmssp session setup") Cc: stable@vger.kernel.org # 5.16 Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Ryan Bair <ryandbair@gmail.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 5a51a098b845..0b742bd50642 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1977,6 +1977,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);