Skip to content

Commit 4dfa07e

Browse files
committed
ksmbd: fix slab-out-of-bounds in smb_strndup_from_utf16()
If ->NameOffset of smb2_create_req is smaller than Buffer offset of smb2_create_req, slab-out-of-bounds read can happen from smb2_open. This patch set the minimum value of the name offset to the buffer offset to validate name length of smb2_create_req(). Reported-by: Xuanzhe Yu <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent dd996a3 commit 4dfa07e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

smb2misc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ static int smb2_get_data_area_len(unsigned int *off, unsigned int *len,
108108
case SMB2_CREATE:
109109
{
110110
unsigned short int name_off =
111-
le16_to_cpu(((struct smb2_create_req *)hdr)->NameOffset);
111+
max_t(unsigned short int,
112+
le16_to_cpu(((struct smb2_create_req *)hdr)->NameOffset),
113+
offsetof(struct smb2_create_req, Buffer));
114+
112115
unsigned short int name_len =
113116
le16_to_cpu(((struct smb2_create_req *)hdr)->NameLength);
114117

0 commit comments

Comments
 (0)