From: Ingo Molnar Date: Wed, 15 Oct 2008 11:46:29 +0000 (+0200) Subject: Merge branch 'linus' into stackprotector X-Git-Tag: v2.6.30-rc1~2^2~50^2~67^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2aaf8f74cdc84a9182f6cabf198b7763bcb9d40;p=platform%2Fkernel%2Flinux-3.10.git Merge branch 'linus' into stackprotector Conflicts: arch/x86/kernel/Makefile include/asm-x86/pda.h --- b2aaf8f74cdc84a9182f6cabf198b7763bcb9d40 diff --cc arch/x86/kernel/Makefile index d001739,0d41f03..50632e1 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@@ -13,21 -20,21 +20,22 @@@ endi nostackp := $(call cc-option, -fno-stack-protector) CFLAGS_vsyscall_64.o := $(PROFILING) -g0 $(nostackp) CFLAGS_hpet.o := $(nostackp) - CFLAGS_tsc_64.o := $(nostackp) + CFLAGS_tsc.o := $(nostackp) +CFLAGS_paravirt.o := $(nostackp) obj-y := process_$(BITS).o signal_$(BITS).o entry_$(BITS).o - obj-y += traps_$(BITS).o irq_$(BITS).o + obj-y += traps.o irq_$(BITS).o dumpstack_$(BITS).o obj-y += time_$(BITS).o ioport.o ldt.o - obj-y += setup_$(BITS).o i8259_$(BITS).o setup.o + obj-y += setup.o i8259.o irqinit_$(BITS).o setup_percpu.o + obj-$(CONFIG_X86_VISWS) += visws_quirks.o + obj-$(CONFIG_X86_32) += probe_roms_32.o obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o - obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o setup64.o - obj-y += bootflag.o e820_$(BITS).o + obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o + obj-y += bootflag.o e820.o obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o obj-y += alternative.o i8253.o pci-nommu.o - obj-$(CONFIG_X86_64) += bugs_64.o - obj-y += tsc_$(BITS).o io_delay.o rtc.o + obj-y += tsc.o io_delay.o rtc.o obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o obj-y += process.o diff --cc arch/x86/kernel/process_64.c index f73cfbc,cd8c0ed..749d5f8 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@@ -147,27 -102,13 +103,24 @@@ static inline void play_dead(void 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): + */ + boot_init_stack_canary(); + /* endless idle loop with no priority at all */ while (1) { - tick_nohz_stop_sched_tick(); + tick_nohz_stop_sched_tick(1); while (!need_resched()) { - void (*idle)(void); rmb(); - idle = pm_idle; - if (!idle) - idle = default_idle; + if (cpu_is_offline(smp_processor_id())) play_dead(); /* @@@ -648,11 -634,13 +646,12 @@@ __switch_to(struct task_struct *prev_p */ prev->usersp = read_pda(oldrsp); write_pda(oldrsp, next->usersp); - write_pda(pcurrent, next_p); + write_pda(pcurrent, next_p); write_pda(kernelstack, - (unsigned long)task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET); + (unsigned long)task_stack_page(next_p) + + THREAD_SIZE - PDA_STACKOFFSET); #ifdef CONFIG_CC_STACKPROTECTOR - write_pda(stack_canary, next_p->stack_canary); /* * Build time only check to make sure the stack_canary is at * offset 40 in the pda; this is a gcc ABI requirement diff --cc include/asm-x86/pda.h index a5ff5bb,80860af..45fd2ae --- a/include/asm-x86/pda.h +++ b/include/asm-x86/pda.h @@@ -19,7 -19,11 +19,9 @@@ struct x8664_pda unsigned long stack_canary; /* 40 stack canary value */ /* gcc-ABI: this canary MUST be at offset 40!!! */ -#endif char *irqstackptr; + short nodenumber; /* number of current node (32k max) */ + short in_bootmem; /* pda lives in bootmem */ unsigned int __softirq_pending; unsigned int __nmi_count; /* number of NMI on this CPUs */ short mmu_state; @@@ -131,5 -134,4 +132,6 @@@ do { #define PDA_STACKOFFSET (5*8) +#define refresh_stack_canary() write_pda(stack_canary, current->stack_canary) - #endif ++ + #endif /* ASM_X86__PDA_H */ diff --cc include/linux/sched.h index f0132f9,c226c7b..1a7e846 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@@ -1968,21 -1965,15 +1964,28 @@@ static inline unsigned long *end_of_sta #endif + static inline int object_is_on_stack(void *obj) + { + void *stack = task_stack_page(current); + + return (obj >= stack) && (obj < (stack + THREAD_SIZE)); + } + extern void thread_info_cache_init(void); +#ifdef CONFIG_DEBUG_STACK_USAGE +static inline unsigned long stack_not_used(struct task_struct *p) +{ + unsigned long *n = end_of_stack(p); + + do { /* Skip over canary */ + n++; + } while (!*n); + + return (unsigned long)n - (unsigned long)end_of_stack(p); +} +#endif + /* set thread flags in other task's structures * - see asm/thread_info.h for TIF_xxxx flags available */