Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lguest: fix 'unhandled trap 13' with CONFIG_CC_STACKPROTECTOR

We don't set up the canary; let's disable stack protector on boot.c so
we can get into lguest_init, then set it up. As a side effect,
switch_to_new_gdt() sets up %fs for us properly too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Rusty Russell and committed by
Linus Torvalds
2cb7878a 9fa7eb28

+14 -4
+1
arch/x86/lguest/Makefile
··· 1 1 obj-y := i386_head.o boot.o 2 + CFLAGS_boot.o := $(call cc-option, -fno-stack-protector)
+13 -4
arch/x86/lguest/boot.c
··· 67 67 #include <asm/mce.h> 68 68 #include <asm/io.h> 69 69 #include <asm/i387.h> 70 + #include <asm/stackprotector.h> 70 71 #include <asm/reboot.h> /* for struct machine_ops */ 71 72 72 73 /*G:010 Welcome to the Guest! ··· 1089 1088 * lguest_init() where the rest of the fairly chaotic boot setup 1090 1089 * occurs. */ 1091 1090 1091 + /* The stack protector is a weird thing where gcc places a canary 1092 + * value on the stack and then checks it on return. This file is 1093 + * compiled with -fno-stack-protector it, so we got this far without 1094 + * problems. The value of the canary is kept at offset 20 from the 1095 + * %gs register, so we need to set that up before calling C functions 1096 + * in other files. */ 1097 + setup_stack_canary_segment(0); 1098 + /* We could just call load_stack_canary_segment(), but we might as 1099 + * call switch_to_new_gdt() which loads the whole table and sets up 1100 + * the per-cpu segment descriptor register %fs as well. */ 1101 + switch_to_new_gdt(0); 1102 + 1092 1103 /* As described in head_32.S, we map the first 128M of memory. */ 1093 1104 max_pfn_mapped = (128*1024*1024) >> PAGE_SHIFT; 1094 - 1095 - /* Load the %fs segment register (the per-cpu segment register) with 1096 - * the normal data segment to get through booting. */ 1097 - asm volatile ("mov %0, %%fs" : : "r" (__KERNEL_DS) : "memory"); 1098 1105 1099 1106 /* The Host<->Guest Switcher lives at the top of our address space, and 1100 1107 * the Host told us how big it is when we made LGUEST_INIT hypercall: