Skip to content

Commit 9c849ce

Browse files
committed
Merge tag '5.15-rc-smb3-fixes-part1' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs client updates from Steve French: "Eleven cifs/smb3 client fixes: - mostly restructuring to allow disabling less secure algorithms (this will allow eventual removing rc4 and md4 from general use in the kernel) - four fixes, including two for stable - enable r/w support with fscache and cifs.ko I am working on a larger set of changes (the usual ... multichannel, auth and signing improvements), but wanted to get these in earlier to reduce chance of merge conflicts later in the merge window" * tag '5.15-rc-smb3-fixes-part1' of git://git.samba.org/sfrench/cifs-2.6: cifs: Do not leak EDEADLK to dgetents64 for STATUS_USER_SESSION_DELETED cifs: add cifs_common directory to MAINTAINERS file cifs: cifs_md4 convert to SPDX identifier cifs: create a MD4 module and switch cifs.ko to use it cifs: fork arc4 and create a separate module for it for cifs and other users cifs: remove support for NTLM and weaker authentication algorithms cifs: enable fscache usage even for files opened as rw oid_registry: Add OIDs for missing Spnego auth mechanisms to Macs smb3: fix posix extensions mount option cifs: fix wrong release in sess_alloc_buffer() failed path CIFS: Fix a potencially linear read overflow
2 parents e24c567 + 3998f0b commit 9c849ce

30 files changed

+485
-763
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4629,6 +4629,7 @@ W: http://linux-cifs.samba.org/
46294629
T: git git://git.samba.org/sfrench/cifs-2.6.git
46304630
F: Documentation/admin-guide/cifs/
46314631
F: fs/cifs/
4632+
F: fs/cifs_common/
46324633

46334634
COMPACTPCI HOTPLUG CORE
46344635
M: Scott Murray <[email protected]>

fs/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,15 @@ config NFS_V4_2_SSC_HELPER
348348

349349
source "net/sunrpc/Kconfig"
350350
source "fs/ceph/Kconfig"
351+
351352
source "fs/cifs/Kconfig"
352353
source "fs/ksmbd/Kconfig"
354+
355+
config CIFS_COMMON
356+
tristate
357+
default y if CIFS=y
358+
default m if CIFS=m
359+
353360
source "fs/coda/Kconfig"
354361
source "fs/afs/Kconfig"
355362
source "fs/9p/Kconfig"

fs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ obj-$(CONFIG_LOCKD) += lockd/
9696
obj-$(CONFIG_NLS) += nls/
9797
obj-$(CONFIG_UNICODE) += unicode/
9898
obj-$(CONFIG_SYSV_FS) += sysv/
99+
obj-$(CONFIG_CIFS_COMMON) += cifs_common/
99100
obj-$(CONFIG_CIFS) += cifs/
100101
obj-$(CONFIG_SMB_SERVER) += ksmbd/
101102
obj-$(CONFIG_HPFS_FS) += hpfs/

fs/cifs/Kconfig

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ config CIFS
44
depends on INET
55
select NLS
66
select CRYPTO
7-
select CRYPTO_MD4
87
select CRYPTO_MD5
98
select CRYPTO_SHA256
109
select CRYPTO_SHA512
1110
select CRYPTO_CMAC
1211
select CRYPTO_HMAC
13-
select CRYPTO_LIB_ARC4
1412
select CRYPTO_AEAD2
1513
select CRYPTO_CCM
1614
select CRYPTO_GCM
1715
select CRYPTO_ECB
1816
select CRYPTO_AES
19-
select CRYPTO_LIB_DES
2017
select KEYS
2118
select DNS_RESOLVER
2219
select ASN1
@@ -85,33 +82,6 @@ config CIFS_ALLOW_INSECURE_LEGACY
8582

8683
If unsure, say Y.
8784

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-
11585
config CIFS_UPCALL
11686
bool "Kerberos/SPNEGO advanced session setup"
11787
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/cifs_unicode.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,9 @@ cifs_strndup_from_utf16(const char *src, const int maxlen,
358358
if (!dst)
359359
return NULL;
360360
cifs_from_utf16(dst, (__le16 *) src, len, maxlen, codepage,
361-
NO_MAP_UNI_RSVD);
361+
NO_MAP_UNI_RSVD);
362362
} else {
363-
len = strnlen(src, maxlen);
364-
len++;
365-
dst = kmalloc(len, GFP_KERNEL);
366-
if (!dst)
367-
return NULL;
368-
strlcpy(dst, src, len);
363+
dst = kstrndup(src, maxlen, GFP_KERNEL);
369364
}
370365

371366
return dst;

fs/cifs/cifsencrypt.c

Lines changed: 4 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <linux/random.h>
2323
#include <linux/highmem.h>
2424
#include <linux/fips.h>
25-
#include <crypto/arc4.h>
25+
#include "../cifs_common/arc4.h"
2626
#include <crypto/aead.h>
2727

2828
int __cifs_calc_signature(struct smb_rqst *rqst,
@@ -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.
@@ -780,9 +699,9 @@ calc_seckey(struct cifs_ses *ses)
780699
return -ENOMEM;
781700
}
782701

783-
arc4_setkey(ctx_arc4, ses->auth_key.response, CIFS_SESS_KEY_SIZE);
784-
arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key,
785-
CIFS_CPHTXT_SIZE);
702+
cifs_arc4_setkey(ctx_arc4, ses->auth_key.response, CIFS_SESS_KEY_SIZE);
703+
cifs_arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key,
704+
CIFS_CPHTXT_SIZE);
786705

787706
/* make secondary_key/nonce as session key */
788707
memcpy(ses->auth_key.response, sec_key, CIFS_SESS_KEY_SIZE);

fs/cifs/cifsfs.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ cifs_evict_inode(struct inode *inode)
399399
{
400400
truncate_inode_pages_final(&inode->i_data);
401401
clear_inode(inode);
402-
cifs_fscache_release_inode_cookie(inode);
403402
}
404403

405404
static void
@@ -438,15 +437,9 @@ cifs_show_security(struct seq_file *s, struct cifs_ses *ses)
438437
seq_puts(s, ",sec=");
439438

440439
switch (ses->sectype) {
441-
case LANMAN:
442-
seq_puts(s, "lanman");
443-
break;
444440
case NTLMv2:
445441
seq_puts(s, "ntlmv2");
446442
break;
447-
case NTLM:
448-
seq_puts(s, "ntlm");
449-
break;
450443
case Kerberos:
451444
seq_puts(s, "krb5");
452445
break;
@@ -1755,7 +1748,6 @@ MODULE_DESCRIPTION
17551748
MODULE_VERSION(CIFS_VERSION);
17561749
MODULE_SOFTDEP("ecb");
17571750
MODULE_SOFTDEP("hmac");
1758-
MODULE_SOFTDEP("md4");
17591751
MODULE_SOFTDEP("md5");
17601752
MODULE_SOFTDEP("nls");
17611753
MODULE_SOFTDEP("aes");

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
}

0 commit comments

Comments
 (0)