All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] HID: core: prevent out-of-bound readings
@ 2016-01-19 11:34 Benjamin Tissoires
  2016-01-19 13:15 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Tissoires @ 2016-01-19 11:34 UTC (permalink / raw)
  To: Jiri Kosina, Dmitry Torokhov, linux-input; +Cc: linux-kernel

Plugging a Logitech DJ receiver with KASAN activated raises a bunch of
out-of-bound readings.

The fields are allocated up to MAX_USAGE, meaning that potentially, we do
not have enough fields to fit the incoming values.
Add checks and silence KASAN.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/hid/hid-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 1532ae6..4f329d4 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1294,6 +1294,7 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
 		/* Ignore report if ErrorRollOver */
 		if (!(field->flags & HID_MAIN_ITEM_VARIABLE) &&
 		    value[n] >= min && value[n] <= max &&
+		    value[n] - min < field->maxusage &&
 		    field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1)
 			goto exit;
 	}
@@ -1306,11 +1307,13 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
 		}
 
 		if (field->value[n] >= min && field->value[n] <= max
+			&& field->value[n] - min < field->maxusage
 			&& field->usage[field->value[n] - min].hid
 			&& search(value, field->value[n], count))
 				hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt);
 
 		if (value[n] >= min && value[n] <= max
+			&& value[n] - min < field->maxusage
 			&& field->usage[value[n] - min].hid
 			&& search(field->value, value[n], count))
 				hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt);
-- 
2.5.0

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

* Re: [PATCH] HID: core: prevent out-of-bound readings
  2016-01-19 11:34 [PATCH] HID: core: prevent out-of-bound readings Benjamin Tissoires
@ 2016-01-19 13:15 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2016-01-19 13:15 UTC (permalink / raw)
  To: Benjamin Tissoires; +Cc: Dmitry Torokhov, linux-input, linux-kernel

On Tue, 19 Jan 2016, Benjamin Tissoires wrote:

> Plugging a Logitech DJ receiver with KASAN activated raises a bunch of
> out-of-bound readings.
> 
> The fields are allocated up to MAX_USAGE, meaning that potentially, we do
> not have enough fields to fit the incoming values.
> Add checks and silence KASAN.
> 
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Applied to for-4.5/upstream-fixes. Thanks,

-- 
Jiri Kosina
SUSE Labs

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

end of thread, other threads:[~2016-01-19 13:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-19 11:34 [PATCH] HID: core: prevent out-of-bound readings Benjamin Tissoires
2016-01-19 13:15 ` Jiri Kosina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.