Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2655454pxj; Mon, 14 Jun 2021 04:10:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdN27xP+NeX3Fj9jxxn5juC9YRCGrwmCwqOsl7IPVxD4Sk8Uo387qLGO8F95SrNVkqoWxX X-Received: by 2002:a17:906:7f0e:: with SMTP id d14mr14398419ejr.103.1623669005593; Mon, 14 Jun 2021 04:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623669005; cv=none; d=google.com; s=arc-20160816; b=MJDcjx3CSiauq07ms0gaN/q/rt7HQ5+LMUZaOGdWIBFb9r9zDPlMwvVHdiJl6xDFw1 /RAns9Iwgxvczmn4bFQZEiCrcpEiMSamlr/snpoq1k/7RrC46vkIZZGMXeskG8xLuA71 DHENK9N0julgdR8A83kM54wsXpy3egcyNUMZv2GEbDFYqLMRX6eqbdjR9lAXMPfQJaY4 1wdMWsImlj0uUbQoHOoiKrVZe1uBk5Ayd7I55E+BdeF1V6TyhaEMKylFKwQJwKNms3Wm tIaJSe7EkH2ndwnKM+fcVDXgBVjW2H1gLFcRrHxJX03G2eimzzczPTPMZtm29SCdD/iI eA+w== 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=rgI6Uowv7oCZSBi2l9EcD/Dfqfxh+lWMW8VFDDb4WsM=; b=M06RhSP50cCpLFeWoO1UhA6K6UG6G1lHQPUGkGC2ujwhYLwZtSVB6FdqrU3DXWlAZ6 Bb8PzQxMz6K9QLnFe9vhg4MGZIbz7OE3D22QVum40Le/4hU2fEkmwTZsaRhUAs4Ylo07 FFZNGE76DPjr/nhYA+8fW4gRLf8JODb/FMq9VStd5tIFHiRq2zoLMnG3hH+sHhNaSpp2 tJKmKsp4BNe5EuEmribygTOf0j0hluxWYNRqywo47fyE5sZ+lNR6N6WZrfCoZBxfvodC A1wptDlhXHgVK0AppacBvP235ayHPDl1egApPbcReBXeg0YzaTHCHWftWLqm9qOcbZV9 NjCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wXz7bMtP; 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 w11si11614527edu.413.2021.06.14.04.09.43; Mon, 14 Jun 2021 04:10:05 -0700 (PDT) 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=wXz7bMtP; 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 S233826AbhFNLHX (ORCPT + 99 others); Mon, 14 Jun 2021 07:07:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:60606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234470AbhFNK5K (ORCPT ); Mon, 14 Jun 2021 06:57:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F7AE61606; Mon, 14 Jun 2021 10:41:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623667286; bh=WOLd7ah1qgxPQgGi8mtCBc+GE/1Vg1PbV/3cQNmYmbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wXz7bMtP7PjGIaW/wMg2RR5rEvoxtJBhTBedvmaGvKJPFaDbeBjYOO0DcVSWJu689 S6ijKq1584K6wF3x1W1DYwzAOoGMHkIsLEzMTHAXSoeXlffwI2Dwjm1OskwxNk37q1 P57pv0ARtwUtoDlP6GvkGoM1lqiSbuYu39gZ1DOc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Karen Dombroski , Amit Kumar Mahapatra , Mark Brown , Sasha Levin Subject: [PATCH 5.10 005/131] spi: spi-zynq-qspi: Fix stack violation bug Date: Mon, 14 Jun 2021 12:26:06 +0200 Message-Id: <20210614102653.155326989@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102652.964395392@linuxfoundation.org> References: <20210614102652.964395392@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: 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