From patchwork Mon Dec 28 12:49:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 352645 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp9749665jai; Mon, 28 Dec 2020 05:33:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCfCXiWOpIaGgQ5dNmVxlBsMJdR7WrTt+fzwv/ckZbJSCAL7LglIAu9T1lSOC+/3rh2Kdx X-Received: by 2002:a17:906:4058:: with SMTP id y24mr40464136ejj.245.1609162390689; Mon, 28 Dec 2020 05:33:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609162390; cv=none; d=google.com; s=arc-20160816; b=WNJVkO7yDuD8VxH5bMc3hKTKQiJsOG5+yXURc9DFYpRUqOSmpuZXa8J5wMpYEEhz0R DSeulb172o7bU9vfMj/M9QF/19gQnl/QlGgiMJFV4n6GmTrCPzHe1HIUb2IEuK6NeVGm ny3Ta2wL0Vb3HlRZ6njp4sSIaOAezEDTUZtXzM0HO5cZQA2w3SYaGuuQfcYCTTZLrtuN pCT+TuOciF0I8wMs7Jyd7ECBuN83reHYHNV/BcUJVF+D1o3ejI/A9kDaz9XGxX+ogPTn qVyDG6wg0WFMUqgGwa5ma+mVpRic10bqSPv+jHyvg1WVad5bqOwzl1OuJuUn7QlM2MMo nXHA== 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=kPwoss2EKD9Xsbt+xSXB3UveULLowCmnCYKiHV4rjDXQygckmfuVYqJu0ECrKlvAN+ PRcNWvNTWG6akElHK7EBSPLCbMh2IQzOz2TKHcS8ljgqhXAE+blWAURgxBstueDVfnko 7W0TMFzFWePTOsFZ+7vLyAZR+4hbWeZBLnMiXj4CtS7wscRY/R0AYTDv63V2F5vTJvjU /JSM/j3+3DYCcnGgx/H01oMGwgOWpcnmxfSF28dCaJ86lFnDUH0ae5rDdxMqiMzeo6Gj Evmmonp6DAK4jmeaNIQvFhRN49NmyHq4lg8NbxsGdo+bmD8noCFpasxlKvFJNBt4wCq4 PHIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="bGOHC/Gw"; 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 v8si17648628ejq.369.2020.12.28.05.33.10; Mon, 28 Dec 2020 05:33:10 -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="bGOHC/Gw"; 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 S2387805AbgL1Ncv (ORCPT + 14 others); Mon, 28 Dec 2020 08:32:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:33430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391068AbgL1Ncs (ORCPT ); Mon, 28 Dec 2020 08:32:48 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id EA078207CF; Mon, 28 Dec 2020 13:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609162327; bh=JevaJKgB0OQZVfFrtoZeKjvd2DOI6bStpsdjPtf2Kkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bGOHC/Gwf7me/mVvhBB/ZvABBeVt8XIb5A6hqimbBbjHNmCEpx3AYvC0jFkURw2CI z6PrHVhLK0pSGWtfxdc1M4ULTAGMW2sQadQIu3u7pfdLWmJa1Hz4JaCT9HZmkj/5Ua v6YWgeD8sH8sjRxIZncyf75QCFVeCoWECeB7LcY4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Dmitry Torokhov Subject: [PATCH 4.19 266/346] Input: cyapa_gen6 - fix out-of-bounds stack access Date: Mon, 28 Dec 2020 13:49:45 +0100 Message-Id: <20201228124932.630251638@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124919.745526410@linuxfoundation.org> References: <20201228124919.745526410@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);