From patchwork Mon Dec 28 12:49:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 352727 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp9838613jai; Mon, 28 Dec 2020 07:40:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWG9zzUgkEj6rh0b3id+pkZ+xhTGqNaadSgiy0AqjfF1bu0lqGfPc2tR3bTgs4cnYs7+C7 X-Received: by 2002:a05:6402:746:: with SMTP id p6mr42945612edy.313.1609169634234; Mon, 28 Dec 2020 07:33:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609169634; cv=none; d=google.com; s=arc-20160816; b=k/3yk3j6P0rWeJ6bF3HUmzne8ul/mVOlIjjxTOZ4kboDrbgJB3tI0CdW7+gTj2H6WT PVF2ivflGe2sRzEV2yyVOXPyxQPJ0YfY995cnQO1DQqGAbhS7b4j7XQbWLTF9oPiKw9s iYJJJ+31aJDuo27BqXXW/PYXVP6YqzzX99wcejoCdTruvH5gGAxXl8CdJlMi0nNLv6sT hWwAXrOqAh0bVL95zkeKcgd88xTL4ThARF13YfvWCaG0537AQ9XawOjKYPRHZpofAaPJ dsAvt0IGblxzvJwkO1vJ9pDlkPsb22GeO1YAFCVpbHGbV15vTaD0WpQuCjtL5t9bLKTO 07OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uucUfe2zCjocnN+wbSFCnhAlDVc71tqPEXLgwaeltH0=; b=tF6ExD9QuykPAtnJMumxnzjDtPgdjdkQIPS1q8T0VJUQ9ThuMQTD6aCZWVU1tgQkeT ojL5nyv2kMn7CKy9/oIyE1YXgpFYyWAD127cc3K/D57UXEgCqjvyeJ/8pNEeAAZHI2w6 O2z2cZ9nksjcVy9+i3HXYaFnPMdf1QnCRPlLN9C6PYbxptAl5rG31SCRfStxXot3x4L1 7JK+E4JBT6q998gAX8T9MuOY0I8cqd7u9S1CotVbeybu8b2oEh47zWSqz7bgdN22/fS4 DKXTFFe8SPjn20yaurLoUIEFuLTeEEFhVE/8M50kBoxWALPi0v3h6gGdIgTKOB1oDItO Bvwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FTvefcYT; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm5si19790868edb.21.2020.12.28.07.33.54; Mon, 28 Dec 2020 07:33:54 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FTvefcYT; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391558AbgL1Nx0 (ORCPT + 14 others); Mon, 28 Dec 2020 08:53:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:55282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391551AbgL1NxY (ORCPT ); Mon, 28 Dec 2020 08:53:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2DE90205CB; Mon, 28 Dec 2020 13:52:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609163563; bh=JevaJKgB0OQZVfFrtoZeKjvd2DOI6bStpsdjPtf2Kkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FTvefcYTq9+m7AVWw/wn5NEicWUChSycBcl/yysZPqqoJFf1WphsPhVykaMwO97XW lGYN81iAzQYivLUqtOJvB7WLNDUCH5zcI6clOk0IF0GqxNya67Pegr0yT3xaV85Fbw M5Wu6y+7FGjphXiu6jE+Qpphv0qPNeGKAs3hoFQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Dmitry Torokhov Subject: [PATCH 5.4 329/453] Input: cyapa_gen6 - fix out-of-bounds stack access Date: Mon, 28 Dec 2020 13:49:25 +0100 Message-Id: <20201228124953.049408937@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124937.240114599@linuxfoundation.org> References: <20201228124937.240114599@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann commit f051ae4f6c732c231046945b36234e977f8467c6 upstream. gcc -Warray-bounds warns about a serious bug in cyapa_pip_retrieve_data_structure: drivers/input/mouse/cyapa_gen6.c: In function 'cyapa_pip_retrieve_data_structure.constprop': include/linux/unaligned/access_ok.h:40:17: warning: array subscript -1 is outside array bounds of 'struct retrieve_data_struct_cmd[1]' [-Warray-bounds] 40 | *((__le16 *)p) = cpu_to_le16(val); drivers/input/mouse/cyapa_gen6.c:569:13: note: while referencing 'cmd' 569 | } __packed cmd; | ^~~ Apparently the '-2' was added to the pointer instead of the value, writing garbage into the stack next to this variable. Fixes: c2c06c41f700 ("Input: cyapa - add gen6 device module support") Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20201026161332.3708389-1-arnd@kernel.org Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/mouse/cyapa_gen6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/input/mouse/cyapa_gen6.c +++ b/drivers/input/mouse/cyapa_gen6.c @@ -573,7 +573,7 @@ static int cyapa_pip_retrieve_data_struc memset(&cmd, 0, sizeof(cmd)); put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &cmd.head.addr); - put_unaligned_le16(sizeof(cmd), &cmd.head.length - 2); + put_unaligned_le16(sizeof(cmd) - 2, &cmd.head.length); cmd.head.report_id = PIP_APP_CMD_REPORT_ID; cmd.head.cmd_code = PIP_RETRIEVE_DATA_STRUCTURE; put_unaligned_le16(read_offset, &cmd.read_offset);