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

arm64: report correct stack pointer in KSTK_ESP for compat tasks

The KSTK_ESP macro is used to determine the user stack pointer for a
given task. In particular, this is used to to report the '[stack]' VMA
in /proc/self/maps, which is used by Android to determine the stack
location for children of the main thread.

This patch fixes the macro to use user_stack_pointer instead of directly
returning sp. This means that we report w13 instead of sp, since the
former is used as the stack pointer when executing in AArch32 state.

Cc: <stable@vger.kernel.org>
Reported-by: Serban Constantinescu <Serban.Constantinescu@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>

+1 -1
+1 -1
arch/arm64/include/asm/processor.h
··· 139 139 ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1) 140 140 141 141 #define KSTK_EIP(tsk) ((unsigned long)task_pt_regs(tsk)->pc) 142 - #define KSTK_ESP(tsk) ((unsigned long)task_pt_regs(tsk)->sp) 142 + #define KSTK_ESP(tsk) user_stack_pointer(task_pt_regs(tsk)) 143 143 144 144 /* 145 145 * Prefetching support