Received: by 10.192.165.148 with SMTP id m20csp2472252imm; Sun, 22 Apr 2018 07:45:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx49BygX6P+jXdU2oudgTZ7QvbR3A3BxOLoWI87tySzb+r6qtAhvXvVaXZ2+pTyFAoC3tuHMa X-Received: by 10.99.111.130 with SMTP id k124mr13989563pgc.301.1524408343779; Sun, 22 Apr 2018 07:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524408343; cv=none; d=google.com; s=arc-20160816; b=kgJY4SOfIuw4IruQcWjlkj8dJFqjZOYO7wqi7WMhUlpSCOCtOaQbfMSSVOUKkuEubc Uqw9iUdddhWTPfgGMuJr8Fv7w4D0nhTKbef1NrRLK4sId22F5G6yKlYhMUVAmshpDV9Q eDqfLY5A7yfhES0mHXH6hWt5kI84z/SrkCu34gGxYJdwgyIndiSjDMbPwGy16J9oN3mr Dm2nMFXnt+BfnnTPX7E+OEAT8whAwhKOS8OJpEZA5Ow4q8bKJp+vlS2EUELlDECL8Mgj UZdRjwvwQUmXcjMpr98mXt8YAbs0aLjTeSUl4wq8lWRAG5EIwx/ZrfwqAgJ0lWUXMJcG zCjQ== 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=UPvFis9orJnTDvVTe9gIyKX46fcebxZjSA0s6uHtNR4=; b=xwjaR6/tdIiYnX+El4DK/t2Zw2QjqpxqaMij5XcZweWsAxsWm0Qh4BzIuG2MKBB6rY WvIrro+yFZ5Lzdm72SdK/ygUkJeGDnuIC060LmDCnGCFRJElITMV18PnQDbaqe8G014v TumJJLsMEn1b5edt0bzH+mEv3ejGgTGfnhiyNA/1OTgHIIYy5RLgTWg0MpnQN3/ayrks TdGNCGrpvYh8DtKB6XjVDR1hnNvNxTRGgMh8yjlsjDtq7NbBuKFLK1Rfz3c1lw+YAwg0 yN6S5PyWkgofHCxXB2dCtpBAkt9Q+NONyFlZan+nfn985+UDoot3EkeWZnD+7CRAIq6W pRKw== 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 r3-v6si11215493pli.324.2018.04.22.07.45.29; Sun, 22 Apr 2018 07:45:43 -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 S1757241AbeDVOoT (ORCPT + 99 others); Sun, 22 Apr 2018 10:44:19 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57922 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932386AbeDVORE (ORCPT ); Sun, 22 Apr 2018 10:17:04 -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 55201BA0; Sun, 22 Apr 2018 14:17:03 +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.4 44/97] HID: core: Fix size as type u32 Date: Sun, 22 Apr 2018 15:53:22 +0200 Message-Id: <20180422135307.777764798@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135304.577223025@linuxfoundation.org> References: <20180422135304.577223025@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.4-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 @@ -1331,7 +1331,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); } @@ -1396,7 +1396,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) @@ -1422,14 +1422,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; @@ -1487,7 +1487,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 @@ -793,7 +793,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); @@ -1098,13 +1098,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 */