Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9045645pxu; Mon, 28 Dec 2020 05:18:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+QbGMqgcByVfd7EwWkyoIuGiWwdTOipI86Vazv0qGr+kUDZjswjde7ekHKi02+JCDcs1t X-Received: by 2002:a05:6402:c95:: with SMTP id cm21mr42442199edb.294.1609161505758; Mon, 28 Dec 2020 05:18:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161505; cv=none; d=google.com; s=arc-20160816; b=AEAQh7rlHAW8jCAo2Ft0oiySRcowcgN6nv6yLcJTEsNvB4mXjqwPB7FdmgG1r42lTd w5B98ezeZzNjjbWG3yEqnPFKbTzNZ5VJLFeE2KBouVeWgvmH/kxyufzfsW6RwtD2fn9/ bSWkoE1o8CPvhu7HF6a1ZBRxBSYLmAeNGn3nKBdyD8DJy/V0B+nvTKltH96r/rfdSpbX NehbPsJT1GIOygw0TtwIQJl1lgoeq8VeO3RCx3k/yEbMaNnNLWpBSndNzlfTnkmIef+V KHWfIoFSo1iSGcoTv5Xc/KuOR7dCCNgts4NRMX2Eiyp6eF0BCLqKfLqHrrxzk95hGlsc bifg== 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=aOaQrrQ9vo+l3Lrqm+t1MNnm491wMDnEe98+edD9TqNWvNi9/a4wiqSmZxiAgH/F5N JKbrd4dICxPD/8hM8GP684U1SLJr4KQ+lJN1ONT1z22Lv7JHXqTCGltVN2ZqyQ+vPif2 Vb5R/d1MOCDtW2UsZiTJ6GPUKsjSdF034PPDhT6B8dtUZiGt6wA84Nc1RUMnDI91o89W oiWAICkz1KOcc7ZrvBZcZthMa2pzZoo9bSCBRqzxaum73nQ1yqwmoaZqSps2+Npvr6xr V3PHr8mPDBDkSf91IgCgKq7/MHV/HKBh7VeG7k1Y85D8KUU0RciRX47vqBYYSDZ4uUAN nCQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ubMcuKju; 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 p17si19849894ejd.679.2020.12.28.05.18.03; Mon, 28 Dec 2020 05:18:25 -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=ubMcuKju; 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 S1733064AbgL1NQU (ORCPT + 99 others); Mon, 28 Dec 2020 08:16:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:44004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732835AbgL1NQB (ORCPT ); Mon, 28 Dec 2020 08:16:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3355022583; Mon, 28 Dec 2020 13:15:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161345; bh=JevaJKgB0OQZVfFrtoZeKjvd2DOI6bStpsdjPtf2Kkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ubMcuKju+q2r5TiykRdJOgI+us1K53YmT5FRK9XEOi+t3ASiHl5T3oTAuLfImM8z1 odsfxI7Vay0Cq0HgnNeoSEUCShopf9caP3qgmlGJ0dqo2hjQEKPfvsu6odQ/NOtkFD 0NztR1QZHhPq+k70OsS7hCbuEZJtbeThBAD3+QiY= 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.14 184/242] Input: cyapa_gen6 - fix out-of-bounds stack access Date: Mon, 28 Dec 2020 13:49:49 +0100 Message-Id: <20201228124913.747270605@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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);