lkml.org 
[lkml]   [2006]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject[PATCH for 2.6.18rc2] [1/7] i386/x86-64: Don't randomize stack top when...
In-Reply-To: <44c514a8.6HlRR82y133O2bd0%ak@suse.de>

On Mon, 24 Jul 2006 20:42:48 +0200, Andi Kleen wrote:
>
> --- linux.orig/arch/i386/kernel/process.c
> +++ linux/arch/i386/kernel/process.c
> @@ -37,6 +37,7 @@
> #include <linux/kallsyms.h>
> #include <linux/ptrace.h>
> #include <linux/random.h>
> +#include <linux/personality.h>
>
> #include <asm/uaccess.h>
> #include <asm/pgtable.h>
> @@ -905,7 +906,7 @@ asmlinkage int sys_get_thread_area(struc
>
> unsigned long arch_align_stack(unsigned long sp)
> {
> - if (randomize_va_space)
> + if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
> sp -= get_random_int() % 8192;
> return sp & ~0xf;
> }

I think this needs to be done always, at least on P4. It really isn't
'randomization' at the same high level as the rest -- more like a small
adjustment. And the offset should be a multiple of 128 and < 7K (not
8K.) Something like this:

unsigned int r = get_random_int();
sp &= ~0x7f;
sp -= 128 * ((r % 32) + (r / 32 % 16));
return sp;

--
Chuck

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

\
 
 \ /
  Last update: 2006-07-25 09:55    [W:6.427 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site