Commit d3b331fb authored by Ryan Bair's avatar Ryan Bair Committed by Steve French

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: 49bd49f9 ("cifs: send workstation name during ntlmssp session setup")
Cc: stable@vger.kernel.org # 5.16
Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: default avatarRyan Bair <ryandbair@gmail.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 40c845c1
...@@ -1977,6 +1977,19 @@ cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses) ...@@ -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: out_key_put:
up_read(&key->sem); up_read(&key->sem);
key_put(key); key_put(key);
......
...@@ -713,7 +713,11 @@ static int size_of_ntlmssp_blob(struct cifs_ses *ses, int base_size) ...@@ -713,7 +713,11 @@ static int size_of_ntlmssp_blob(struct cifs_ses *ses, int base_size)
else else
sz += sizeof(__le16); 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; return sz;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment