Skip to content

Commit d3b331f

Browse files
ryandbairsmfrench
authored andcommitted
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: 49bd49f ("cifs: send workstation name during ntlmssp session setup") Cc: [email protected] # 5.16 Reviewed-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Ryan Bair <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 40c845c commit d3b331f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

fs/cifs/connect.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,19 @@ cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses)
19771977
}
19781978
}
19791979

1980+
ctx->workstation_name = kstrdup(ses->workstation_name, GFP_KERNEL);
1981+
if (!ctx->workstation_name) {
1982+
cifs_dbg(FYI, "Unable to allocate memory for workstation_name\n");
1983+
rc = -ENOMEM;
1984+
kfree(ctx->username);
1985+
ctx->username = NULL;
1986+
kfree_sensitive(ctx->password);
1987+
ctx->password = NULL;
1988+
kfree(ctx->domainname);
1989+
ctx->domainname = NULL;
1990+
goto out_key_put;
1991+
}
1992+
19801993
out_key_put:
19811994
up_read(&key->sem);
19821995
key_put(key);

fs/cifs/sess.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,11 @@ static int size_of_ntlmssp_blob(struct cifs_ses *ses, int base_size)
713713
else
714714
sz += sizeof(__le16);
715715

716-
sz += sizeof(__le16) * strnlen(ses->workstation_name, CIFS_MAX_WORKSTATION_LEN);
716+
if (ses->workstation_name)
717+
sz += sizeof(__le16) * strnlen(ses->workstation_name,
718+
CIFS_MAX_WORKSTATION_LEN);
719+
else
720+
sz += sizeof(__le16);
717721

718722
return sz;
719723
}

0 commit comments

Comments
 (0)