From patchwork Mon Dec 28 12:49:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 352767 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp10032516ejs; Mon, 28 Dec 2020 08:34:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnRivy23D+jLK23cN2QYDszW17vsbAd8q45sLeXeBuOZ3HckPxODx6QO041nncQP6l2rGQ X-Received: by 2002:a05:6402:1c96:: with SMTP id cy22mr42014494edb.339.1609173267758; Mon, 28 Dec 2020 08:34:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173267; cv=none; d=google.com; s=arc-20160816; b=ffCEDRQV6OWK2+57gEbjhmNvuBbuve8S6JNfpzflBfRx8ECsjVW7xoqbmXetZEVMvW T0M+XKpvpq8Oi8X7Ozk3KLkME8GSB0AdLnlCrGZNEvodss11lJDM2SjXBZGtT+r7cCxr i7dOk0hGf3CHsD45rqutUu5pQQgCMb3fnJhDVMkwxjFdvWz3bpQAE+tQ/qbv5XMpxv+m JE749fYSLLOn/BsMbTToBPpg1WFk/j47mdnvA5ARGmWHgdqJ0yaRPplFrxWUtNztbgNB K4rxuiXw8gvjmDvWopLrZGbL/gBN/wKFqVFl9RlEbN2Jzfe5x/RWt9aI/Ezz5Ho+XXNs Hi9w== 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=EIzsLP6xjDgK29YsLOldyaV9zibgjxFbviqmLjH3nmVG8Hux4Z7vZaJODu43Ibnsxs Vq5OTK3Zx22uM00HUAWcCytSNmdpDM5m/f520b+MDdIQcNtxt/CoXv71w+UESUK3CRiP d0qEyW0yqmyYjKx3FC8M6gA9moEe5PGuy+jsTtzny7ZRZ4zzWK3pAQvCxssu501ExCsP MyddxBPQChTucNib9kvqGiVvgiemHGKUtLyl3ZUMRAIVBdGOcpx99zh6DCNzZbagKbvc FbPVorid43Q94fs1U2MYym/ovgtutSw+EghbtFO4a7OD70D8rQ+QWxdAiv9hvECaB+qV m4FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="JCbjg/EO"; 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 h3si19650618ejk.164.2020.12.28.08.34.27; Mon, 28 Dec 2020 08:34:27 -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="JCbjg/EO"; 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 S1730595AbgL1Qc6 (ORCPT + 14 others); Mon, 28 Dec 2020 11:32:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:33220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730598AbgL1NFT (ORCPT ); Mon, 28 Dec 2020 08:05:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A5377206ED; Mon, 28 Dec 2020 13:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160679; bh=JevaJKgB0OQZVfFrtoZeKjvd2DOI6bStpsdjPtf2Kkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JCbjg/EO7VQufzqFYh3aSVnq//pV0rwPYwxRazJ8lvHYspSh6EQl5KUbYMDTHTmtD IeiEfzALl/4766AOi5b3+88vrffbjwBCMdLlGv0/YvvRz468xX25WpLPbLrKLeh9jZ iCRX+TxZwWQd6QbcwUwJehrEpzkXGzosHcVygqf8= 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.9 134/175] Input: cyapa_gen6 - fix out-of-bounds stack access Date: Mon, 28 Dec 2020 13:49:47 +0100 Message-Id: <20201228124859.746842375@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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);