Skip to contentSkip to conversation

i386/x86-64: Don't randomize stack top when no randomization personality

PATCH Al Boldi 1 participant 1 message Jul 17, 2006

lore
Share & tools
lore

Al Boldi

author
#0 lore raw
Quoted 10 lines · Ingo Molnar
Quoted 6 lines · Andi Kleen

unsigned long arch_align_stack(unsigned long sp)
{

(quoted diff) +1 -1
-     if (randomize_va_space)
+     if (!(current->personality & ADDR_NO_RANDOMIZE) &&
randomize_va_space) sp -= get_random_int() % 8192;
      return sp & ~0xf;

i'm not opposing this patch at all, but didnt the performance problems go away when the 0xf was changed to 0x7f?

Yes, 0x7f is critical, but I'm not sure about side-effects.

Quoted 1 line

looks good otherwise.

except this one

fs/binfmt_elf.c static unsigned long randomize_stack_top · line 522

Quoted 12 lines
fs/binfmt_elf.c +2 -1
@@ -515,7 +515,8 @@ static unsigned long randomize_stack_top
 {
        unsigned int random_variable = 0;
 
-       if (current->flags & PF_RANDOMIZE) {
+       if ((current->flags & PF_RANDOMIZE) &&
+               !(current->personality & ADDR_NO_RANDOMIZE)) {
                random_variable = get_random_int() & STACK_RND_MASK;
                random_variable <<= PAGE_SHIFT;
        }

Why are you testing twice?

Thanks!

--
Al