Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2335218imm; Thu, 7 Jun 2018 08:59:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK0sES8oN67xOF4MMeONTQJ02+3gDkUb/lK6OyAPve0sOqyM4M7fEubidEZXErCbdn+NocQ X-Received: by 2002:a63:6186:: with SMTP id v128-v6mr2083566pgb.35.1528387164290; Thu, 07 Jun 2018 08:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528387164; cv=none; d=google.com; s=arc-20160816; b=SEuW5iI2oZ2AeF8sWaVKrtkleSXA2eHzu63jUVwBK84nvqQVg1ZrHQOlwHZjHuuGaN /Dloz/VQMoocxQArfkE2wUvnTU9ZAG8Mbr1ua8g6AfP4ZJ+BZx+I8nx9vCp4uTps0ZPY A7/XpPpmL0NygKcyyLsWh4l4cjUn0GQO+A070DkGqQSM48QFHBtRUrTFz2PS2ffJF0Wb pUH+/xaJgpAiJjQSIC0bYonpiJU5x24zFvajZwOxWFyomTTavrfh5+JfFdF/gJ1SqQIP OcLenFRFiYDwm2uDiFI49sQeBi7+VKON4qQRCGh5ptJ4ecfIaTPUF1wHL7aJ9pw5Fd5o 2Psg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=rCUQDP9DgCZQahN9CZN37lD9iXfDTt32I+B/pWZujJQ=; b=jeumzAjIJeoj/8L7zZnMtat7ijWJy40fVaejrfwbk/qStXyCPDRUa93CDdK/a9cKFm 9jYZsCcryhgR5Y3/9ZTNeItXtMDgy/S/kJzzrV/9zB/ch5BOh1eNJtIEsmgv+iDkwWP0 7OyhwaejZHLifSwgGr1iL1O7OmYIumqsXCMX/inH9QMm5eQV2shzd7r8YmFUBQKRy9sC br5c2SAve6x2LJSMf3vya8YCXZO+7CsenjRZ3/UpUnAvHNPymn5kDTLps8iqgBFcI5vN t1ezV0h/PhJfCoX36ibp+E4SN6ciiMSvN+aRPdHSa8YvJWXQEurc4ycD39xv7znzps4x fq5g== 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 s11-v6si4911092plp.464.2018.06.07.08.59.10; Thu, 07 Jun 2018 08:59: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; 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 S934617AbeFGP6C (ORCPT + 99 others); Thu, 7 Jun 2018 11:58:02 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39347 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933054AbeFGOJH (ORCPT ); Thu, 7 Jun 2018 10:09:07 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvb7-0005Zj-RU; Thu, 07 Jun 2018 15:09:06 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb3-0002vv-VU; Thu, 07 Jun 2018 15:09:01 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Dan Carpenter" , "Jiri Kosina" , "Silvan Jegen" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 162/410] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter commit 7ad81482cad67cbe1ec808490d1ddfc420c42008 upstream. 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: Ben Hutchings --- drivers/hid/hid-roccat-kovaplus.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/hid/hid-roccat-kovaplus.c +++ b/drivers/hid/hid-roccat-kovaplus.c @@ -37,6 +37,8 @@ static uint kovaplus_convert_event_cpi(u 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;