Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2529933imm; Mon, 28 May 2018 09:50:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZosiIy1KMJ1bD4VsLbikv/JKcgg3Khq29eG325wj8sjlMtLJu8+xdc6sOskamgYSwdMvdSP X-Received: by 2002:a62:6883:: with SMTP id d125-v6mr14262835pfc.26.1527526220869; Mon, 28 May 2018 09:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527526220; cv=none; d=google.com; s=arc-20160816; b=ddzNa59+eU3PBdqYV04ta5OmQiis3rHgs9MP4OJUEXLPNH9TX3Lm4+ubk/22fJOkeI IOLdhmndL50qs2yvq8QOrbmexNdnryz6ebnPacxcNi3M7gCBxztgmRT+Z+3ErwWBfYR4 aNlNEt4u80X7GQ5+U926wuGeJFdD1EGl7s9g93jBAh4t6OXxkdYgNRNZYD7Kuxtw2uxa iJ0p6X8XK1AslrRIbmmbbabNJEP0KiPtSGZNkuQCCIGlnB/4zUzv6UbdDx96urb1xsme E86F0ZTV7ov14GarsiXnThyxRikDQ++TFAYbwPlIjyiJHN0N7yU8w5Och2LGRS50tQhQ E5Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=xx7ZF6PF99nJEysstswjVCIO+kOXJtSwSSUPZi02x7E=; b=JZlQKbuSw5IV9KczmQee/iGam/1X8Q2LoIVBkjH2PHfL75jHMbeimHqJuS8HKve1Pk 6uRvd5sto51AM0WuRPlUmhj4UDIYzzUwH3d2QjCO8S7hmSa7KvHvJSv2a95iU7Bj94/N 1blTPKKuAoL3yO2/IvpOAY7ddGWGu/oyDf3400TUOooPSFIU4Cg8J1Z6pcOd1eCLqKws /pqCHBTnjSEdJgWo48tTpBV9m99CNb4jOfwzNxpNz62E8zza1fr6gHPW1Lgmq0Ds9ius D0dePkfQVb4fTw7sEwVA8J5RkPKssZk+vEcuzbrNXwTEv+rrQRItuwjNU0vC/2Gc7kcM fm8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tjKMHlL7; 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 l4-v6si24922139pgn.54.2018.05.28.09.49.36; Mon, 28 May 2018 09:50:20 -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=@kernel.org header.s=default header.b=tjKMHlL7; 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 S1755564AbeE1Qrl (ORCPT + 99 others); Mon, 28 May 2018 12:47:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:54626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754664AbeE1KGl (ORCPT ); Mon, 28 May 2018 06:06:41 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8311020899; Mon, 28 May 2018 10:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502001; bh=pWt6FbXVKh+RKd8ULP7WyEbnxZIOr2Oxj3AmBuoqhro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tjKMHlL7fBjm+taSQQN/DBduOGxXshBWyYCoOW2Sfr1NrX57xah9ZuBVVqk3BkTr2 Xssg2ceiUO3lYfn0EHM3DmGjcJ8Z2VhL+dtIjtqDUpYPfTt4GT2w4psVACXZxOufyf xu2HhIX40o7uEQWC6rTDpn1GFkYzrrV5X/DeJPLg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Silvan Jegen , Jiri Kosina , Sasha Levin Subject: [PATCH 3.18 024/185] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() Date: Mon, 28 May 2018 12:01:05 +0200 Message-Id: <20180528100051.993092887@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- 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;