From patchwork Thu May 19 19:41:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armando Visconti X-Patchwork-Id: 799712 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 p4JJg82r028429 for ; Thu, 19 May 2011 19:42:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934522Ab1ESTlp (ORCPT ); Thu, 19 May 2011 15:41:45 -0400 Received: from eu1sys200aog109.obsmtp.com ([207.126.144.127]:37349 "EHLO eu1sys200aog109.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934493Ab1ESTlo (ORCPT ); Thu, 19 May 2011 15:41:44 -0400 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob109.postini.com ([207.126.147.11]) with SMTP ID DSNKTdVydVINCqUydlD6x8ylN5V5Gw9KNM+O@postini.com; Thu, 19 May 2011 19:41:44 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 9869DD4; Thu, 19 May 2011 19:41:26 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas4.st.com [10.75.90.69]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5B662471B; Thu, 19 May 2011 19:41:26 +0000 (GMT) Received: from localhost (10.51.110.68) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.2.234.1; Thu, 19 May 2011 21:41:25 +0200 From: Armando Visconti To: Cc: , , Armando Visconti Subject: [PATCH] HID: Fixed a crash in hid_report_raw_event() function. Date: Thu, 19 May 2011 21:41:22 +0200 Message-ID: <1305834082-14888-1-git-send-email-armando.visconti@st.com> X-Mailer: git-send-email 1.7.4 MIME-Version: 1.0 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, 19 May 2011 19:42:08 +0000 (UTC) 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 c3d6626..3e972e3 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1045,6 +1045,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);