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: <20240523113410.983875-1-shichaorai@gmail.com>
Date: Thu, 23 May 2024 19:34:10 +0800
From: Shichao Lai <shichaorai@...il.com>
To: stern@...land.harvard.edu,
	gregkh@...uxfoundation.org,
	oneukum@...e.com
Cc: linux-usb@...r.kernel.org,
	usb-storage@...ts.one-eyed-alien.net,
	linux-kernel@...r.kernel.org,
	Shichao Lai <shichaorai@...il.com>,
	xingwei lee <xrivendell7@...il.com>,
	yue sun <samsun1006219@...il.com>
Subject: [PATCH v2] usb-storage: Check whether divisor is non-zero before division

Since uzonesize may be zero, so judgements for non-zero
are nessesary in both place.

Changes since v1:
- Add one more check in alauda_write_lba().
- Move check ahead of loop in alauda_read_data().

Reported-by: xingwei lee <xrivendell7@...il.com>
Reported-by: yue sun <samsun1006219@...il.com>
Signed-off-by: Shichao Lai <shichaorai@...il.com>
---
 drivers/usb/storage/alauda.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
index 115f05a6201a..17c73acd3b02 100644
--- a/drivers/usb/storage/alauda.c
+++ b/drivers/usb/storage/alauda.c
@@ -813,6 +813,8 @@ static int alauda_write_lba(struct us_data *us, u16 lba,
 	unsigned char ecc[3];
 	int i, result;
 	unsigned int uzonesize = MEDIA_INFO(us).uzonesize;
+	if (!uzonesize)
+		return USB_STOR_TRANSPORT_ERROR;
 	unsigned int zonesize = MEDIA_INFO(us).zonesize;
 	unsigned int pagesize = MEDIA_INFO(us).pagesize;
 	unsigned int blocksize = MEDIA_INFO(us).blocksize;
@@ -921,6 +923,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address,
 	unsigned int blocksize = MEDIA_INFO(us).blocksize;
 	unsigned int pagesize = MEDIA_INFO(us).pagesize;
 	unsigned int uzonesize = MEDIA_INFO(us).uzonesize;
+	if (!uzonesize)
+		return USB_STOR_TRANSPORT_ERROR;
 	struct scatterlist *sg;
 	int result;
 
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ