Received: by 10.213.65.68 with SMTP id h4csp2114218imn; Sun, 8 Apr 2018 20:04:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+yVxbp2t9hKFAjGy9TnJuqTg3xIx8tklJ/XgSX1ukaGrGXs76FhxB+BKoTsAApSVwY801J X-Received: by 2002:a17:902:5501:: with SMTP id f1-v6mr36372173pli.50.1523243064806; Sun, 08 Apr 2018 20:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243064; cv=none; d=google.com; s=arc-20160816; b=Gp4/DdHeYbyHG2sLtW4djK9EV767trr8vphTrFXvIdNW1HXDQ4DNHR+0W3+d09r/PO WAiEmiOtLvg7zlNBHB+P6kxiNeRDnqKrPMoDfbtDxoY09pRzg1CFNp6ZFfb/pHZK6DEQ OcW3tjq+22Z9zP79GrLflWOPJdsv6I6JbmNIY1k4NE5Lf8HvCQpbYhR/ZQ3J5dpTkPGT NtBnYymSC9KmryftYQP2gYA6G7U8WJszwuiUmNcMKgn9b8DRpMPizvuH0DX69fXgi/in mCWHgNCvlAHTj51qKvsG4vfm/8eavYyK1lgXI5I/1byxEynsKeupPukWeFp6P7waXeGs crzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=auDUzu2A1+Q1EPnzBc/Ut3+v2gKFBvC+XIkihtGDw6c=; b=MdbbGp/QOlNlmjdamXKl2yuUjUQ1qzpuvyNCi9UAqAlMgqZ5NREjHvbzuT9Elax/4k EUSN5k9ywFh2SG5fbcfgZSjBq47bHCTsdlF+SLft+2xwjKqrPtwySUOPXAryuq09mAM/ qdcLT4zS5Z2r+xsR24eMh5YrxHk97h2oZvj+zU/OG0TvFsPqcqom9Plrr7EBe2ppAoye J7FiLw01rZ1g3PlSxkdVAvyVuB20zqc57DIt/Cn011Ib0q00kITcHR7YKooNlABAAgLA 2bDZVWj4m7AqG8wPcjnphHnPcsCpWBWyAPXFvsj6NWoQEESXmm/zFaG7Gl+lhOcis9HB eCTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=MTNqfVXx; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m30-v6si16129892pli.210.2018.04.08.20.03.48; Sun, 08 Apr 2018 20:04:24 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=MTNqfVXx; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932327AbeDIAdr (ORCPT + 99 others); Sun, 8 Apr 2018 20:33:47 -0400 Received: from mail-by2nam01on0111.outbound.protection.outlook.com ([104.47.34.111]:45024 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932313AbeDIAdo (ORCPT ); Sun, 8 Apr 2018 20:33:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=auDUzu2A1+Q1EPnzBc/Ut3+v2gKFBvC+XIkihtGDw6c=; b=MTNqfVXxk/lrFbu+L/C4g3qbNl3SQJ4LyxQA/oG1DLfGrQAQk1e5h7vaED+NnOM4wMTHDpg+N0o7haoinWc3iKCTokuFiCVhz/LWGXIcsTBfni6vUVjZWF92TGwy+iKtsF8nTfW6dUHlYVUqxFNtbnSCgDVWNx4tY2A4gtduzzU= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0998.namprd21.prod.outlook.com (52.132.133.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.0; Mon, 9 Apr 2018 00:33:42 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:33:42 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Dan Carpenter , Jiri Kosina , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 243/293] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() Thread-Topic: [PATCH AUTOSEL for 4.9 243/293] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() Thread-Index: AQHTz5lX1qcuKrtR8ECZhExPWNCr0w== Date: Mon, 9 Apr 2018 00:26:02 +0000 Message-ID: <20180409002239.163177-243-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0998;7:o4ZDaPo5ofmYdwPcX542XViGGqf4Shsurd625JimLRBrndsdK9cTIA7NeG5OOJ2pL6I4O4pFH1xjrudyLduGT2VyWAHxMX0FPA+QpsYWjXWFtSzOtOQdUedZSCmn3vLyEcd3F6fufmqOKZHDgnLfIiUWEmz8VC5fsrmNKJAl4VoTorfb12C5VDG/gAgtP0lC3Jxs9K5h3NaO/VcVOGt3XwYgAk+RZO4UtkDtmTfcIyoJmuBHQQKm4+lX7BId5zVU;20:oW2wJyMz5sXwWuNcj5vNq/dqfBdVVsvEPIGXTsDcJD3LyUoVgdnLatbV85hK14xNnQeuPF3D/mAJ2y6r1+31PHNHTKmIppItKSLEsV/5vsoZ7DCuFvUGTO3ZxcyO5b1YyOA3NjdkLs5zwq+3p7r7I8Xlp78SkcooZxInQpW0gHc= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 067c31c7-3ed9-4e37-0834-08d59db18bd3 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0998; x-ms-traffictypediagnostic: DM5PR2101MB0998: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158)(146099531331640); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB0998;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0998; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39380400002)(376002)(396003)(366004)(39860400002)(189003)(199004)(25786009)(59450400001)(105586002)(14454004)(76176011)(68736007)(2906002)(316002)(97736004)(8676002)(86612001)(3660700001)(3280700002)(102836004)(6116002)(4326008)(8936002)(36756003)(22452003)(81166006)(81156014)(54906003)(6506007)(10090500001)(2501003)(6512007)(186003)(6666003)(3846002)(486006)(5660300001)(26005)(7736002)(5250100002)(305945005)(99286004)(2900100001)(110136005)(1076002)(6436002)(53936002)(106356001)(575784001)(107886003)(72206003)(86362001)(476003)(446003)(66066001)(11346002)(478600001)(10290500003)(2616005)(6486002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0998;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: UQTwPVZSLxQU9GHKeqCoVob4xAxdS7UEub21d4ARPnZcvDabhknkSvNXSdCZ67qhuazM0HAUNk34EN8lBRHo35qhFg6Mm0aE1bBpAjHNSsg/E1udbvB4htl0n1L2gPo5GTTZOkPEC/oTm7tgJjygn0c4Tl0dBXGkWJblLnIg7vQyMokf6xeg49Rj3JdsLkRuZHUpy/bYGHY+kQubtSMbMYRWKaf1mrQavPpeQ2iSJm9Um/c301yrwDc12zW7Rf7KAY8YiZQgYI0AhM5Wlt2e1lYKLBEV915j6CulksGWUIS2o3NuIIipHnljcxaEtV0MWXVdTq1HgzoS+0Q2K6sRGnTgxFhzIOlSe5BEbM5ZaSraLFhcLGHv34imAfDMFUasw6tTv/pUjZJqgbeiOkb5wdPg9PlaTE5ijkUud85JJk0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 067c31c7-3ed9-4e37-0834-08d59db18bd3 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:26:02.7224 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0998 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 7ad81482cad67cbe1ec808490d1ddfc420c42008 ] 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 Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-roccat-kovaplus.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kov= aplus.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 >=3D ARRAY_SIZE(kovaplus->profile_settings)) + return; kovaplus->actual_profile =3D new_profile_index; kovaplus->actual_cpi =3D kovaplus->profile_settings[new_profile_index].cp= i_startup_level; kovaplus->actual_x_sensitivity =3D kovaplus->profile_settings[new_profile= _index].sensitivity_x; --=20 2.15.1