Skip to content

Commit 40c18f3

Browse files
committed
Merge tag '6.2-rc3-ksmbd-server-fixes' of git://git.samba.org/ksmbd
Pull ksmb server fixes from Steve French: - fix possible infinite loop in socket handler - fix possible panic in ntlmv2 authentication - fix error handling on tree connect * tag '6.2-rc3-ksmbd-server-fixes' of git://git.samba.org/ksmbd: ksmbd: fix infinite loop in ksmbd_conn_handler_loop() ksmbd: check nt_len to be at least CIFS_ENCPWD_SIZE in ksmbd_decode_ntlmssp_auth_blob ksmbd: send proper error response in smb2_tree_connect()
2 parents 526970b + 83dcedd commit 40c18f3

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

fs/ksmbd/auth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob,
322322
dn_off = le32_to_cpu(authblob->DomainName.BufferOffset);
323323
dn_len = le16_to_cpu(authblob->DomainName.Length);
324324

325-
if (blob_len < (u64)dn_off + dn_len || blob_len < (u64)nt_off + nt_len)
325+
if (blob_len < (u64)dn_off + dn_len || blob_len < (u64)nt_off + nt_len ||
326+
nt_len < CIFS_ENCPWD_SIZE)
326327
return -EINVAL;
327328

328329
/* TODO : use domain name that imported from configuration file */

fs/ksmbd/connection.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,12 @@ int ksmbd_conn_handler_loop(void *p)
316316

317317
/* 4 for rfc1002 length field */
318318
size = pdu_size + 4;
319-
conn->request_buf = kvmalloc(size, GFP_KERNEL);
319+
conn->request_buf = kvmalloc(size,
320+
GFP_KERNEL |
321+
__GFP_NOWARN |
322+
__GFP_NORETRY);
320323
if (!conn->request_buf)
321-
continue;
324+
break;
322325

323326
memcpy(conn->request_buf, hdr_buf, sizeof(hdr_buf));
324327
if (!ksmbd_smb_request(conn))

fs/ksmbd/smb2pdu.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,13 +1928,13 @@ int smb2_tree_connect(struct ksmbd_work *work)
19281928
if (conn->posix_ext_supported)
19291929
status.tree_conn->posix_extensions = true;
19301930

1931-
out_err1:
19321931
rsp->StructureSize = cpu_to_le16(16);
1932+
inc_rfc1001_len(work->response_buf, 16);
1933+
out_err1:
19331934
rsp->Capabilities = 0;
19341935
rsp->Reserved = 0;
19351936
/* default manual caching */
19361937
rsp->ShareFlags = SMB2_SHAREFLAG_MANUAL_CACHING;
1937-
inc_rfc1001_len(work->response_buf, 16);
19381938

19391939
if (!IS_ERR(treename))
19401940
kfree(treename);
@@ -1967,6 +1967,9 @@ int smb2_tree_connect(struct ksmbd_work *work)
19671967
rsp->hdr.Status = STATUS_ACCESS_DENIED;
19681968
}
19691969

1970+
if (status.ret != KSMBD_TREE_CONN_STATUS_OK)
1971+
smb2_set_err_rsp(work);
1972+
19701973
return rc;
19711974
}
19721975

fs/ksmbd/transport_tcp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ static int ksmbd_tcp_readv(struct tcp_transport *t, struct kvec *iov_orig,
295295
struct msghdr ksmbd_msg;
296296
struct kvec *iov;
297297
struct ksmbd_conn *conn = KSMBD_TRANS(t)->conn;
298+
int max_retry = 2;
298299

299300
iov = get_conn_iovec(t, nr_segs);
300301
if (!iov)
@@ -321,9 +322,11 @@ static int ksmbd_tcp_readv(struct tcp_transport *t, struct kvec *iov_orig,
321322
} else if (conn->status == KSMBD_SESS_NEED_RECONNECT) {
322323
total_read = -EAGAIN;
323324
break;
324-
} else if (length == -ERESTARTSYS || length == -EAGAIN) {
325+
} else if ((length == -ERESTARTSYS || length == -EAGAIN) &&
326+
max_retry) {
325327
usleep_range(1000, 2000);
326328
length = 0;
329+
max_retry--;
327330
continue;
328331
} else if (length <= 0) {
329332
total_read = -EAGAIN;

0 commit comments

Comments
 (0)