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]
Date:   Wed, 11 Aug 2021 06:16:47 -0700
From:   Tuo Li <islituo@...il.com>
To:     kashyap.desai@...adcom.com, sumit.saxena@...adcom.com,
        shivasharan.srikanteshwara@...adcom.com, jejb@...ux.ibm.com,
        martin.petersen@...cle.com
Cc:     megaraidlinux.pdl@...adcom.com, linux-scsi@...r.kernel.org,
        linux-kernel@...r.kernel.org, baijiaju1990@...il.com,
        Tuo Li <islituo@...il.com>, TOTE Robot <oslab@...nghua.edu.cn>
Subject: [PATCH] [SCSI] megaraid_sas: Fix possible divide-by-zero bugs in megaraid_sas_fp.c

In the function mega_mod64(). the variable is checked in:
  if (!divisor)

This indicates that divisor can be zero.
If so, a divide-by-zero bug will occur:
  remainder = do_div(d, divisor);

Also, in the function mega_div64_32(), a divide-by-zero bug can also occur 
if divisor is NULL.

To fix these divide-by-zero bugs, the functions return 0 if divisor is 
zero.

Reported-by: TOTE Robot <oslab@...nghua.edu.cn>
Signed-off-by: Tuo Li <islituo@...il.com>
---
 drivers/scsi/megaraid/megaraid_sas_fp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
index 83f69c33b01a..05eb0d201aed 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -72,8 +72,10 @@ u32 mega_mod64(u64 dividend, u32 divisor)
 	u64 d;
 	u32 remainder;
 
-	if (!divisor)
+	if (!divisor) {
 		printk(KERN_ERR "megasas : DIVISOR is zero, in div fn\n");
+		return 0;
+	}
 	d = dividend;
 	remainder = do_div(d, divisor);
 	return remainder;
@@ -90,8 +92,10 @@ static u64 mega_div64_32(uint64_t dividend, uint32_t divisor)
 {
 	u64 d = dividend;
 
-	if (!divisor)
+	if (!divisor) {
 		printk(KERN_ERR "megasas : DIVISOR is zero in mod fn\n");
+		return 0;
+	}
 
 	do_div(d, divisor);
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ