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, 14 Dec 2011 11:40:17 +0000
From:	David Howells <dhowells@...hat.com>
To:	torvalds@...ux-foundation.org, akpm@...ux-foundation.org
Cc:	linux-kernel@...r.kernel.org, David Howells <dhowells@...hat.com>,
	"Robert P. J. Day" <rpjday@...shcourse.ca>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH] Fix order_base_2(0)

The order_base_2() function is either wrongly documented or wrongly
implemented.  In the preceding comment, it says that:

	ob2(0) = 0

but this is not valid as roundup_pow_of_two()'s documentation asserts that:

	* - the result is undefined when n == 0

Fix order_base_2(n) to actually return 0 when n == 0.

However, should we just instead define that the result of order_base_2(0) is
undefined?

Signed-off-by: David Howells <dhowells@...hat.com>
cc: Robert P. J. Day <rpjday@...shcourse.ca>
cc: Andrew Morton <akpm@...ux-foundation.org>
---

 include/linux/log2.h |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/include/linux/log2.h b/include/linux/log2.h
index fd7ff3d..d6463d8 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -202,7 +202,6 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
  *  ob2(5) = 3
  *  ... and so on.
  */
-
-#define order_base_2(n) ilog2(roundup_pow_of_two(n))
+#define order_base_2(n) ((n) == 0 ? 0 : ilog2(roundup_pow_of_two(n)))
 
 #endif /* _LINUX_LOG2_H */

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ