From patchwork Wed Jan 10 09:39:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10154649 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F1D5C60231 for ; Wed, 10 Jan 2018 09:39:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5E2A22064 for ; Wed, 10 Jan 2018 09:39:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7A8124603; Wed, 10 Jan 2018 09:39:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 681C022064 for ; Wed, 10 Jan 2018 09:39:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752120AbeAJJjg (ORCPT ); Wed, 10 Jan 2018 04:39:36 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:49998 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751693AbeAJJje (ORCPT ); Wed, 10 Jan 2018 04:39:34 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0A9bCq9176743; Wed, 10 Jan 2018 09:39:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=44KStkTxsdVYU5YKHaZiRTyZTWaEAeaDdNu+BBj28pQ=; b=mMpjlvAkOSKVLVWwv6mWfFBguI6M/pcPxzI9nukDcsd4VpS9j+zITgaaCPqh16q7wOJH rpOZ+u8Qn5xKry7JaXlKGD3xLS7wOMZvF9oNUdaZy07lHYPVC2Bj/ix8eQDf3Wv5UKQA wNL9YWwTJ8heb0+WdhXo8k5gT4SUabsbW6g0t1sObU1vALwho2JAiyWXEUBJbWFYWNFX p4cuX/v9KI4AXwNoxVTfU+DCNqXpDaC5VwR8py5CiRgKGQioQT47IKLt6dY5y99z9f8g pG69+AKPtaYZ7JeOROwkU20K0CjE8ZZZXINquAtDmG245SonYcrp5IvZBidGa0cd+bul 3w== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2fd8jn18d5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2018 09:39:14 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w0A9dBlL010711 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 10 Jan 2018 09:39:12 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w0A9dBWn013827; Wed, 10 Jan 2018 09:39:11 GMT Received: from mwanda (/41.202.241.23) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Jan 2018 01:39:10 -0800 Date: Wed, 10 Jan 2018 12:39:03 +0300 From: Dan Carpenter To: Stefan Achatz Cc: Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() Message-ID: <20180110093903.yyoknoi7oc2cd5iy@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8769 signatures=668652 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=790 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801100134 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We get the "new_profile_index" value from the mouse device when we're handling raw events. Smatch taints it as untrusted data and complains that we need a bounds check. This seems like a reasonable warning otherwise there is a small read beyond the end of the array. Fixes: 0e70f97f257e ("HID: roccat: Add support for Kova[+] mouse") Signed-off-by: Dan Carpenter Acked-by: Silvan Jegen --- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c index 43617fb28b87..317c9c2c0a7c 100644 --- a/drivers/hid/hid-roccat-kovaplus.c +++ b/drivers/hid/hid-roccat-kovaplus.c @@ -37,6 +37,8 @@ static uint kovaplus_convert_event_cpi(uint value) static void kovaplus_profile_activated(struct kovaplus_device *kovaplus, uint new_profile_index) { + if (new_profile_index >= ARRAY_SIZE(kovaplus->profile_settings)) + return; kovaplus->actual_profile = new_profile_index; kovaplus->actual_cpi = kovaplus->profile_settings[new_profile_index].cpi_startup_level; kovaplus->actual_x_sensitivity = kovaplus->profile_settings[new_profile_index].sensitivity_x;