Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9092296pxu; Mon, 28 Dec 2020 06:27:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJT4azV4j8raBmlVLVm0TiQ2+B4CSMIgrofqz8Rt5gA4pCcd8QbN+/XEanJFe6oUItUcS4 X-Received: by 2002:a05:6402:1045:: with SMTP id e5mr42799185edu.40.1609165628443; Mon, 28 Dec 2020 06:27:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165628; cv=none; d=google.com; s=arc-20160816; b=KgSGQl84yxWnSujx4nFZONF6dZShRzbe8TESd+xToOAhvvnWXiGtCCRBYMELISsbiq 4ddPYgDFxRe0d3kRKH3YhU+NR0Uget5rUAmcJrNr4sLdBcJSoZEYFQq0IpjGlJBXKW/D m3o9dK9rAMPUDHl/f1tU+N9JDPLJZrmot49cLKAXVePNaQRfUslc9adOlao96QSGU/Nt bBL+E+bTbK2Nqz+QpRozqbHRThQEFMpejByTX8rT7BUXOUW8PHhKqlGMMJOP0BLDMGIV ZKo39+8KS6NtS/PHEicOo0EiBNOTxp/vy3d0jiDxcNCL28swr8Dhg4/9DUaSP1QD1ySR p3ag== 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=MnZji6ZY9rVKahcI++Vi5KLkEJ4FQk34Guk6DOyEimPan5/16LTiPMgXXBccP8rrT/ j8e4X70zxywW3CGckYORDMsQ33VIZfdpnmRX+6sy1btZsM9UYs4ylbB0YrFTDfzF1H0P cxBba1sjLakQGIIL3H97Xf61mEehPPrgTODaKhb2XEVl7pipoMP0P+T3epmecuRWatU4 JzZCXpl8fKwaoaoYToGK7ThoyzaEehobNqWMCgZ/lOWw4PPgJkT5+QZvywGInOnynUHf wvt5w5QdlkQK49FarcM6NIJBlgv5jnWaMY6R9Fmc/NGQalzrkxxAHQvJLUB7gUK3hsXg VW2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r33Qd8Jp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 d14si17716799ejt.356.2020.12.28.06.26.45; Mon, 28 Dec 2020 06:27:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=r33Qd8Jp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S2503108AbgL1OYh (ORCPT + 99 others); Mon, 28 Dec 2020 09:24:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:60642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503084AbgL1OYc (ORCPT ); Mon, 28 Dec 2020 09:24:32 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7B0B2207B2; Mon, 28 Dec 2020 14:23:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165432; bh=JevaJKgB0OQZVfFrtoZeKjvd2DOI6bStpsdjPtf2Kkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r33Qd8Jpxpfv7vEFanBDAl4+Mm7649uCA/WlhY6i/tQwRkbsMfdvqmHKeplnW15tY fZefDBAD0fN1Fpig/8PYfcjeQh/4pw8lLdu7PmfgGDWLyly0uGxVt1qtsSL+Evj67b td3QEI0lSRT9e4fQfBSp9RtGr9ADYJthEovvI8Qk= 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.10 529/717] Input: cyapa_gen6 - fix out-of-bounds stack access Date: Mon, 28 Dec 2020 13:48:47 +0100 Message-Id: <20201228125046.313733217@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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);