linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* BUG: hid_report_raw_event() crash
@ 2011-04-28  9:04 Armando Visconti
  2011-04-28  9:12 ` Armando Visconti
  0 siblings, 1 reply; 3+ messages in thread
From: Armando Visconti @ 2011-04-28  9:04 UTC (permalink / raw)
  To: linux-input

[-- Attachment #1: Type: text/plain, Size: 652 bytes --]

Hello,

I'm using a particular multi touch screen module, which is the
TP 72055 from Data Modul. They have tested it only for Win7.

Using it I have found a crash in hid_report_raw_event() on kernel
2.6.37, but I believe is there also in latest one.

Debugging the issue it seems that it is caused by the fact that
TP72055 module issues a hid report with a size equals to 0. The rsize
value gets
set to 536870912 and Linux is crashing in the memset because the
value is too big.

I think a proper checking on rsize must be made to avoid cases like that.
I'm attaching the simple patch I made.

Pls let me know if the fix makes sense or not.

THx,
Arm


[-- Attachment #2: 0001-HID-Fixed-a-crash-in-hid_report_raw_event-function.patch --]
[-- Type: text/plain, Size: 1081 bytes --]

>From 4e3af7356b4973f8733669ba4c201e61b36e998a Mon Sep 17 00:00:00 2001
From: Armando Visconti <armando.visconti@st.com>
Date: Tue, 26 Apr 2011 17:07:54 +0200
Subject: [PATCH] HID: Fixed a crash in hid_report_raw_event() function.

I'm using a Data Modul EasyTouch USB multitouch controller, which is
issuing a hid report with a size equals to 0. The rsize value gets
set to 536870912 and Linux is crashing in the memset because the
value is too big.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
---
 drivers/hid/hid-core.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index b144b38..c5efca3 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1024,6 +1024,9 @@ void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
 
 	rsize = ((report->size - 1) >> 3) + 1;
 
+	if (rsize > HID_MAX_BUFFER_SIZE)
+		rsize = HID_MAX_BUFFER_SIZE;
+
 	if (csize < rsize) {
 		dbg_hid("report %d is too short, (%d < %d)\n", report->id,
 				csize, rsize);
-- 
1.7.4


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

* BUG: hid_report_raw_event() crash
  2011-04-28  9:04 BUG: hid_report_raw_event() crash Armando Visconti
@ 2011-04-28  9:12 ` Armando Visconti
  2011-04-28  9:17   ` Armando Visconti
  0 siblings, 1 reply; 3+ messages in thread
From: Armando Visconti @ 2011-04-28  9:12 UTC (permalink / raw)
  To: linux-input

[-- Attachment #1: Type: text/plain, Size: 652 bytes --]

Hello,

I'm using a particular multi touch screen module, which is the
TP 72055 from Data Modul. They have tested it only for Win7.

Using it I have found a crash in hid_report_raw_event() on kernel
2.6.37, but I believe is there also in latest one.

Debugging the issue it seems that it is caused by the fact that
TP72055 module issues a hid report with a size equals to 0. The rsize
value gets
set to 536870912 and Linux is crashing in the memset because the
value is too big.

I think a proper checking on rsize must be made to avoid cases like that.
I'm attaching the simple patch I made.

Pls let me know if the fix makes sense or not.

THx,
Arm


[-- Attachment #2: 0001-HID-Fixed-a-crash-in-hid_report_raw_event-function.patch --]
[-- Type: text/plain, Size: 1081 bytes --]

>From 4e3af7356b4973f8733669ba4c201e61b36e998a Mon Sep 17 00:00:00 2001
From: Armando Visconti <armando.visconti@st.com>
Date: Tue, 26 Apr 2011 17:07:54 +0200
Subject: [PATCH] HID: Fixed a crash in hid_report_raw_event() function.

I'm using a Data Modul EasyTouch USB multitouch controller, which is
issuing a hid report with a size equals to 0. The rsize value gets
set to 536870912 and Linux is crashing in the memset because the
value is too big.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
---
 drivers/hid/hid-core.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index b144b38..c5efca3 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1024,6 +1024,9 @@ void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
 
 	rsize = ((report->size - 1) >> 3) + 1;
 
+	if (rsize > HID_MAX_BUFFER_SIZE)
+		rsize = HID_MAX_BUFFER_SIZE;
+
 	if (csize < rsize) {
 		dbg_hid("report %d is too short, (%d < %d)\n", report->id,
 				csize, rsize);
-- 
1.7.4


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

* BUG: hid_report_raw_event() crash
  2011-04-28  9:12 ` Armando Visconti
@ 2011-04-28  9:17   ` Armando Visconti
  0 siblings, 0 replies; 3+ messages in thread
From: Armando Visconti @ 2011-04-28  9:17 UTC (permalink / raw)
  To: linux-input

[-- Attachment #1: Type: text/plain, Size: 653 bytes --]

Hello,

I'm using a particular multi touch screen module, which is the
TP 72055 from Data Modul. They have tested it only for Win7.

Using it I have found a crash in hid_report_raw_event() on kernel
2.6.37, but I believe is there also in latest one.

Debugging the issue it seems that it is caused by the fact that
TP72055 module issues a hid report with a size equals to 0. The rsize
value gets set to 536870912 and Linux is crashing in the memset because 
the value is too big.

I think a proper checking on rsize must be made to avoid cases like that.
I'm attaching the simple patch I made.

Pls let me know if the fix makes sense or not.

THx,
Arm


[-- Attachment #2: 0001-HID-Fixed-a-crash-in-hid_report_raw_event-function.patch --]
[-- Type: text/plain, Size: 1081 bytes --]

>From 4e3af7356b4973f8733669ba4c201e61b36e998a Mon Sep 17 00:00:00 2001
From: Armando Visconti <armando.visconti@st.com>
Date: Tue, 26 Apr 2011 17:07:54 +0200
Subject: [PATCH] HID: Fixed a crash in hid_report_raw_event() function.

I'm using a Data Modul EasyTouch USB multitouch controller, which is
issuing a hid report with a size equals to 0. The rsize value gets
set to 536870912 and Linux is crashing in the memset because the
value is too big.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
---
 drivers/hid/hid-core.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index b144b38..c5efca3 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1024,6 +1024,9 @@ void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
 
 	rsize = ((report->size - 1) >> 3) + 1;
 
+	if (rsize > HID_MAX_BUFFER_SIZE)
+		rsize = HID_MAX_BUFFER_SIZE;
+
 	if (csize < rsize) {
 		dbg_hid("report %d is too short, (%d < %d)\n", report->id,
 				csize, rsize);
-- 
1.7.4


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

end of thread, other threads:[~2011-04-28  9:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-28  9:04 BUG: hid_report_raw_event() crash Armando Visconti
2011-04-28  9:12 ` Armando Visconti
2011-04-28  9:17   ` Armando Visconti

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