From f72c22e45e8f8fe78c7f793d983bee5bed63497e Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Mon, 23 Sep 2013 17:38:02 +0200 Subject: um: Make stack trace reliable against kernel mode faults As UML uses an alternative signal stack we cannot use the current stack pointer for stack dumping if UML itself dies by SIGSEGV. To bypass this issue we save regs taken from mcontext in our segv handler into thread_struct and use these regs to obtain the stack pointer in show_stack(). Signed-off-by: Richard Weinberger --- arch/um/include/asm/processor-generic.h | 1 + arch/um/include/shared/os.h | 1 + 2 files changed, 2 insertions(+) (limited to 'arch/um/include') diff --git a/arch/um/include/asm/processor-generic.h b/arch/um/include/asm/processor-generic.h index c03cd5a0236..90469031297 100644 --- a/arch/um/include/asm/processor-generic.h +++ b/arch/um/include/asm/processor-generic.h @@ -21,6 +21,7 @@ struct mm_struct; struct thread_struct { struct task_struct *saved_task; struct pt_regs regs; + struct pt_regs *segv_regs; int singlestep_syscall; void *fault_addr; jmp_buf *fault_catcher; diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 021104d98cb..75298d3358e 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h @@ -227,6 +227,7 @@ extern void block_signals(void); extern void unblock_signals(void); extern int get_signals(void); extern int set_signals(int enable); +extern int os_is_signal_stack(void); /* util.c */ extern void stack_protections(unsigned long address); -- cgit v1.2.3-70-g09d2 From a1850e9c7282db1c19a18093a945d5e84bfe7418 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Mon, 23 Sep 2013 17:38:03 +0200 Subject: um: Get rid of thread_struct->saved_task As we have a sane show_stack() now, we can drop the ->saved_task hack. Signed-off-by: Richard Weinberger --- arch/um/drivers/mconsole_kern.c | 6 ++---- arch/um/include/asm/processor-generic.h | 1 - arch/um/kernel/process.c | 15 ++------------- 3 files changed, 4 insertions(+), 18 deletions(-) (limited to 'arch/um/include') diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index 3df3bd54449..29880c9b324 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c @@ -645,11 +645,9 @@ void mconsole_sysrq(struct mc_request *req) static void stack_proc(void *arg) { - struct task_struct *from = current, *to = arg; + struct task_struct *task = arg; - to->thread.saved_task = from; - rcu_user_hooks_switch(from, to); - switch_to(from, to, from); + show_stack(task, NULL); } /* diff --git a/arch/um/include/asm/processor-generic.h b/arch/um/include/asm/processor-generic.h index 90469031297..d89b02bb626 100644 --- a/arch/um/include/asm/processor-generic.h +++ b/arch/um/include/asm/processor-generic.h @@ -19,7 +19,6 @@ struct task_struct; struct mm_struct; struct thread_struct { - struct task_struct *saved_task; struct pt_regs regs; struct pt_regs *segv_regs; int singlestep_syscall; diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index bbcef522bcb..eecc4142764 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -82,19 +82,8 @@ void *__switch_to(struct task_struct *from, struct task_struct *to) to->thread.prev_sched = from; set_current(to); - do { - current->thread.saved_task = NULL; - - switch_threads(&from->thread.switch_buf, - &to->thread.switch_buf); - - arch_switch_to(current); - - if (current->thread.saved_task) - show_regs(&(current->thread.regs)); - to = current->thread.saved_task; - from = current; - } while (current->thread.saved_task); + switch_threads(&from->thread.switch_buf, &to->thread.switch_buf); + arch_switch_to(current); return current->thread.prev_sched; } -- cgit v1.2.3-70-g09d2 From 33a7d42999b1857d4494f6ad6367e3aef0ae8137 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 12 Nov 2013 20:42:27 +0100 Subject: um: Remove unused declarations from _end is used, but it's already provided by , so use that. Signed-off-by: Geert Uytterhoeven Cc: Richard Weinberger Cc: user-mode-linux-devel@lists.sourceforge.net Signed-off-by: Richard Weinberger --- arch/um/include/shared/as-layout.h | 3 --- arch/um/kernel/um_arch.c | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'arch/um/include') diff --git a/arch/um/include/shared/as-layout.h b/arch/um/include/shared/as-layout.h index 694c792bab4..41c8c774ec1 100644 --- a/arch/um/include/shared/as-layout.h +++ b/arch/um/include/shared/as-layout.h @@ -44,7 +44,6 @@ struct cpu_task { extern struct cpu_task cpu_tasks[]; -extern unsigned long low_physmem; extern unsigned long high_physmem; extern unsigned long uml_physmem; extern unsigned long uml_reserved; @@ -52,8 +51,6 @@ extern unsigned long end_vm; extern unsigned long start_vm; extern unsigned long long highmem; -extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end; -extern unsigned long _unprotected_end; extern unsigned long brk_start; extern unsigned long host_task_size; diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index b9dd13e6f20..016adf0985d 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3-70-g09d2