Received: by 10.213.65.68 with SMTP id h4csp2116212imn; Sun, 8 Apr 2018 20:07:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Zpem76U61DlBjNH6YXzxwHt0TlmjnLrdOoqsFLD4DtuGtHuEUI2ajUZ/RrqpvFEghEJ+l X-Received: by 2002:a17:902:108a:: with SMTP id c10-v6mr37166955pla.22.1523243222405; Sun, 08 Apr 2018 20:07:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243222; cv=none; d=google.com; s=arc-20160816; b=f5TOJDjlQG9xrvH4CVIShTWsKtpCIVBTybYtVAToyfZ4x7lgmKVdS971B0j/0JM+qY Et6tyLE8wCw9G5qxIelgyFqpwxbav9bqPirvUffxh6opfBaPzUPoxM50mIZofkzsMfta 8fh20Jpg3npVUZvTNZ0oGjhwxno/AN8ZPTd6cvyXBMCxPezFRi7NoZ1a5Xjepesda/3s 3URPFWxEE8qNgxR6G8XqQAe8JX0CMILryYlG36FnIPjp1eWeufPaaQKJdPKhJSGwLvmR EQqHerxIlK4mwa6fPqZvGSRPJOPsryCAluhzA5zsGub6DpLcrgkHzvTWUJMm64qNrGEe WE+g== 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=jF9sPzO75084/hBSTa4R8vufVSKr6Nc7AIIrRBCN0I4=; b=BahKiopqr1vpEMejwnO7gTPflsdVJZsEhGwccKFNdTZIPEcWENigWjLoY9yi0GfkFy donDNoMHO1eHPLQuF2iGcB5HSsv6lo4hD1K20Yg6M/Lg0Eh30RDSdRqnlCclt9Ykli5F /ySnZfq5sF15NjsLaU3pP99Kx7FXDjjV83XW8Lf7owO69vgyEBHdxRbm4XWlwFV5N9H1 Zm78ZVV6Lm/xxjOCS26bnNvKGq95aMuVJeEew8nauUMU32355+jJ1jwtHubHnkNt8uJ/ 58zWovPh4DtiJ5AvXBpSeKrX0f0IVewBphKLjcp3cyIkgfOmna20oM0t40z+qZKjC13Q jcVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=ie12zq1q; 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 o129si10563076pga.253.2018.04.08.20.06.25; Sun, 08 Apr 2018 20:07:02 -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=ie12zq1q; 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 S932640AbeDIBMG (ORCPT + 99 others); Sun, 8 Apr 2018 21:12:06 -0400 Received: from mail-co1nam03on0137.outbound.protection.outlook.com ([104.47.40.137]:26752 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932988AbeDIAil (ORCPT ); Sun, 8 Apr 2018 20:38:41 -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=jF9sPzO75084/hBSTa4R8vufVSKr6Nc7AIIrRBCN0I4=; b=ie12zq1qlKoTcDAwbQdhrZHUQ7m5TfV+dfu3e7WPEEN4r92CvGdfQBSKbXBMuaPIJSFIEbShAxGUKspWBMkt6Ow3OlFYAncLpC1uDAwGDZWT30Bd503WNBJiMqenFSM4FpXObJ+JZpqsVeeU/mg5PKMMVzOduUgfYq+KF5C7X1k= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1095.namprd21.prod.outlook.com (52.132.130.17) 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:38:36 +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:38:36 +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.4 130/162] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() Thread-Topic: [PATCH AUTOSEL for 4.4 130/162] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() Thread-Index: AQHTz5nQTGeadJEi1EyVaNIEkrG3rQ== Date: Mon, 9 Apr 2018 00:29:26 +0000 Message-ID: <20180409002738.163941-130-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-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;DM5PR2101MB1095;7:VQ1BmcsuX26sO6FmA1ZAl/RmY2OSpTc0TYedjMsjcYqciPKspg76z7+csUdiOGAfvws0i8nraUHVm5VjICV2Isp1nxbMoL6VRXtcBMV3iJPLBKNTJdlwGeljgxcj9D06Imy/O4sVcCab/K0iS32/X8vscZz9v7mSQ12AyIHP3cerXBYuBEVSJAwek81CXKfUwGn0YV2jynK5avdAO6C7XVrswX7IIohGnV3v1OHCKab5CYzhLiWYZEp0qhAiUSCr;20:g0sGx8lmE4idE7VKQAmOI46fj3zyKWW1/3/I1j11h2wV66U8GAQS7jR4MJMeKaoEgjcRgdn/h091OEJrZft1ewGNj9w9SqlwpyhT0dmeC6sZvJDFYDBOdygplICnOU+cysybEr+XSbT2tzmtwH0ZxXSosmIRlPQASQfjVpb+MHQ= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 856fb413-bcc8-4b4b-8035-08d59db23b0b x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1095; x-ms-traffictypediagnostic: DM5PR2101MB1095: 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)(3231221)(944501327)(52105095)(10201501046)(3002001)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB1095;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1095; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(366004)(396003)(39860400002)(376002)(189003)(199004)(26005)(10090500001)(476003)(105586002)(86362001)(107886003)(11346002)(446003)(2616005)(102836004)(76176011)(6512007)(97736004)(575784001)(36756003)(6666003)(6506007)(8676002)(59450400001)(99286004)(4326008)(10290500003)(81156014)(86612001)(81166006)(186003)(486006)(2900100001)(106356001)(1076002)(72206003)(478600001)(305945005)(8936002)(25786009)(3660700001)(7736002)(68736007)(66066001)(110136005)(316002)(54906003)(3280700002)(2906002)(3846002)(6116002)(6436002)(53936002)(6486002)(22452003)(2501003)(5250100002)(14454004)(5660300001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1095;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: sXHfy1afSEdKqLsviOg03RbgntmU7f0aFYltk0l8lCxjmbVdVDOEpo118FULK5+sdwu2cvRvprPmW5LheOlu5bsKcGSiUg+QPLJqjR/BOK9XMURTydC60g1q4QiaQHNIiRoJrswDGvfX5V73+lajub45jHPczJzLkw9kfghWYK/CKfy7KLqOWe7qeFcjqAco3LQbEHnJv/vEQ1o7sE7bwi8+Sy0wai79JrHg1cLr0EbB5Hz3aM0ATD3B19btQs38sADD07JoMZGSCikkosADhSZfT5AP3NKiR1dRibwtGrdbtO9CDyiVevroL1Sw8fG/ZWx2mLnJhdC93JAsliTa+Z8DaHbVRU2rAWcJEqoOYhH/GbYcQ+70EyhcjyRbu5YSwslorPA794cuIOebzo83ABmEYkMQu6xU62CJ63yDe04= 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: 856fb413-bcc8-4b4b-8035-08d59db23b0b X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:29:26.8181 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1095 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 966047711fbf..1073c0d1fae5 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