linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>,
	stable <stable@vger.kernel.org>,
	Florian Echtler <floe@butterbrot.org>,
	David Herrmann <dh.herrmann@gmail.com>,
	Henrik Rydberg <rydberg@euromail.se>
Subject: [PATCH 7/7] Input: sur40 - fix NULL-deref at probe
Date: Mon, 13 Mar 2017 13:35:39 +0100	[thread overview]
Message-ID: <20170313123539.28103-8-johan@kernel.org> (raw)
In-Reply-To: <20170313123539.28103-1-johan@kernel.org>

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer or accessing memory that lie beyond the end of the endpoint
array should a malicious device lack the expected endpoints.

Fixes: bdb5c57f209c ("Input: add sur40 driver for Samsung SUR40 (aka MS
Surface 2.0/Pixelsense)")
Cc: stable <stable@vger.kernel.org>	# 3.13
Cc: Florian Echtler <floe@butterbrot.org>
Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Henrik Rydberg <rydberg@euromail.se>

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/input/touchscreen/sur40.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index aefb6e11f88a..4c0eecae065c 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -527,6 +527,9 @@ static int sur40_probe(struct usb_interface *interface,
 	if (iface_desc->desc.bInterfaceClass != 0xFF)
 		return -ENODEV;
 
+	if (iface_desc->desc.bNumEndpoints < 5)
+		return -ENODEV;
+
 	/* Use endpoint #4 (0x86). */
 	endpoint = &iface_desc->endpoint[4].desc;
 	if (endpoint->bEndpointAddress != TOUCH_ENDPOINT)
-- 
2.12.0

  parent reply	other threads:[~2017-03-13 12:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-13 12:35 [PATCH 0/7] Input: fix NULL-derefs at probe Johan Hovold
2017-03-13 12:35 ` [PATCH 1/7] Input: iforce - fix NULL-deref " Johan Hovold
2017-03-13 12:35 ` [PATCH 2/7] Input: cm109 " Johan Hovold
2017-03-13 12:35 ` [PATCH 3/7] Input: ims-pcu " Johan Hovold
2017-03-13 12:35 ` [PATCH 4/7] Input: yealink " Johan Hovold
2017-03-13 12:35 ` [PATCH 5/7] Input: hanwang " Johan Hovold
2017-03-13 12:35 ` [PATCH 6/7] Input: kbtab " Johan Hovold
2017-03-13 12:35 ` Johan Hovold [this message]
2017-03-13 15:15 ` [PATCH 0/7] Input: fix NULL-derefs " Oliver Neukum
2017-03-13 15:45   ` Johan Hovold
2017-03-16 22:37     ` Dmitry Torokhov
2017-03-17 10:53       ` Johan Hovold
2017-03-17 21:03         ` Dmitry Torokhov
2017-03-18  9:13           ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170313123539.28103-8-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=dh.herrmann@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=floe@butterbrot.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rydberg@euromail.se \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).