Received: by 10.192.165.148 with SMTP id m20csp2446543imm; Sun, 22 Apr 2018 07:15:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ZMIF4tcvzcvOQxKBPhPEZ9HjqrmTevjtoWXHtwXUgzI6+HF0micGEvg8h2obyZmPZyS5j X-Received: by 10.99.124.21 with SMTP id x21mr14287283pgc.209.1524406500467; Sun, 22 Apr 2018 07:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524406500; cv=none; d=google.com; s=arc-20160816; b=m1kQGwli/55eUo+pV+zlmTM5fQxCyXen2+WF3bUyOB1u4Z3smT8+cSfiisM85sTh7y ++MxebEvzN5esWp2BgtdyNWAcR3oGjEXBWTUxBrH70wQ0ynjXr23hQnDa3ERol36QlJ2 wqH5KM6kkUNzAZJjj/whxCrI4ZTmEEvGhsolf2abPhnIOPv2TyytlZnqfSbC16Fx98jY gBvCnkAB2NI87TjHAeCRUqC/7TSZ7q7nECBCovtagvtyKPDaEEBeOqwRlEA/0KRF8Rpl PXkdBcFbgr+gvJiNdr9LNOelhBPSZbZMx4bTKTIkWFhjRkZrYHAzhdZ4ZXiWXf1yH5eB nsQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ba04JogxX+b84+dzjJjk0FDO2nXyHJAhcn2CFhlevJk=; b=ErIe4BjQzREJEExtMI8STF14x/86FvZUWDdVMKOLrZxqYhpLSvD79FDYejOMYDlJTg 7KDLT+Ek7Q7cp5S/P6qSIfK+goo0GegxEPaDTqLYs/Qjnmrd6e8HEr3i4/9IlCtZXcpA u2AuKHZJ3jwoWBoDJBsMfLXOdbFHSskK+W3CraoLw9AIW8gDY6b2QxLYIOizet+1jIZw kIpxNpZ/WRLwE7fzSJ6H9y6aQ5PvPe7n2jUIUJXO1Jc0zIbT7QmN22iGj9lS/VCCSlkr UjvdTsDRxSd6E9CXWqFfdYjK5MK8o536wImcuIfHcDwcpZxiHMmSGxak6u446JdgLznN Y/ow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13-v6si9990671pll.416.2018.04.22.07.14.46; Sun, 22 Apr 2018 07:15:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756893AbeDVONn (ORCPT + 99 others); Sun, 22 Apr 2018 10:13:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55852 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756662AbeDVONk (ORCPT ); Sun, 22 Apr 2018 10:13:40 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CB35BCEC; Sun, 22 Apr 2018 14:13:38 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aaron Ma , Jiri Kosina Subject: [PATCH 4.9 29/95] HID: core: Fix size as type u32 Date: Sun, 22 Apr 2018 15:52:58 +0200 Message-Id: <20180422135211.639226612@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aaron Ma commit 6de0b13cc0b4ba10e98a9263d7a83b940720b77a upstream. When size is negative, calling memset will make segment fault. Declare the size as type u32 to keep memset safe. size in struct hid_report is unsigned, fix return type of hid_report_len to u32. Cc: stable@vger.kernel.org Signed-off-by: Aaron Ma Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-core.c | 10 +++++----- include/linux/hid.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1370,7 +1370,7 @@ u8 *hid_alloc_report_buf(struct hid_repo * of implement() working on 8 byte chunks */ - int len = hid_report_len(report) + 7; + u32 len = hid_report_len(report) + 7; return kmalloc(len, flags); } @@ -1435,7 +1435,7 @@ void __hid_request(struct hid_device *hi { char *buf; int ret; - int len; + u32 len; buf = hid_alloc_report_buf(report, GFP_KERNEL); if (!buf) @@ -1461,14 +1461,14 @@ out: } EXPORT_SYMBOL_GPL(__hid_request); -int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, +int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size, int interrupt) { struct hid_report_enum *report_enum = hid->report_enum + type; struct hid_report *report; struct hid_driver *hdrv; unsigned int a; - int rsize, csize = size; + u32 rsize, csize = size; u8 *cdata = data; int ret = 0; @@ -1526,7 +1526,7 @@ EXPORT_SYMBOL_GPL(hid_report_raw_event); * * This is data entry for lower layers. */ -int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) +int hid_input_report(struct hid_device *hid, int type, u8 *data, u32 size, int interrupt) { struct hid_report_enum *report_enum; struct hid_driver *hdrv; --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -801,7 +801,7 @@ extern int hidinput_connect(struct hid_d extern void hidinput_disconnect(struct hid_device *); int hid_set_field(struct hid_field *, unsigned, __s32); -int hid_input_report(struct hid_device *, int type, u8 *, int, int); +int hid_input_report(struct hid_device *, int type, u8 *, u32, int); int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); struct hid_field *hidinput_get_led_field(struct hid_device *hid); unsigned int hidinput_count_leds(struct hid_device *hid); @@ -1106,13 +1106,13 @@ static inline void hid_hw_wait(struct hi * * @report: the report we want to know the length */ -static inline int hid_report_len(struct hid_report *report) +static inline u32 hid_report_len(struct hid_report *report) { /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ return ((report->size - 1) >> 3) + 1 + (report->id > 0); } -int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, +int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size, int interrupt); /* HID quirks API */