Skip to content

Commit 7ad1e36

Browse files
Sergei Trofimovichtorvalds
authored andcommitted
ia64: fix user_stack_pointer() for ptrace()
ia64 has two stacks: - memory stack (or stack), pointed at by by r12 - register backing store (register stack), pointed at by ar.bsp/ar.bspstore with complications around dirty register frame on CPU. In [1] Dmitry noticed that PTRACE_GET_SYSCALL_INFO returns the register stack instead memory stack. The bug comes from the fact that user_stack_pointer() and current_user_stack_pointer() don't return the same register: ulong user_stack_pointer(struct pt_regs *regs) { return regs->ar_bspstore; } #define current_user_stack_pointer() (current_pt_regs()->r12) The change gets both back in sync. I think ptrace(PTRACE_GET_SYSCALL_INFO) is the only affected user by this bug on ia64. The change fixes 'rt_sigreturn.gen.test' strace test where it was observed initially. Link: https://bugs.gentoo.org/769614 [1] Link: https://lkml.kernel.org/r/20210331084447.2561532-1-slyfox@gentoo.org Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Reported-by: Dmitry V. Levin <ldv@altlinux.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 90bd070 commit 7ad1e36

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

arch/ia64/include/asm/ptrace.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454

5555
static inline unsigned long user_stack_pointer(struct pt_regs *regs)
5656
{
57-
/* FIXME: should this be bspstore + nr_dirty regs? */
58-
return regs->ar_bspstore;
57+
return regs->r12;
5958
}
6059

6160
static inline int is_syscall_success(struct pt_regs *regs)
@@ -79,11 +78,6 @@ static inline long regs_return_value(struct pt_regs *regs)
7978
unsigned long __ip = instruction_pointer(regs); \
8079
(__ip & ~3UL) + ((__ip & 3UL) << 2); \
8180
})
82-
/*
83-
* Why not default? Because user_stack_pointer() on ia64 gives register
84-
* stack backing store instead...
85-
*/
86-
#define current_user_stack_pointer() (current_pt_regs()->r12)
8781

8882
/* given a pointer to a task_struct, return the user's pt_regs */
8983
# define task_pt_regs(t) (((struct pt_regs *) ((char *) (t) + IA64_STK_OFFSET)) - 1)

0 commit comments

Comments
 (0)