Received: by 10.213.65.68 with SMTP id h4csp2202627imn; Sun, 8 Apr 2018 22:24:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx49bl5RTLvkb4biRuhxfnu3MDQ8x4pQ778e/+pv2L64ZLpzlQG9asmXSZ/zXfNAANGX5iuKQ X-Received: by 10.99.60.6 with SMTP id j6mr23477421pga.73.1523251444601; Sun, 08 Apr 2018 22:24:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523251444; cv=none; d=google.com; s=arc-20160816; b=0OK1lE5GgINjMw5JNj+i56AeJ/T/nqX4SidSkY6FQpBmdv/WWHghCyuPtQJfxMcIqN Hkl1J5oJURXsXFsNexhKs4NyLXHxSkO8xyu8bDbwQ7900xmmf2ZQdWvVyDLtCHhB012L fYCHJ+UgrqeNhBHac8ymiBC8parpb9Fh0N28afmGec2CHwSe9wpjqZvSm//qzCL0S2Sj WTnXwTMQXqaUOlTSLu9CNj0cax90PbbztcvaPU5KFi5SU8RXYLJBbKHQ+B2pSD3wyYt5 5WWAHvTFS4LiZ5xsYwVP2jrdCVVz5g8FOk8BtrNnY4kRu0SAgiC9cVAKx8vJrF5w8BNe RlBA== 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=j6iglEF4ngHi2tBY54a8HWqNTeSLYF2d6yPMEK7/4jmC851Dj2UhVW83WpcNakh4pP yFqx0EQ93u8ACEhhnshRXNyZfhCKFNUjRseEdOaJpMWxw/f+VRu4HU9lL1G3gUuqO3r1 F2Y9l3/UEIMbA1yZe2w/3mXMsxJbyD2jTLRgGOZcDHUrMlPoJ+tlXK7BWnryF6ZY6c2W UPK4wPeY/XrtdwQSikgOcjltAyjlHhwPu31wTeIjBf4aVyD/agzz6RDz8pw/7uNdwcns SIEGv1o4w+bVyJt77zPLVVskKqwwJENfMwRo5Zo+p1MNWpVCtla/26yMDkZYTrNYYQP8 CK0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=eKkCqQS3; 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 k8si11835903pfi.243.2018.04.08.22.23.28; Sun, 08 Apr 2018 22:24:04 -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=eKkCqQS3; 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 S1754912AbeDIAXo (ORCPT + 99 others); Sun, 8 Apr 2018 20:23:44 -0400 Received: from mail-by2nam03on0115.outbound.protection.outlook.com ([104.47.42.115]:29467 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753655AbeDIAXk (ORCPT ); Sun, 8 Apr 2018 20:23:40 -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=eKkCqQS3S+rMp0UtlQ4EtX3eC+R6cxZ81kJLPZfrD6vjHXe3MWcazmD7qvpFXRycyeZRwuQd8+p+FmGJ7GKdkdjJFE01XqqaRHeKlHR5uGgbdGz20ijZrDenMwdXaaGaKcGZkJnvLpkhc2i0KYxeHSqLhaFNfB9xxRlFnPtf26g= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1080.namprd21.prod.outlook.com (52.132.130.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:23:37 +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:23:37 +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.14 062/161] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() Thread-Topic: [PATCH AUTOSEL for 4.14 062/161] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() Thread-Index: AQHTz5iVvXl/C3I73E+j9RFbje+woQ== Date: Mon, 9 Apr 2018 00:20:36 +0000 Message-ID: <20180409001936.162706-62-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB1080;7:Az15l7O941mJ/8ClAoZBmOu2avd8ytECKFXC4sRMki8w1kynYBxCXEP5lzGxULupe20IaXi/JFSGIb+/eHakfTo0Lzbjsx8Ogm7EG9YXNUYyzwBmPsSkWWK7uCBdKKPy73sWNVGOO1E6Blbuh6n4A3xE/X1lDzY+NTr/IZZVcKVGI/eLOSJIxCE9RGZcQigbClcjx/Ew29lvLWgXyqigA/w0rIcVJ5uLaxwY9+K9AJoFyLpi03Bmxwj04hQUHXtZ;20:2i29dQVv++ebTyJyRh9V3Fj8/ZO4LXO6lCK16T16MkBFcqnoKDirxe42eOqsIqUdvp0j6HkWOHfV9sdpHGHI8yGtaPqK6XnJJHSiE8/So1hqFg9qMDE/LmfpZ+7KYoXCBBs4x6OWIQvHp7jNY8f9JLg1oLU1d4IJu2XnosCu3z0= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 1fde5d2c-37d9-445a-1c5d-08d59db0233f x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1080; x-ms-traffictypediagnostic: DM5PR2101MB1080: 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)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(3231221)(944501327)(52105095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB1080;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1080; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(396003)(39380400002)(366004)(39860400002)(199004)(189003)(2501003)(5250100002)(8936002)(10090500001)(5660300001)(3660700001)(446003)(107886003)(14454004)(36756003)(6436002)(476003)(3280700002)(2616005)(11346002)(4326008)(53936002)(6512007)(22452003)(305945005)(10290500003)(316002)(102836004)(2906002)(6116002)(66066001)(6506007)(3846002)(7736002)(486006)(54906003)(110136005)(186003)(72206003)(26005)(1076002)(105586002)(2900100001)(6486002)(97736004)(478600001)(81156014)(81166006)(86612001)(8676002)(106356001)(99286004)(86362001)(575784001)(76176011)(59450400001)(68736007)(25786009)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1080;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 0rxj11Do5D5al0uL83CoCL9YG3mBnJVSaIs4OJBAG02+0QHrrrUBDZ7JTsSu12Ygf+O3kIT97GtP4tySx4/kJQ4n0x+sWSocluaJ8GyaCToslgBzJSo3DadSVTuMZFctpuphOhdb3MQfzXyQdpD6IgxXycvVhuhceu3JTZM877wl/oc3zx9MutUxLBkx9yleyzYycfAZhzaxKpn61rVAtV4WUpDVfcppZ6dK2zliLuT90R4/Dp0XoVX7r3nbnSp1yIly25s7gNcyqpb7F81pTp/GGNY5XZzv9OKHypTr/eiRzfgOIqsYqMIrEsG6ntKyFAaoLYnoYy/f/uUYA/7BT6hi0f3nDkC2/oRtcV+BASMf7A1AcO8bU5+NwqkmXmG5vxthmrcyG7JjfUJp9RywRmrpp9IHEWD4g+OWaYy5Rs8= 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: 1fde5d2c-37d9-445a-1c5d-08d59db0233f X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:20:36.7379 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1080 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