]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.10.7/input-iforce-validate-number-of-endpoints-before-using-them.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.10.7 / input-iforce-validate-number-of-endpoints-before-using-them.patch
CommitLineData
90594201
GKH
1From 59cf8bed44a79ec42303151dd014fdb6434254bb Mon Sep 17 00:00:00 2001
2From: Johan Hovold <johan@kernel.org>
3Date: Thu, 16 Mar 2017 11:34:02 -0700
4Subject: Input: iforce - validate number of endpoints before using them
5
6From: Johan Hovold <johan@kernel.org>
7
8commit 59cf8bed44a79ec42303151dd014fdb6434254bb upstream.
9
10Make sure to check the number of endpoints to avoid dereferencing a
11NULL-pointer or accessing memory that lie beyond the end of the endpoint
12array should a malicious device lack the expected endpoints.
13
14Signed-off-by: Johan Hovold <johan@kernel.org>
15Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
16Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17
18---
19 drivers/input/joystick/iforce/iforce-usb.c | 3 +++
20 1 file changed, 3 insertions(+)
21
22--- a/drivers/input/joystick/iforce/iforce-usb.c
23+++ b/drivers/input/joystick/iforce/iforce-usb.c
24@@ -141,6 +141,9 @@ static int iforce_usb_probe(struct usb_i
25
26 interface = intf->cur_altsetting;
27
28+ if (interface->desc.bNumEndpoints < 2)
29+ return -ENODEV;
30+
31 epirq = &interface->endpoint[0].desc;
32 epout = &interface->endpoint[1].desc;
33