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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230717163600.29087-1-tudor.ambarus@linaro.org>
Date:   Mon, 17 Jul 2023 19:35:57 +0300
From:   Tudor Ambarus <tudor.ambarus@...aro.org>
To:     michael@...le.cc, pratyush@...nel.org
Cc:     miquel.raynal@...tlin.com, ichard@....at,
        Takahiro.Kuwano@...ineon.com, linux-mtd@...ts.infradead.org,
        linux-kernel@...r.kernel.org,
        Tudor Ambarus <tudor.ambarus@...aro.org>,
        stable@...r.kernel.org
Subject: [PATCH 1/4] mtd: spi-nor: make sure op does not contain garbage

Initialize local struct spi_mem_op at declaration to avoid having
garbage data from stack for members that were not explicitly
initialized afterwards. Zeroise the local struct after the first
use, so that we have it clean for the second use.

Fixes: d73ee7534cc5 ("mtd: spi-nor: core: perform a Soft Reset on shutdown")
Cc: stable@...r.kernel.org
Signed-off-by: Tudor Ambarus <tudor.ambarus@...aro.org>
---
 drivers/mtd/spi-nor/core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 273258f7e77f..603791497523 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3235,11 +3235,9 @@ static int spi_nor_init(struct spi_nor *nor)
  */
 static void spi_nor_soft_reset(struct spi_nor *nor)
 {
-	struct spi_mem_op op;
+	struct spi_mem_op op = SPINOR_SRSTEN_OP;
 	int ret;
 
-	op = (struct spi_mem_op)SPINOR_SRSTEN_OP;
-
 	spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
 
 	ret = spi_mem_exec_op(nor->spimem, &op);
@@ -3248,6 +3246,7 @@ static void spi_nor_soft_reset(struct spi_nor *nor)
 		return;
 	}
 
+	memset(&op, 0, sizeof(op));
 	op = (struct spi_mem_op)SPINOR_SRST_OP;
 
 	spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ