mul_u64_u64_div_u64-fix-the-division-by-zero-behavior.patch removed from -mm tree
The quilt patch titled
Subject: mul_u64_u64_div_u64: fix the division-by-zero behavior
has been removed from the -mm tree. Its filename was
mul_u64_u64_div_u64-fix-the-division-by-zero-behavior.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Nicolas Pitre <[email protected]>
Subject: mul_u64_u64_div_u64: fix the division-by-zero behavior
Date: Mon, 16 Jun 2025 15:22:44 -0400 (EDT)
The current implementation forces a compile-time 1/0 division, which generates an undefined instruction (ud2 on x86) rather than a proper runtime division-by-zero exception.
Change to trigger an actual div-by-0 exception at runtime, consistent with other division operations. Use a non-1 dividend to prevent the compiler from optimizing the division into a comparison.
---
lib/math/div64.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
lib/math/div64.c renamed from lib/math/div64.c~mul_u64_u64_div_u64-fix-the-division-by-zero-behavior +7 -6
@@ -212,12 +212,13 @@ u64 mul_u64_u64_div_u64(u64 a, u64 b, u6#endif -/* make sure c is not zero, trigger exception otherwise */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdiv-by-zero" -if (unlikely (c ==0 )) -return 1 /0 ; -#pragma GCC diagnostic pop +/* make sure c is not zero, trigger runtime exception otherwise */ +if (unlikely (c ==0 )) { +unsigned long zero =0 ; + +OPTIMIZER_HIDE_VAR (zero); +return ~0UL /zero; + }int shift =__builtin_ctzll (c);
_
Patches currently in -mm which might be from [email protected] are