diff options
author | Andi Kleen <ak@suse.de> | 2006-10-05 12:47:22 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2006-10-05 12:47:22 -0400 |
commit | 51ec28e1b2cb267a09a0b8eac1ccf8d61b7268bf (patch) | |
tree | 4686d439a49b98b98fc5048641ddfb50db3fbcd6 /arch | |
parent | f015c6c4d733f68cbc1c5d231bb158abaa5c9606 (diff) |
[PATCH] x86: Terminate the kernel stacks for the unwinder
Always make sure RIP/EIP is 0 in the registers stored on the top
of the stack of a kernel thread. This makes sure the unwinder code
won't try a fallback but knows the stack has ended.
AK: this patch is a bit mysterious. in theory they should be terminated
anyways, but it seems to fix at least one crash. Anyways double termination
probably doesn't hurt.
Signed-off-by: Andi Kleen <ak@suse.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/i386/kernel/process.c | 6 | ||||
-rw-r--r-- | arch/x86_64/kernel/entry.S | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c index dad02a960e03..b0a07801d9df 100644 --- a/arch/i386/kernel/process.c +++ b/arch/i386/kernel/process.c | |||
@@ -328,6 +328,7 @@ extern void kernel_thread_helper(void); | |||
328 | int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) | 328 | int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) |
329 | { | 329 | { |
330 | struct pt_regs regs; | 330 | struct pt_regs regs; |
331 | int err; | ||
331 | 332 | ||
332 | memset(®s, 0, sizeof(regs)); | 333 | memset(®s, 0, sizeof(regs)); |
333 | 334 | ||
@@ -342,7 +343,10 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) | |||
342 | regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2; | 343 | regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2; |
343 | 344 | ||
344 | /* Ok, create the new process.. */ | 345 | /* Ok, create the new process.. */ |
345 | return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL); | 346 | err = do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL); |
347 | if (err == 0) /* terminate kernel stack */ | ||
348 | task_pt_regs(current)->eip = 0; | ||
349 | return err; | ||
346 | } | 350 | } |
347 | EXPORT_SYMBOL(kernel_thread); | 351 | EXPORT_SYMBOL(kernel_thread); |
348 | 352 | ||
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S index b8285cf1a9c3..ab9b2c4726f2 100644 --- a/arch/x86_64/kernel/entry.S +++ b/arch/x86_64/kernel/entry.S | |||
@@ -978,6 +978,11 @@ ENTRY(kernel_thread) | |||
978 | call do_fork | 978 | call do_fork |
979 | movq %rax,RAX(%rsp) | 979 | movq %rax,RAX(%rsp) |
980 | xorl %edi,%edi | 980 | xorl %edi,%edi |
981 | test %rax,%rax | ||
982 | jnz 1f | ||
983 | /* terminate stack in child */ | ||
984 | movq %rdi,RIP(%rsp) | ||
985 | 1: | ||
981 | 986 | ||
982 | /* | 987 | /* |
983 | * It isn't worth to check for reschedule here, | 988 | * It isn't worth to check for reschedule here, |