Skip to content

Commit a75cb86

Browse files
committed
Merge tag 'v7.0-rc1-ksmbd-server-fixes' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: - auth security improvement - fix potential buffer overflow in smbdirect negotiation * tag 'v7.0-rc1-ksmbd-server-fixes' of git://git.samba.org/ksmbd: ksmbd: fix signededness bug in smb_direct_prepare_negotiation() ksmbd: Compare MACs in constant time
2 parents 69062f2 + 6b4f875 commit a75cb86

4 files changed

Lines changed: 9 additions & 5 deletions

File tree

fs/smb/server/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ config SMB_SERVER
1313
select CRYPTO_LIB_MD5
1414
select CRYPTO_LIB_SHA256
1515
select CRYPTO_LIB_SHA512
16+
select CRYPTO_LIB_UTILS
1617
select CRYPTO_CMAC
1718
select CRYPTO_AEAD2
1819
select CRYPTO_CCM

fs/smb/server/auth.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <crypto/aead.h>
1616
#include <crypto/md5.h>
1717
#include <crypto/sha2.h>
18+
#include <crypto/utils.h>
1819
#include <linux/random.h>
1920
#include <linux/scatterlist.h>
2021

@@ -165,7 +166,8 @@ int ksmbd_auth_ntlmv2(struct ksmbd_conn *conn, struct ksmbd_session *sess,
165166
ntlmv2_rsp, CIFS_HMAC_MD5_HASH_SIZE,
166167
sess->sess_key);
167168

168-
if (memcmp(ntlmv2->ntlmv2_hash, ntlmv2_rsp, CIFS_HMAC_MD5_HASH_SIZE) != 0)
169+
if (crypto_memneq(ntlmv2->ntlmv2_hash, ntlmv2_rsp,
170+
CIFS_HMAC_MD5_HASH_SIZE))
169171
return -EINVAL;
170172
return 0;
171173
}

fs/smb/server/smb2pdu.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright (C) 2018 Samsung Electronics Co., Ltd.
55
*/
66

7+
#include <crypto/utils.h>
78
#include <linux/inetdevice.h>
89
#include <net/addrconf.h>
910
#include <linux/syscalls.h>
@@ -8880,7 +8881,7 @@ int smb2_check_sign_req(struct ksmbd_work *work)
88808881
ksmbd_sign_smb2_pdu(work->conn, work->sess->sess_key, iov, 1,
88818882
signature);
88828883

8883-
if (memcmp(signature, signature_req, SMB2_SIGNATURE_SIZE)) {
8884+
if (crypto_memneq(signature, signature_req, SMB2_SIGNATURE_SIZE)) {
88848885
pr_err("bad smb2 signature\n");
88858886
return 0;
88868887
}
@@ -8968,7 +8969,7 @@ int smb3_check_sign_req(struct ksmbd_work *work)
89688969
if (ksmbd_sign_smb3_pdu(conn, signing_key, iov, 1, signature))
89698970
return 0;
89708971

8971-
if (memcmp(signature, signature_req, SMB2_SIGNATURE_SIZE)) {
8972+
if (crypto_memneq(signature, signature_req, SMB2_SIGNATURE_SIZE)) {
89728973
pr_err("bad smb2 signature\n");
89738974
return 0;
89748975
}

fs/smb/server/transport_rdma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,9 +2540,9 @@ static int smb_direct_prepare(struct ksmbd_transport *t)
25402540
goto put;
25412541

25422542
req = (struct smbdirect_negotiate_req *)recvmsg->packet;
2543-
sp->max_recv_size = min_t(int, sp->max_recv_size,
2543+
sp->max_recv_size = min_t(u32, sp->max_recv_size,
25442544
le32_to_cpu(req->preferred_send_size));
2545-
sp->max_send_size = min_t(int, sp->max_send_size,
2545+
sp->max_send_size = min_t(u32, sp->max_send_size,
25462546
le32_to_cpu(req->max_receive_size));
25472547
sp->max_fragmented_send_size =
25482548
le32_to_cpu(req->max_fragmented_size);

0 commit comments

Comments
 (0)