Skip to content

Commit 6675184

Browse files
gregkhsmfrench
authored andcommitted
ksmbd: validate EaNameLength in smb2_get_ea()
smb2_get_ea() reads ea_req->EaNameLength from the client request and passes it directly to strncmp() as the comparison length without verifying that the length of the name really is the size of the input buffer received. Fix this up by properly checking the size of the name based on the value received and the overall size of the request, to prevent a later strncmp() call to use the length as a "trusted" size of the buffer. Without this check, uninitialized heap values might be slowly leaked to the client. Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: Steve French <smfrench@gmail.com> Cc: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: Tom Talpey <tom@talpey.com> Cc: linux-cifs@vger.kernel.org Cc: <stable@kernel.org> Assisted-by: gregkh_clanker_t1000 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 1c13763 commit 6675184

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

fs/smb/server/smb2pdu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4717,6 +4717,11 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
47174717

47184718
ea_req = (struct smb2_ea_info_req *)((char *)req +
47194719
le16_to_cpu(req->InputBufferOffset));
4720+
4721+
if (le32_to_cpu(req->InputBufferLength) <
4722+
offsetof(struct smb2_ea_info_req, name) +
4723+
ea_req->EaNameLength)
4724+
return -EINVAL;
47204725
} else {
47214726
/* need to send all EAs, if no specific EA is requested*/
47224727
if (le32_to_cpu(req->Flags) & SL_RETURN_SINGLE_ENTRY)

0 commit comments

Comments
 (0)