[Devel,RHEL7,COMMIT] ms/x86: Fix norandmaps/ADDR_NO_RANDOMIZE

Submitted by Konstantin Khorenko on Sept. 1, 2017, 8 a.m.

Details

Message ID 201709010800.v8180U53007754@finist_ce7.work
State New
Headers show

Patch hide | download patch | download mbox

diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index a1656c8..22026df 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -81,14 +81,14 @@  static int mmap_is_legacy(void)
 
 static unsigned long arch_rnd(unsigned int rndbits)
 {
+	if (!(current->flags & PF_RANDOMIZE))
+		return 0;
 	return ((unsigned long)get_random_int() &
 			((1UL << rndbits) - 1)) << PAGE_SHIFT;
 }
 
 unsigned long arch_mmap_rnd(void)
 {
-	if (!(current->flags & PF_RANDOMIZE))
-		return 0;
 	return arch_rnd(mmap_is_ia32() ? mmap32_rnd_bits : mmap64_rnd_bits);
 }