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: <20230516225108.29194-1-todd.e.brandt@intel.com>
Date:   Tue, 16 May 2023 15:51:08 -0700
From:   Todd Brandt <todd.e.brandt@...el.com>
To:     miquel.raynal@...tlin.com, linux-kernel@...r.kernel.org
Cc:     todd.e.brandt@...ux.intel.com, todd.e.brandt@...el.com,
        pratyush@...nel.org, tudor.ambarus@...aro.org
Subject: [PATCH] MTD SPI-NOR: BUG FIX of divide by zero in new n_banks value

While testing 6.4-rc1 on our Lenovo Thinkpad X1 I discovered
that freeze, suspend, and shutdown, all hang the system. I bisected
it to an addition made to the MTD spi-nor code.

The new "n_banks" value is being divided into without a proper check..
Thus on certain systems this causes a divide by zero hang.

Reported-and-tested-by: Todd Brandt <todd.e.brandt@...ux.intel.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217448
Fixes: 9d6c5d64f028 ("mtd: spi-nor: Introduce the concept of bank")
Signed-off-by: Todd Brandt <todd.e.brandt@...el.com>
---
 drivers/mtd/spi-nor/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 0bb0ad14a2fc..084117959be4 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2921,7 +2921,10 @@ static void spi_nor_late_init_params(struct spi_nor *nor)
 	if (nor->flags & SNOR_F_HAS_LOCK && !nor->params->locking_ops)
 		spi_nor_init_default_locking_ops(nor);
 
-	nor->params->bank_size = div64_u64(nor->params->size, nor->info->n_banks);
+	if (nor->info->n_banks > 0)
+		nor->params->bank_size = div64_u64(nor->params->size, nor->info->n_banks);
+	else
+		nor->params->bank_size = 0;
 }
 
 /**
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ