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]
Message-Id: <4FF70D54020000780008E179@nat28.tlf.novell.com>
Date:	Fri, 06 Jul 2012 15:07:48 +0100
From:	"Jan Beulich" <JBeulich@...e.com>
To:	<mingo@...e.hu>, <tglx@...utronix.de>, <hpa@...or.com>
Cc:	<linux-kernel@...r.kernel.org>
Subject: [PATCH] x86: fix alignment determination in range_to_mtrr()

With the variable operated on being of "unsigned long" type, neither
ffs() nor fls() are suitable to use on them, as those truncate their
arguments to 32 bits. Using __ffs() and __fls() respectively at once
eliminates the need t subtract 1 from their results.

Additionally, with the alignment value subsequently used as a shift
count, it must be enforced to be less than BITS_PER_LONG (and on 64-bit
there's no need for it to be any smaller).

Signed-off-by: Jan Beulich <jbeulich@...e.com>

---
 arch/x86/kernel/cpu/mtrr/cleanup.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- 3.5-rc5/arch/x86/kernel/cpu/mtrr/cleanup.c
+++ 3.5-rc5-x86-mtrr-cleanup-types/arch/x86/kernel/cpu/mtrr/cleanup.c
@@ -258,11 +258,11 @@ range_to_mtrr(unsigned int reg, unsigned
 
 		/* Compute the maximum size with which we can make a range: */
 		if (range_startk)
-			max_align = ffs(range_startk) - 1;
+			max_align = __ffs(range_startk);
 		else
-			max_align = 32;
+			max_align = BITS_PER_LONG - 1;
 
-		align = fls(range_sizek) - 1;
+		align = __fls(range_sizek);
 		if (align > max_align)
 			align = max_align;
 



--
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