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: Tue, 12 Mar 2024 12:48:52 +0300
From: Roman Smirnov <r.smirnov@....ru>
To: <linux-kernel@...r.kernel.org>
CC: Roman Smirnov <r.smirnov@....ru>, Sergey Shtylyov <s.shtylyov@....ru>,
	<lvc-project@...uxtesting.org>
Subject: [PATCH] fixp-arith: prevent division by zero in fixp_sin32_rad()

The parameter twopi can have a zero value. It is necessary
to prevent division by zero.

Found by Linux Verification Center (linuxtesting.org) with Svace.

Signed-off-by: Roman Smirnov <r.smirnov@....ru>
---
 include/linux/fixp-arith.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/fixp-arith.h b/include/linux/fixp-arith.h
index e485fb0c1201..434eee8bd9ef 100644
--- a/include/linux/fixp-arith.h
+++ b/include/linux/fixp-arith.h
@@ -118,8 +118,9 @@ static inline s32 fixp_sin32_rad(u32 radians, u32 twopi)
 
 	/*
 	 * Avoid too large values for twopi, as we don't want overflows.
+	 * Also prevent division by zero.
 	 */
-	BUG_ON(twopi > 1 << 18);
+	BUG_ON(!twopi || twopi > 1 << 18);
 
 	degrees = (radians * 360) / twopi;
 	tmp = radians - (degrees * twopi) / 360;
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ