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>] [day] [month] [year] [list]
Date:   Wed, 11 Aug 2021 06:24:39 -0700
From:   Tuo Li <islituo@...il.com>
To:     sathya.prakash@...adcom.com, sreekanth.reddy@...adcom.com,
        suganath-prabu.subramani@...adcom.com, jejb@...ux.ibm.com,
        martin.petersen@...cle.com
Cc:     MPT-FusionLinux.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: mpt3sas: Fix a possible divide-by-zero bug in base_mod64()

The variable divisor is checked in:
  if (!divisor)

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

To fix the possible bug, the function returns 0 when divisor is zero.

Reported-by: TOTE Robot <oslab@...nghua.edu.cn>
Signed-off-by: Tuo Li <islituo@...il.com>
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 19b1c0cf5f2a..3550998ea38b 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -1594,8 +1594,10 @@ static u32 base_mod64(u64 dividend, u32 divisor)
 {
 	u32 remainder;
 
-	if (!divisor)
+	if (!divisor) {
 		pr_err("mpt3sas: DIVISOR is zero, in div fn\n");
+		return 0;
+	}
 	remainder = do_div(dividend, divisor);
 	return remainder;
 }
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ