Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 136761
b: refs/heads/master
c: 5c79d2a
h: refs/heads/master
i:
  136759: c9ac8b3
v: v3
  • Loading branch information
Tejun Heo authored and Ingo Molnar committed Feb 11, 2009
1 parent cd870cc commit acb9c30
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 60a5317ff0f42dd313094b88f809f63041568b08
refs/heads/master: 5c79d2a517a9905599d192db8ce77ab5f1a2faca
2 changes: 1 addition & 1 deletion trunk/arch/x86/include/asm/stackprotector.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static __always_inline void boot_init_stack_canary(void)
static inline void setup_stack_canary_segment(int cpu)
{
#ifdef CONFIG_X86_32
unsigned long canary = (unsigned long)&per_cpu(stack_canary, cpu);
unsigned long canary = (unsigned long)&per_cpu(stack_canary, cpu) - 20;
struct desc_struct *gdt_table = get_cpu_gdt_table(cpu);
struct desc_struct desc;

Expand Down
8 changes: 3 additions & 5 deletions trunk/arch/x86/include/asm/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ struct task_struct *__switch_to(struct task_struct *prev,

#ifdef CONFIG_CC_STACKPROTECTOR
#define __switch_canary \
"movl "__percpu_arg([current_task])",%%ebx\n\t" \
"movl %P[task_canary](%%ebx),%%ebx\n\t" \
"movl %%ebx,"__percpu_arg([stack_canary])"\n\t"
"movl %P[task_canary](%[next]), %%ebx\n\t" \
"movl %%ebx, "__percpu_arg([stack_canary])"\n\t"
#define __switch_canary_oparam \
, [stack_canary] "=m" (per_cpu_var(stack_canary))
#define __switch_canary_iparam \
, [current_task] "m" (per_cpu_var(current_task)) \
, [task_canary] "i" (offsetof(struct task_struct, stack_canary))
#else /* CC_STACKPROTECTOR */
#define __switch_canary
Expand Down Expand Up @@ -60,9 +58,9 @@ do { \
"movl %[next_sp],%%esp\n\t" /* restore ESP */ \
"movl $1f,%[prev_ip]\n\t" /* save EIP */ \
"pushl %[next_ip]\n\t" /* restore EIP */ \
__switch_canary \
"jmp __switch_to\n" /* regparm call */ \
"1:\t" \
__switch_canary \
"popl %%ebp\n\t" /* restore EBP */ \
"popfl\n" /* restore flags */ \
\
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/x86/kernel/head_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ is386: movl $2,%ecx # set MP
jne 1f
movl $per_cpu__gdt_page,%eax
movl $per_cpu__stack_canary,%ecx
subl $20, %ecx
movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
shrl $16, %ecx
movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
Expand Down
10 changes: 10 additions & 0 deletions trunk/arch/x86/kernel/process_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <stdarg.h>

#include <linux/stackprotector.h>
#include <linux/cpu.h>
#include <linux/errno.h>
#include <linux/sched.h>
Expand Down Expand Up @@ -91,6 +92,15 @@ void cpu_idle(void)
{
int cpu = smp_processor_id();

/*
* If we're the non-boot CPU, nothing set the stack canary up
* for us. CPU0 already has it initialized but no harm in
* doing it again. This is a good place for updating it, as
* we wont ever return from this function (so the invalid
* canaries already on the stack wont ever trigger).
*/
boot_init_stack_canary();

current_thread_info()->status |= TS_POLLING;

/* endless idle loop with no priority at all */
Expand Down
11 changes: 5 additions & 6 deletions trunk/arch/x86/kernel/process_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,11 @@ void cpu_idle(void)
current_thread_info()->status |= TS_POLLING;

/*
* If we're the non-boot CPU, nothing set the PDA stack
* canary up for us - and if we are the boot CPU we have
* a 0 stack canary. This is a good place for updating
* it, as we wont ever return from this function (so the
* invalid canaries already on the stack wont ever
* trigger):
* If we're the non-boot CPU, nothing set the stack canary up
* for us. CPU0 already has it initialized but no harm in
* doing it again. This is a good place for updating it, as
* we wont ever return from this function (so the invalid
* canaries already on the stack wont ever trigger).
*/
boot_init_stack_canary();

Expand Down

0 comments on commit acb9c30

Please sign in to comment.