From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2DBCC47097 for ; Thu, 3 Jun 2021 17:07:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A30C261405 for ; Thu, 3 Jun 2021 17:07:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230323AbhFCRJZ (ORCPT ); Thu, 3 Jun 2021 13:09:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:40278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230208AbhFCRJZ (ORCPT ); Thu, 3 Jun 2021 13:09:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3192E613F5; Thu, 3 Jun 2021 17:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622740060; bh=WOLd7ah1qgxPQgGi8mtCBc+GE/1Vg1PbV/3cQNmYmbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RWsizCiG2qRg5DtwQ/6+iUys4lcM1iyfzybLR8goVd35wqTPDbkzog7eVgXPTid2Z TeDxxb/C6KW/PshmuT+9IgZ2sy0x9OVAHBfMxohW5MtWMGUW42yDioBWUFB+4rKDqQ n3q1Qq79cjUFfIGF3msfPCzuVwrxYA6u0AmKunUAusDYIRVCsQkDuplFQRFdYFuc4y cWJBtjXUvIvx6cGjVgx8gSEz7WIGXTT0yOObTY44XJ9cPUw1LX/Ft4Gye6avRnL1lT LZhp20SV072We78tEBcFuVjbBhY+dPYsJTalzYGZFzOUTYHlQeWd6QaSeYPJ+64Kv1 p5cP0GMGUY7xg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Karen Dombroski , Amit Kumar Mahapatra , Mark Brown , Sasha Levin , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.12 04/43] spi: spi-zynq-qspi: Fix stack violation bug Date: Thu, 3 Jun 2021 13:06:54 -0400 Message-Id: <20210603170734.3168284-4-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210603170734.3168284-1-sashal@kernel.org> References: <20210603170734.3168284-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org From: Karen Dombroski [ Upstream commit 6d5ff8e632a4f2389c331e5554cd1c2a9a28c7aa ] When the number of bytes for the op is greater than one, the read could run off the end of the function stack and cause a crash. This patch restores the behaviour of safely reading out of the original opcode location. Signed-off-by: Karen Dombroski Signed-off-by: Amit Kumar Mahapatra Link: https://lore.kernel.org/r/20210429053802.17650-3-amit.kumar-mahapatra@xilinx.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-zynq-qspi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c index 5d8a5ee62fa2..2765289028fa 100644 --- a/drivers/spi/spi-zynq-qspi.c +++ b/drivers/spi/spi-zynq-qspi.c @@ -528,18 +528,17 @@ static int zynq_qspi_exec_mem_op(struct spi_mem *mem, struct zynq_qspi *xqspi = spi_controller_get_devdata(mem->spi->master); int err = 0, i; u8 *tmpbuf; - u8 opcode = op->cmd.opcode; dev_dbg(xqspi->dev, "cmd:%#x mode:%d.%d.%d.%d\n", - opcode, op->cmd.buswidth, op->addr.buswidth, + op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth, op->dummy.buswidth, op->data.buswidth); zynq_qspi_chipselect(mem->spi, true); zynq_qspi_config_op(xqspi, mem->spi); - if (op->cmd.nbytes) { + if (op->cmd.opcode) { reinit_completion(&xqspi->data_completion); - xqspi->txbuf = &opcode; + xqspi->txbuf = (u8 *)&op->cmd.opcode; xqspi->rxbuf = NULL; xqspi->tx_bytes = op->cmd.nbytes; xqspi->rx_bytes = op->cmd.nbytes; -- 2.30.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0168FC47099 for ; Thu, 3 Jun 2021 17:11:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD78E61448 for ; Thu, 3 Jun 2021 17:11:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD78E61448 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tcVL0qHROLW8lEc6u5+Y2OC3n2szLWBO+H+tjMpiavg=; b=YxptByaXxKq9Ur XLdyyg9CZcq6FCh7tN9nJvCzT2+U7jmUMGSFCgpKewWRypkfd4F4IMJvkjRFoku68pdPZB1Bvvdvq 2W3x9oV0vdn2CGNujQ77yleS0rF6gmDonOlxy1hLoJcuKirfpKC2NfVRvS1EWFPtWJOdDh3TzHLm5 pWvYOxgzzsPF8lo8A4qxPDnK7BVHGnAl2ezH38lujnRx/SOFeHVg+rOjgh9ShbqfbY/LYuMv/wK8m NBYXHzQny+dGdELE32wRyPC+easuCKIMJTDFmZpWRC7JqAoqFUwocenSgw/7B+DTxus/tfXl+Xyzu AXOFKNcj4uakUbed6D2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqou-009jlE-Ms; Thu, 03 Jun 2021 17:07:48 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqom-009jiY-Ox for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 17:07:44 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3192E613F5; Thu, 3 Jun 2021 17:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622740060; bh=WOLd7ah1qgxPQgGi8mtCBc+GE/1Vg1PbV/3cQNmYmbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RWsizCiG2qRg5DtwQ/6+iUys4lcM1iyfzybLR8goVd35wqTPDbkzog7eVgXPTid2Z TeDxxb/C6KW/PshmuT+9IgZ2sy0x9OVAHBfMxohW5MtWMGUW42yDioBWUFB+4rKDqQ n3q1Qq79cjUFfIGF3msfPCzuVwrxYA6u0AmKunUAusDYIRVCsQkDuplFQRFdYFuc4y cWJBtjXUvIvx6cGjVgx8gSEz7WIGXTT0yOObTY44XJ9cPUw1LX/Ft4Gye6avRnL1lT LZhp20SV072We78tEBcFuVjbBhY+dPYsJTalzYGZFzOUTYHlQeWd6QaSeYPJ+64Kv1 p5cP0GMGUY7xg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Karen Dombroski , Amit Kumar Mahapatra , Mark Brown , Sasha Levin , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.12 04/43] spi: spi-zynq-qspi: Fix stack violation bug Date: Thu, 3 Jun 2021 13:06:54 -0400 Message-Id: <20210603170734.3168284-4-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210603170734.3168284-1-sashal@kernel.org> References: <20210603170734.3168284-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_100740_873990_C3E183D9 X-CRM114-Status: GOOD ( 11.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Karen Dombroski [ Upstream commit 6d5ff8e632a4f2389c331e5554cd1c2a9a28c7aa ] When the number of bytes for the op is greater than one, the read could run off the end of the function stack and cause a crash. This patch restores the behaviour of safely reading out of the original opcode location. Signed-off-by: Karen Dombroski Signed-off-by: Amit Kumar Mahapatra Link: https://lore.kernel.org/r/20210429053802.17650-3-amit.kumar-mahapatra@xilinx.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-zynq-qspi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c index 5d8a5ee62fa2..2765289028fa 100644 --- a/drivers/spi/spi-zynq-qspi.c +++ b/drivers/spi/spi-zynq-qspi.c @@ -528,18 +528,17 @@ static int zynq_qspi_exec_mem_op(struct spi_mem *mem, struct zynq_qspi *xqspi = spi_controller_get_devdata(mem->spi->master); int err = 0, i; u8 *tmpbuf; - u8 opcode = op->cmd.opcode; dev_dbg(xqspi->dev, "cmd:%#x mode:%d.%d.%d.%d\n", - opcode, op->cmd.buswidth, op->addr.buswidth, + op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth, op->dummy.buswidth, op->data.buswidth); zynq_qspi_chipselect(mem->spi, true); zynq_qspi_config_op(xqspi, mem->spi); - if (op->cmd.nbytes) { + if (op->cmd.opcode) { reinit_completion(&xqspi->data_completion); - xqspi->txbuf = &opcode; + xqspi->txbuf = (u8 *)&op->cmd.opcode; xqspi->rxbuf = NULL; xqspi->tx_bytes = op->cmd.nbytes; xqspi->rx_bytes = op->cmd.nbytes; -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel