From patchwork Thu Apr 28 09:17:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armando Visconti X-Patchwork-Id: 738871 X-Patchwork-Delegate: jikos@jikos.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3S9HD9G025536 for ; Thu, 28 Apr 2011 09:17:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750817Ab1D1JRN (ORCPT ); Thu, 28 Apr 2011 05:17:13 -0400 Received: from eu1sys200aog117.obsmtp.com ([207.126.144.143]:49217 "EHLO eu1sys200aog117.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750755Ab1D1JRM (ORCPT ); Thu, 28 Apr 2011 05:17:12 -0400 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob117.postini.com ([207.126.147.11]) with SMTP ID DSNKTbkwl+LSuZ4gjycHQlayHRuDg3tOfwsu@postini.com; Thu, 28 Apr 2011 09:17:12 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 358F219B for ; Thu, 28 Apr 2011 09:17:11 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas6.st.com [10.75.90.73]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 02B49200F for ; Thu, 28 Apr 2011 09:17:10 +0000 (GMT) Received: from armando.linux.vnet (10.51.110.146) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.2.234.1; Thu, 28 Apr 2011 11:17:10 +0200 Message-ID: <4DB93096.6090601@st.com> Date: Thu, 28 Apr 2011 11:17:10 +0200 From: Armando Visconti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.9 MIME-Version: 1.0 To: Subject: BUG: hid_report_raw_event() crash References: <4DB92D93.7090602@st.com> <4DB92F71.5070900@st.com> In-Reply-To: <4DB92F71.5070900@st.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 28 Apr 2011 09:17:14 +0000 (UTC) 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 From 4e3af7356b4973f8733669ba4c201e61b36e998a Mon Sep 17 00:00:00 2001 From: Armando Visconti 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 --- 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);