lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAArsxNtnCuALXLHLETo5w_EbjrRJdSSte7Xa3nEnVcVw+hV=sQ@mail.gmail.com>
Date:   Fri, 4 Dec 2020 22:13:19 +1300
From:   Karen Dombroski <karen.dombroski@...sbioimaging.com>
To:     Mark Brown <broonie@...nel.org>
Cc:     Michal Simek <michal.simek@...inx.com>, linux-spi@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH] spi: spi-zynq-qspi: fix stack violation bug

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.

Fixes: caf72df48be3 ("spi: spi-mem: allow specifying a command's
extension")
Signed-off-by: Karen Dombroski <karen.dombroski@...sbioimaging.com>
Reviewed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@...inx.com>
---
CR-1084036
---
 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.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ