Skip to content

Commit 4f97e6a

Browse files
namjaejeongregkh
authored andcommitted
ksmbd: fix slab-out-of-bounds in smb_strndup_from_utf16()
[ Upstream commit a80a486 ] 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(). Cc: [email protected] Reported-by: Xuanzhe Yu <[email protected]> Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent ff2f9c4 commit 4f97e6a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/smb/server/smb2misc.c

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

0 commit comments

Comments
 (0)