* [PATCH] ia64: fix user_stack_pointer() for ptrace()
@ 2021-03-31 8:44 Sergei Trofimovich
2021-04-01 0:49 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Trofimovich @ 2021-03-31 8:44 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, Sergei Trofimovich, Oleg Nesterov, linux-ia64,
Dmitry V . Levin
ia64 has two stacks:
- memory stack (or stack), pointed at by by r12
- register backing store (register stack), pointed at
ar.bsp/ar.bspstore with complications around dirty
register frame on CPU.
In https://bugs.gentoo.org/769614 Dmitry noticed that
PTRACE_GET_SYSCALL_INFO returns 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.
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Oleg Nesterov <oleg@redhat.com>
CC: linux-ia64@vger.kernel.org
Bug: https://bugs.gentoo.org/769614
Reported-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
---
arch/ia64/include/asm/ptrace.h | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/arch/ia64/include/asm/ptrace.h b/arch/ia64/include/asm/ptrace.h
index b3aa46090101..08179135905c 100644
--- a/arch/ia64/include/asm/ptrace.h
+++ b/arch/ia64/include/asm/ptrace.h
@@ -54,8 +54,7 @@
static inline unsigned long user_stack_pointer(struct pt_regs *regs)
{
- /* FIXME: should this be bspstore + nr_dirty regs? */
- return regs->ar_bspstore;
+ return regs->r12;
}
static inline int is_syscall_success(struct pt_regs *regs)
@@ -79,11 +78,6 @@ static inline long regs_return_value(struct pt_regs *regs)
unsigned long __ip = instruction_pointer(regs); \
(__ip & ~3UL) + ((__ip & 3UL) << 2); \
})
-/*
- * Why not default? Because user_stack_pointer() on ia64 gives register
- * stack backing store instead...
- */
-#define current_user_stack_pointer() (current_pt_regs()->r12)
/* given a pointer to a task_struct, return the user's pt_regs */
# define task_pt_regs(t) (((struct pt_regs *) ((char *) (t) + IA64_STK_OFFSET)) - 1)
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ia64: fix user_stack_pointer() for ptrace()
2021-03-31 8:44 [PATCH] ia64: fix user_stack_pointer() for ptrace() Sergei Trofimovich
@ 2021-04-01 0:49 ` Andrew Morton
2021-04-01 6:28 ` Sergei Trofimovich
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2021-04-01 0:49 UTC (permalink / raw)
To: Sergei Trofimovich
Cc: linux-kernel, Oleg Nesterov, linux-ia64, Dmitry V . Levin
On Wed, 31 Mar 2021 09:44:47 +0100 Sergei Trofimovich <slyfox@gentoo.org> wrote:
> ia64 has two stacks:
> - memory stack (or stack), pointed at by by r12
> - register backing store (register stack), pointed at
> ar.bsp/ar.bspstore with complications around dirty
> register frame on CPU.
>
> In https://bugs.gentoo.org/769614 Dmitry noticed that
> PTRACE_GET_SYSCALL_INFO returns 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.
>
I assume a cc:stable is justified here?
The bug seems to have been there for 10+ years, so there isn't a lot of
point in looking for the Fixes: reference.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ia64: fix user_stack_pointer() for ptrace()
2021-04-01 0:49 ` Andrew Morton
@ 2021-04-01 6:28 ` Sergei Trofimovich
0 siblings, 0 replies; 3+ messages in thread
From: Sergei Trofimovich @ 2021-04-01 6:28 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Oleg Nesterov, linux-ia64, Dmitry V . Levin
On Wed, 31 Mar 2021 17:49:08 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:
> On Wed, 31 Mar 2021 09:44:47 +0100 Sergei Trofimovich <slyfox@gentoo.org> wrote:
>
> > ia64 has two stacks:
> > - memory stack (or stack), pointed at by by r12
> > - register backing store (register stack), pointed at
> > ar.bsp/ar.bspstore with complications around dirty
> > register frame on CPU.
> >
> > In https://bugs.gentoo.org/769614 Dmitry noticed that
> > PTRACE_GET_SYSCALL_INFO returns 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.
> >
>
> I assume a cc:stable is justified here?
>
> The bug seems to have been there for 10+ years, so there isn't a lot of
> point in looking for the Fixes: reference.
Yes, I think cc:stable is fine.
--
Sergei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-01 6:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 8:44 [PATCH] ia64: fix user_stack_pointer() for ptrace() Sergei Trofimovich
2021-04-01 0:49 ` Andrew Morton
2021-04-01 6:28 ` Sergei Trofimovich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).