linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] HID: magicmouse: sanity check report size in raw_event() callback
@ 2014-08-27  7:12 Jiri Kosina
  2014-08-27  7:13 ` [PATCH 2/2] HID: picolcd: " Jiri Kosina
  2014-08-27 13:54 ` [PATCH 1/2] HID: magicmouse: " Benjamin Tissoires
  0 siblings, 2 replies; 7+ messages in thread
From: Jiri Kosina @ 2014-08-27  7:12 UTC (permalink / raw)
  To: linux-input; +Cc: linux-kernel

The report passed to us from transport driver could potentially be 
arbitrarily large, therefore we better sanity-check it so that 
magicmouse_emit_touch() gets only valid values of raw_id.

Cc: stable@vger.kernel.org
Reported-by: Steven Vittitoe <scvitti@google.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
 drivers/hid/hid-magicmouse.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index ecc2cbf..29a74c1 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -290,6 +290,11 @@ static int magicmouse_raw_event(struct hid_device *hdev,
 		if (size < 4 || ((size - 4) % 9) != 0)
 			return 0;
 		npoints = (size - 4) / 9;
+		if (npoints > 15) {
+			hid_warn(hdev, "invalid size value (%d) for TRACKPAD_REPORT_ID\n",
+					size);
+			return 0;
+		}
 		msc->ntouches = 0;
 		for (ii = 0; ii < npoints; ii++)
 			magicmouse_emit_touch(msc, ii, data + ii * 9 + 4);
@@ -307,6 +312,11 @@ static int magicmouse_raw_event(struct hid_device *hdev,
 		if (size < 6 || ((size - 6) % 8) != 0)
 			return 0;
 		npoints = (size - 6) / 8;
+		if (npoints > 15) {
+			hid_warn(hdev, "invalid size value (%d) for MOUSE_REPORT_ID\n",
+					size);
+			return 0;
+		}
 		msc->ntouches = 0;
 		for (ii = 0; ii < npoints; ii++)
 			magicmouse_emit_touch(msc, ii, data + ii * 8 + 6);
-- 
1.9.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-28  5:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-27  7:12 [PATCH 1/2] HID: magicmouse: sanity check report size in raw_event() callback Jiri Kosina
2014-08-27  7:13 ` [PATCH 2/2] HID: picolcd: " Jiri Kosina
2014-08-27  8:13   ` Bruno Prémont
2014-08-27  8:25     ` Jiri Kosina
2014-08-27 21:32       ` Jiri Kosina
2014-08-28  5:57         ` Bruno Prémont
2014-08-27 13:54 ` [PATCH 1/2] HID: magicmouse: " Benjamin Tissoires

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).