Conversation
935ba12 to
94d95ac
Compare
auth.c
Outdated
| * @pw_buf: NTLM challenge response | ||
| * @passkey: user password | ||
| * @pw_len: buffer length | ||
| * @cryptkey: buffer length |
There was a problem hiding this comment.
- * @cryptkey: buffer length
+ * @cryptkey: server challenge
|
I have applied 3 patches first. I need more time to review "ksmbd: smb1: add buffer validation" patch. |
80f76a4 to
cdd2c68
Compare
598c4b4 to
9ef42e9
Compare
|
@mmakassikis Sorry for checking "ksmbd: smb1: add buffer validation" patch. I will check it on weekend. |
Okay, I will review this patch on weekend. |
smb1pdu.c
Outdated
| pr_err("Unable to strdup() treename or devtype uid %d\n", | ||
| rsp_hdr->Uid); | ||
| offset += offsetof(struct smb_com_tconx_req, Password); | ||
| offset += le16_to_cpu(req->PasswordLength); |
There was a problem hiding this comment.
Have you tested if req->PasswordLength is zero ?
There was a problem hiding this comment.
If req->PasswordLength is zero, offset is unchanged (incidentally, the current code works because req->PasswordLength == le16_to_cpu(req->PasswordLength)).
I don't see what problems can arise with req->PasswordLength.
smb1pdu.c
Outdated
| sz = le16_to_cpu(req->SecurityBlobLength); | ||
|
|
||
| if (offsetof(struct smb_com_session_setup_req, SecurityBlob) + sz > | ||
| get_rfc1002_len(req)) { |
There was a problem hiding this comment.
This check can be moved to smb1misc.c ?
|
@mmakassikis When I checked smb1 buffer validation patch, You need to move some of validation codes to smb1misc.c. I think that you can check codes in smb2misc.c |
| struct andx_block *next; | ||
|
|
||
| /* AndXOffset does not include 4 byte RFC1002 header */ | ||
| len -= 4; |
There was a problem hiding this comment.
Does the "len" include 4-byte RFC1002 header?
There was a problem hiding this comment.
buf is the full request (RFC1002 header, followed by SMB2 header and payload). len should those 4 bytes.
The code here is correct, but the caller code is wrong as it uses get_rfc1002_len() which is the buffer length minus 4.
This mistake is present in most if not all changes in this patch.
smb1pdu.c
Outdated
| } | ||
|
|
||
| offset += oldname_len + 2; | ||
| if (offset > maxlen) { |
There was a problem hiding this comment.
instead of offset > maxlen, offset >= maxlen?
There was a problem hiding this comment.
Yes. Actually, I thought it was ok as we passed a calculated length to smb_get_name(), but if the request is malformed, it's possible to have offset > maxlen, in which case the negative "maxlen - offset" will cause an infinite loop in smb_utf16_bytes().
I will update the patch to check offset >= maxlen before calling smb_get_name().
smb1pdu.c
Outdated
| setup_bytes_count = 2 * req->SetupCount; | ||
|
|
||
| maxlen = get_rfc1002_len(req); | ||
| offset = offsetof(struct smb_com_trans_req, Data); |
There was a problem hiding this comment.
Doesn't 1-byte, smb_com_trans_req.Data[1] need to be considered?
There was a problem hiding this comment.
I don't understand.
Currently, the code parses up to 256 bytes starting from req->Data + setup_bytes_count. My change initializes the offset to req->Data. Whether the Data field is Data[0] or Data[1] doesn't matter, no ?
d055654 to
7202068
Compare
c683c7d to
04bf112
Compare
buf_len is never used anywhere. Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
- Unset spnego bit in SMB negotiate response. - Include NativeOS / Native LAN Manager / Primary Domain fields in session setup response. Without these, smbclient fails with NT_STATUS_BUFFER_TOO_SMALL. Tested with smbclient: smbclient //127.0.0.1/testshare -U user%password \ --option "client min protocol = NT1" \ --option "client use spnego = no" \ -m NT1 Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
87d3bda to
a9a2348
Compare
flock is leaked in an error happens before smb_lock_init(). Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
Many functions assume the client sends well formed packets, or are optimistic about the buffer length (using PATH_MAX or a fixed '256' value) instead of the actual length. The pattern followed to fix this boils down to extracting the total buffer length and calculate how much data has been consumed. Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
a9a2348 to
cff4b20
Compare
|
Updated "ksmbd: smb1: Fix resource leak in smb_locking_andx()" as there were other paths were flock was leaked |
|
@mmakassikis I have applied 4 patches first. Could you please tell me how you test "ksmbd: smb1: add buffer validation" patch ? and this patch was already applied to your product ? |
|
The buffer validation patch has not yet been applied for our product. The changes themselves are quite repetitive but it's easy to make mistakes / forget a check (as shown by the previous version of the patch that you and Hyunchul reviewed). An extra pair of eyes is always welcome. I tested the patchset manually for the most part (which is how I saw non-spnego session setup was broken). I tested the following operations with smbclient / cifs.ko:
|
|
@mmakassikis Okay, Let me check it:) Thanks! |
2fb0a29 to
cdc5e9b
Compare
fa0ee90 to
76139ec
Compare
e0e6d38 to
fe3d6cd
Compare
5a8106d to
eccccf4
Compare
88eefd8 to
ba30fd2
Compare
A few fixes SMB1 fixes:
The first 3 ones small fixes. The last one is big, but it is essentially the same pattern repeated over and over again.
I tried sending to the linux-cifsd-devel list, but it looks like the project has been deleted from sourceforge.