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: <20220324070004.225738-1-nathan@nathanrossi.com>
Date:   Thu, 24 Mar 2022 07:00:04 +0000
From:   Nathan Rossi <nathan@...hanrossi.com>
To:     linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc:     Nathan Rossi <nathan@...hanrossi.com>,
        Nathan Rossi <nathan.rossi@...i.com>,
        Tudor Ambarus <tudor.ambarus@...rochip.com>,
        Pratyush Yadav <p.yadav@...com>,
        Miquel Raynal <miquel.raynal@...tlin.com>,
        Richard Weinberger <richard@....at>,
        Vignesh Raghavendra <vigneshr@...com>
Subject: [PATCH] mtd: spi-nor: core: Fix 16bit write sr_and_check status check

From: Nathan Rossi <nathan.rossi@...i.com>

The spi_nor_write_16bit_sr_and_check function description describes that
the function compares the value of the status and config registers after
the write. However the function does not implement the status register
compare only the config register check.

This causes the function to differ in behaviour to the equivalent
spi_nor_write_sr1_and_check for non-16bit writes to the status register.
This is important as other functions rely on the return code of
spi_nor_write_sr_and_check. For example spi_nor_sr_unlock returns the
result directly, which is returned to userspace such that failing to
unlock the spi-nor device was resulting in a return code of 0 instead of
the expected non-zero indicating the failure.

Signed-off-by: Nathan Rossi <nathan.rossi@...i.com>
---
 drivers/mtd/spi-nor/core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 04ea180118..d75d4f8a45 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1007,6 +1007,15 @@ static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 sr1)
 	if (ret)
 		return ret;
 
+	ret = spi_nor_read_sr(nor, sr_cr);
+	if (ret)
+		return ret;
+
+	if (sr1 != sr_cr[0]) {
+		dev_dbg(nor->dev, "SR: read back test failed\n");
+		return -EIO;
+	}
+
 	if (nor->flags & SNOR_F_NO_READ_CR)
 		return 0;
 
---
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ