]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
x86_64: Record stack pointer before task execution begins
authorSiddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
Sun, 26 Feb 2012 16:17:55 +0000 (21:47 +0530)
committerH. Peter Anvin <hpa@zytor.com>
Sun, 26 Feb 2012 20:59:04 +0000 (12:59 -0800)
task->thread.usersp is unusable immediately after a binary is exec()'d
until it undergoes a context switch cycle. The start_thread() function
called during execve() saves the stack pointer into pt_regs and into
old_rsp, but fails to record it into task->thread.usersp.

Because of this, KSTK_ESP(task) returns an incorrect value for a
64-bit program until the task is switched out and back in since
switch_to swaps %rsp values in and out into task->thread.usersp.

Signed-off-by: Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
Link: http://lkml.kernel.org/r/1330273075-2949-1-git-send-email-siddhesh.poyarekar@gmail.com
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
arch/x86/kernel/process_64.c

index 1fd94bc4279d60472a34feea7c792e5e70b013d8..eb54dd0fbed6f2b790c83f505504de5ff4472752 100644 (file)
@@ -341,6 +341,7 @@ start_thread_common(struct pt_regs *regs, unsigned long new_ip,
        loadsegment(es, _ds);
        loadsegment(ds, _ds);
        load_gs_index(0);
+       current->thread.usersp  = new_sp;
        regs->ip                = new_ip;
        regs->sp                = new_sp;
        percpu_write(old_rsp, new_sp);