Skip to content

Commit 76a3c92

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: remove support for NTLM and weaker authentication algorithms
for SMB1. This removes the dependency to DES. Signed-off-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 18d0406 commit 76a3c92

File tree

14 files changed

+5
-720
lines changed

14 files changed

+5
-720
lines changed

fs/cifs/Kconfig

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ config CIFS
1616
select CRYPTO_GCM
1717
select CRYPTO_ECB
1818
select CRYPTO_AES
19-
select CRYPTO_LIB_DES
2019
select KEYS
2120
select DNS_RESOLVER
2221
select ASN1
@@ -85,33 +84,6 @@ config CIFS_ALLOW_INSECURE_LEGACY
8584

8685
If unsure, say Y.
8786

88-
config CIFS_WEAK_PW_HASH
89-
bool "Support legacy servers which use weaker LANMAN security"
90-
depends on CIFS && CIFS_ALLOW_INSECURE_LEGACY
91-
help
92-
Modern CIFS servers including Samba and most Windows versions
93-
(since 1997) support stronger NTLM (and even NTLMv2 and Kerberos)
94-
security mechanisms. These hash the password more securely
95-
than the mechanisms used in the older LANMAN version of the
96-
SMB protocol but LANMAN based authentication is needed to
97-
establish sessions with some old SMB servers.
98-
99-
Enabling this option allows the cifs module to mount to older
100-
LANMAN based servers such as OS/2 and Windows 95, but such
101-
mounts may be less secure than mounts using NTLM or more recent
102-
security mechanisms if you are on a public network. Unless you
103-
have a need to access old SMB servers (and are on a private
104-
network) you probably want to say N. Even if this support
105-
is enabled in the kernel build, LANMAN authentication will not be
106-
used automatically. At runtime LANMAN mounts are disabled but
107-
can be set to required (or optional) either in
108-
/proc/fs/cifs (see Documentation/admin-guide/cifs/usage.rst for
109-
more detail) or via an option on the mount command. This support
110-
is disabled by default in order to reduce the possibility of a
111-
downgrade attack.
112-
113-
If unsure, say N.
114-
11587
config CIFS_UPCALL
11688
bool "Kerberos/SPNEGO advanced session setup"
11789
depends on CIFS

fs/cifs/cifs_debug.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
250250
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
251251
seq_printf(m, ",ALLOW_INSECURE_LEGACY");
252252
#endif
253-
#ifdef CONFIG_CIFS_WEAK_PW_HASH
254-
seq_printf(m, ",WEAK_PW_HASH");
255-
#endif
256253
#ifdef CONFIG_CIFS_POSIX
257254
seq_printf(m, ",CIFS_POSIX");
258255
#endif
@@ -929,14 +926,6 @@ cifs_security_flags_handle_must_flags(unsigned int *flags)
929926
*flags = CIFSSEC_MUST_NTLMSSP;
930927
else if ((*flags & CIFSSEC_MUST_NTLMV2) == CIFSSEC_MUST_NTLMV2)
931928
*flags = CIFSSEC_MUST_NTLMV2;
932-
else if ((*flags & CIFSSEC_MUST_NTLM) == CIFSSEC_MUST_NTLM)
933-
*flags = CIFSSEC_MUST_NTLM;
934-
else if (CIFSSEC_MUST_LANMAN &&
935-
(*flags & CIFSSEC_MUST_LANMAN) == CIFSSEC_MUST_LANMAN)
936-
*flags = CIFSSEC_MUST_LANMAN;
937-
else if (CIFSSEC_MUST_PLNTXT &&
938-
(*flags & CIFSSEC_MUST_PLNTXT) == CIFSSEC_MUST_PLNTXT)
939-
*flags = CIFSSEC_MUST_PLNTXT;
940929

941930
*flags |= signflags;
942931
}

fs/cifs/cifs_swn.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ static int cifs_swn_send_register_message(struct cifs_swn_reg *swnreg)
147147
goto nlmsg_fail;
148148
}
149149
break;
150-
case LANMAN:
151-
case NTLM:
152150
case NTLMv2:
153151
case RawNTLMSSP:
154152
ret = cifs_swn_auth_info_ntlm(swnreg->tcon, skb);

fs/cifs/cifsencrypt.c

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -250,87 +250,6 @@ int cifs_verify_signature(struct smb_rqst *rqst,
250250

251251
}
252252

253-
/* first calculate 24 bytes ntlm response and then 16 byte session key */
254-
int setup_ntlm_response(struct cifs_ses *ses, const struct nls_table *nls_cp)
255-
{
256-
int rc = 0;
257-
unsigned int temp_len = CIFS_SESS_KEY_SIZE + CIFS_AUTH_RESP_SIZE;
258-
char temp_key[CIFS_SESS_KEY_SIZE];
259-
260-
if (!ses)
261-
return -EINVAL;
262-
263-
ses->auth_key.response = kmalloc(temp_len, GFP_KERNEL);
264-
if (!ses->auth_key.response)
265-
return -ENOMEM;
266-
267-
ses->auth_key.len = temp_len;
268-
269-
rc = SMBNTencrypt(ses->password, ses->server->cryptkey,
270-
ses->auth_key.response + CIFS_SESS_KEY_SIZE, nls_cp);
271-
if (rc) {
272-
cifs_dbg(FYI, "%s Can't generate NTLM response, error: %d\n",
273-
__func__, rc);
274-
return rc;
275-
}
276-
277-
rc = E_md4hash(ses->password, temp_key, nls_cp);
278-
if (rc) {
279-
cifs_dbg(FYI, "%s Can't generate NT hash, error: %d\n",
280-
__func__, rc);
281-
return rc;
282-
}
283-
284-
rc = mdfour(ses->auth_key.response, temp_key, CIFS_SESS_KEY_SIZE);
285-
if (rc)
286-
cifs_dbg(FYI, "%s Can't generate NTLM session key, error: %d\n",
287-
__func__, rc);
288-
289-
return rc;
290-
}
291-
292-
#ifdef CONFIG_CIFS_WEAK_PW_HASH
293-
int calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt,
294-
char *lnm_session_key)
295-
{
296-
int i, len;
297-
int rc;
298-
char password_with_pad[CIFS_ENCPWD_SIZE] = {0};
299-
300-
if (password) {
301-
for (len = 0; len < CIFS_ENCPWD_SIZE; len++)
302-
if (!password[len])
303-
break;
304-
305-
memcpy(password_with_pad, password, len);
306-
}
307-
308-
if (!encrypt && global_secflags & CIFSSEC_MAY_PLNTXT) {
309-
memcpy(lnm_session_key, password_with_pad,
310-
CIFS_ENCPWD_SIZE);
311-
return 0;
312-
}
313-
314-
/* calculate old style session key */
315-
/* calling toupper is less broken than repeatedly
316-
calling nls_toupper would be since that will never
317-
work for UTF8, but neither handles multibyte code pages
318-
but the only alternative would be converting to UCS-16 (Unicode)
319-
(using a routine something like UniStrupr) then
320-
uppercasing and then converting back from Unicode - which
321-
would only worth doing it if we knew it were utf8. Basically
322-
utf8 and other multibyte codepages each need their own strupper
323-
function since a byte at a time will ont work. */
324-
325-
for (i = 0; i < CIFS_ENCPWD_SIZE; i++)
326-
password_with_pad[i] = toupper(password_with_pad[i]);
327-
328-
rc = SMBencrypt(password_with_pad, cryptkey, lnm_session_key);
329-
330-
return rc;
331-
}
332-
#endif /* CIFS_WEAK_PW_HASH */
333-
334253
/* Build a proper attribute value/target info pairs blob.
335254
* Fill in netbios and dns domain name and workstation name
336255
* and client time (total five av pairs and + one end of fields indicator.

fs/cifs/cifsfs.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,15 +437,9 @@ cifs_show_security(struct seq_file *s, struct cifs_ses *ses)
437437
seq_puts(s, ",sec=");
438438

439439
switch (ses->sectype) {
440-
case LANMAN:
441-
seq_puts(s, "lanman");
442-
break;
443440
case NTLMv2:
444441
seq_puts(s, "ntlmv2");
445442
break;
446-
case NTLM:
447-
seq_puts(s, "ntlm");
448-
break;
449443
case Kerberos:
450444
seq_puts(s, "krb5");
451445
break;

fs/cifs/cifsglob.h

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ enum statusEnum {
114114

115115
enum securityEnum {
116116
Unspecified = 0, /* not specified */
117-
LANMAN, /* Legacy LANMAN auth */
118-
NTLM, /* Legacy NTLM012 auth with NTLM hash */
119117
NTLMv2, /* Legacy NTLM auth with NTLMv2 hash */
120118
RawNTLMSSP, /* NTLMSSP without SPNEGO, NTLMv2 hash */
121119
Kerberos, /* Kerberos via SPNEGO */
@@ -634,7 +632,6 @@ struct TCP_Server_Info {
634632
struct session_key session_key;
635633
unsigned long lstrp; /* when we got last response from this server */
636634
struct cifs_secmech secmech; /* crypto sec mech functs, descriptors */
637-
#define CIFS_NEGFLAVOR_LANMAN 0 /* wct == 13, LANMAN */
638635
#define CIFS_NEGFLAVOR_UNENCAP 1 /* wct == 17, but no ext_sec */
639636
#define CIFS_NEGFLAVOR_EXTENDED 2 /* wct == 17, ext_sec bit set */
640637
char negflavor; /* NEGOTIATE response flavor */
@@ -1734,49 +1731,28 @@ static inline bool is_retryable_error(int error)
17341731

17351732
/* Security Flags: indicate type of session setup needed */
17361733
#define CIFSSEC_MAY_SIGN 0x00001
1737-
#define CIFSSEC_MAY_NTLM 0x00002
17381734
#define CIFSSEC_MAY_NTLMV2 0x00004
17391735
#define CIFSSEC_MAY_KRB5 0x00008
1740-
#ifdef CONFIG_CIFS_WEAK_PW_HASH
1741-
#define CIFSSEC_MAY_LANMAN 0x00010
1742-
#define CIFSSEC_MAY_PLNTXT 0x00020
1743-
#else
1744-
#define CIFSSEC_MAY_LANMAN 0
1745-
#define CIFSSEC_MAY_PLNTXT 0
1746-
#endif /* weak passwords */
17471736
#define CIFSSEC_MAY_SEAL 0x00040 /* not supported yet */
17481737
#define CIFSSEC_MAY_NTLMSSP 0x00080 /* raw ntlmssp with ntlmv2 */
17491738

17501739
#define CIFSSEC_MUST_SIGN 0x01001
17511740
/* note that only one of the following can be set so the
17521741
result of setting MUST flags more than once will be to
17531742
require use of the stronger protocol */
1754-
#define CIFSSEC_MUST_NTLM 0x02002
17551743
#define CIFSSEC_MUST_NTLMV2 0x04004
17561744
#define CIFSSEC_MUST_KRB5 0x08008
1757-
#ifdef CONFIG_CIFS_WEAK_PW_HASH
1758-
#define CIFSSEC_MUST_LANMAN 0x10010
1759-
#define CIFSSEC_MUST_PLNTXT 0x20020
1760-
#ifdef CONFIG_CIFS_UPCALL
1761-
#define CIFSSEC_MASK 0xBF0BF /* allows weak security but also krb5 */
1762-
#else
1763-
#define CIFSSEC_MASK 0xB70B7 /* current flags supported if weak */
1764-
#endif /* UPCALL */
1765-
#else /* do not allow weak pw hash */
1766-
#define CIFSSEC_MUST_LANMAN 0
1767-
#define CIFSSEC_MUST_PLNTXT 0
17681745
#ifdef CONFIG_CIFS_UPCALL
17691746
#define CIFSSEC_MASK 0x8F08F /* flags supported if no weak allowed */
17701747
#else
17711748
#define CIFSSEC_MASK 0x87087 /* flags supported if no weak allowed */
17721749
#endif /* UPCALL */
1773-
#endif /* WEAK_PW_HASH */
17741750
#define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */
17751751
#define CIFSSEC_MUST_NTLMSSP 0x80080 /* raw ntlmssp with ntlmv2 */
17761752

17771753
#define CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_NTLMSSP)
1778-
#define CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
1779-
#define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
1754+
#define CIFSSEC_MAX (CIFSSEC_MUST_NTLMV2)
1755+
#define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
17801756
/*
17811757
*****************************************************************
17821758
* All constants go here
@@ -1940,10 +1916,6 @@ static inline char *get_security_type_str(enum securityEnum sectype)
19401916
return "Kerberos";
19411917
case NTLMv2:
19421918
return "NTLMv2";
1943-
case NTLM:
1944-
return "NTLM";
1945-
case LANMAN:
1946-
return "LANMAN";
19471919
default:
19481920
return "Unknown";
19491921
}

fs/cifs/cifspdu.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@
1414
#include <asm/unaligned.h>
1515
#include "smbfsctl.h"
1616

17-
#ifdef CONFIG_CIFS_WEAK_PW_HASH
18-
#define LANMAN_PROT 0
19-
#define LANMAN2_PROT 1
20-
#define CIFS_PROT 2
21-
#else
2217
#define CIFS_PROT 0
23-
#endif
2418
#define POSIX_PROT (CIFS_PROT+1)
2519
#define BAD_PROT 0xFFFF
2620

@@ -505,30 +499,8 @@ typedef struct negotiate_req {
505499
unsigned char DialectsArray[1];
506500
} __attribute__((packed)) NEGOTIATE_REQ;
507501

508-
/* Dialect index is 13 for LANMAN */
509-
510502
#define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
511503

512-
typedef struct lanman_neg_rsp {
513-
struct smb_hdr hdr; /* wct = 13 */
514-
__le16 DialectIndex;
515-
__le16 SecurityMode;
516-
__le16 MaxBufSize;
517-
__le16 MaxMpxCount;
518-
__le16 MaxNumberVcs;
519-
__le16 RawMode;
520-
__le32 SessionKey;
521-
struct {
522-
__le16 Time;
523-
__le16 Date;
524-
} __attribute__((packed)) SrvTime;
525-
__le16 ServerTimeZone;
526-
__le16 EncryptionKeyLength;
527-
__le16 Reserved;
528-
__u16 ByteCount;
529-
unsigned char EncryptionKey[1];
530-
} __attribute__((packed)) LANMAN_NEG_RSP;
531-
532504
#define READ_RAW_ENABLE 1
533505
#define WRITE_RAW_ENABLE 2
534506
#define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)

fs/cifs/cifsproto.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -498,19 +498,12 @@ extern int cifs_sign_smb(struct smb_hdr *, struct TCP_Server_Info *, __u32 *);
498498
extern int cifs_verify_signature(struct smb_rqst *rqst,
499499
struct TCP_Server_Info *server,
500500
__u32 expected_sequence_number);
501-
extern int SMBNTencrypt(unsigned char *, unsigned char *, unsigned char *,
502-
const struct nls_table *);
503-
extern int setup_ntlm_response(struct cifs_ses *, const struct nls_table *);
504501
extern int setup_ntlmv2_rsp(struct cifs_ses *, const struct nls_table *);
505502
extern void cifs_crypto_secmech_release(struct TCP_Server_Info *server);
506503
extern int calc_seckey(struct cifs_ses *);
507504
extern int generate_smb30signingkey(struct cifs_ses *);
508505
extern int generate_smb311signingkey(struct cifs_ses *);
509506

510-
#ifdef CONFIG_CIFS_WEAK_PW_HASH
511-
extern int calc_lanman_hash(const char *password, const char *cryptkey,
512-
bool encrypt, char *lnm_session_key);
513-
#endif /* CIFS_WEAK_PW_HASH */
514507
extern int CIFSSMBCopy(unsigned int xid,
515508
struct cifs_tcon *source_tcon,
516509
const char *fromName,
@@ -547,11 +540,8 @@ extern int check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
547540
struct cifs_sb_info *cifs_sb,
548541
struct cifs_fattr *fattr,
549542
const unsigned char *path);
550-
extern int mdfour(unsigned char *, unsigned char *, int);
551543
extern int E_md4hash(const unsigned char *passwd, unsigned char *p16,
552544
const struct nls_table *codepage);
553-
extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8,
554-
unsigned char *p24);
555545

556546
extern int
557547
cifs_setup_volume_info(struct smb3_fs_context *ctx, const char *mntopts, const char *devname);

0 commit comments

Comments
 (0)