diff options
author | Paulo Alcantara <pc@cjr.nz> | 2022-05-25 07:37:04 -0500 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2022-05-25 07:41:22 -0500 |
commit | de3a9e943ddecba8d2ac1dde4cfff538e5c6a7b9 (patch) | |
tree | 6cc5c2567bfbdb3155662c166020189c473be525 /fs/cifs/cifsglob.h | |
parent | d87c48ce4d8951f46d21f17ea86bba8853049862 (diff) | |
download | linux-de3a9e943ddecba8d2ac1dde4cfff538e5c6a7b9.tar.gz |
cifs: fix ntlmssp on old servers
Some older servers seem to require the workstation name during ntlmssp
to be at most 15 chars (RFC1001 name length), so truncate it before
sending when using insecure dialects.
Link: https://lore.kernel.org/r/e6837098-15d9-acb6-7e34-1923cf8c6fe1@winds.org
Reported-by: Byron Stanoszek <gandalf@winds.org>
Tested-by: Byron Stanoszek <gandalf@winds.org>
Fixes: 49bd49f983b5 ("cifs: send workstation name during ntlmssp session setup")
Cc: stable@vger.kernel.org
Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/cifsglob.h')
-rw-r--r-- | fs/cifs/cifsglob.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index b6c2a787be06..68da230c7f11 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -952,7 +952,7 @@ struct cifs_ses { and after mount option parsing we fill it */ char *domainName; char *password; - char *workstation_name; + char workstation_name[CIFS_MAX_WORKSTATION_LEN]; struct session_key auth_key; struct ntlmssp_auth *ntlmssp; /* ciphertext, flags, server challenge */ enum securityEnum sectype; /* what security flavor was specified? */ @@ -2018,4 +2018,17 @@ static inline u64 cifs_flock_len(struct file_lock *fl) return fl->fl_end == OFFSET_MAX ? 0 : fl->fl_end - fl->fl_start + 1; } +static inline size_t ntlmssp_workstation_name_size(const struct cifs_ses *ses) +{ + if (WARN_ON_ONCE(!ses || !ses->server)) + return 0; + /* + * Make workstation name no more than 15 chars when using insecure dialects as some legacy + * servers do require it during NTLMSSP. + */ + if (ses->server->dialect <= SMB20_PROT_ID) + return min_t(size_t, sizeof(ses->workstation_name), RFC1001_NAME_LEN_WITH_NULL); + return sizeof(ses->workstation_name); +} + #endif /* _CIFS_GLOB_H */ |