i386/x86-64: Don't randomize stack top when no randomization personality is set
Subsystems (2)
PATCH 2/8 i386/x86-64: Don't randomize stack top when no randomization personality is set
Based on patch from Frank van Maarseveen <[email protected]>, but extended.
--- arch/i386/kernel/process.c | 3 ++- arch/x86_64/kernel/process.c | 2 +- fs/binfmt_elf.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-)
arch/x86_64/kernel/process.c +1 -1
@@ -845,7 +845,7 @@ int dump_task_regs(struct task_struct *tunsigned 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 ; }
arch/i386/kernel/process.c +2 -1
@@ -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(strucunsigned 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 ; }
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 ; }
arch/x86_64/kernel/process.c int dump_task_regs(struct task_struct *t · line 850
Quoted 6 lines · Andi Kleen
unsigned long
arch_align_stack(unsigned long sp)
{arch/x86_64/kernel/process.c +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?
looks good otherwise.
Ingo
Quoted 10 lines · Ingo Molnar
arch/x86_64/kernel/process.c int dump_task_regs(struct task_struct *t · line 850
Quoted 6 lines · Andi Kleen
unsigned long
arch_align_stack(unsigned long sp)
{arch/x86_64/kernel/process.c +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
0xfwas changed to0x7f?
Yes, but i sent the patch before that other patch was available.
I guess it's a separate issue anyways - this patch is just concerned about disabling randomization consistently. Performance optimization can be done in another one.
-Andi
Quoted 12 lines · Andi Kleen
Quoted 10 lines · Ingo Molnar
arch/x86_64/kernel/process.c int dump_task_regs(struct task_struct *t · line 850
Quoted 6 lines · Andi Kleen
unsigned long
arch_align_stack(unsigned long sp)
{arch/x86_64/kernel/process.c +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
0xfwas changed to0x7f?
Quoted 1 line
Yes, but i sent the patch before that other patch was available.
excuses, excuses ;)
Quoted 3 lines
I guess it's a separate issue anyways - this patch is just concerned about disabling randomization consistently. Performance optimization can be done in another one.
yeah. There's one security issue: the 'dont randomize' flag must be cleared when we cross a protection domain. When for example suid-ing in exec().
Ingo
Quoted 4 lines
yeah. There's one security issue: the 'dont randomize' flag must be cleared when we cross a protection domain. When for example suid-ing in
exec().
Good point.
-Andi
Re: [discuss] Re: [PATCH for 2.6.18-rc2] [2/8] i386/x86-64: Don't randomize stack top when no randomization personality is set II
In reply to Ingo MolnarQuoted 4 lines
yeah. There's one security issue: the 'dont randomize' flag must be cleared when we cross a protection domain. When for example suid-ing in
exec().
Just checked. It should be already done because ADDR_NO_RANDOMIZE is in PER_CLEAR_ON_SETID which is cleared in exec.
-Andi