qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: Fix incorrect offset of tuc_stack in ARM do_sigframe_return_v2
@ 2016-09-09 18:35 Timothy E Baldwin
  2016-09-09 20:02 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Timothy E Baldwin @ 2016-09-09 18:35 UTC (permalink / raw)
  To: QEMU Developers, Peter Maydell; +Cc: Timothy E Baldwin, Riku Voipio

struct target_ucontext_v2 is not at the begining of the signal frame,
therefore do_sigaltstack was being passed bogus arguments.

As the offset depends on the type of signal frame fixed by passing in the
beginning of the context from do_sigreturn_v2 and do_rt_sigreturn_v2.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
---

Changes since v2:
 Change do_sigreturn_v2 and do_rt_sigreturn_v2 to pass in context.
 Rename frame_addr to context_addr

 linux-user/signal.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 9a4d894..b5cdb25 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -2035,7 +2035,8 @@ static abi_ulong *restore_sigframe_v2_iwmmxt(CPUARMState *env,
     return (abi_ulong*)(iwmmxtframe + 1);
 }
 
-static int do_sigframe_return_v2(CPUARMState *env, target_ulong frame_addr,
+static int do_sigframe_return_v2(CPUARMState *env,
+                                 target_ulong context_addr,
                                  struct target_ucontext_v2 *uc)
 {
     sigset_t host_set;
@@ -2062,8 +2063,11 @@ static int do_sigframe_return_v2(CPUARMState *env, target_ulong frame_addr,
         }
     }
 
-    if (do_sigaltstack(frame_addr + offsetof(struct target_ucontext_v2, tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT)
+    if (do_sigaltstack(context_addr
+                       + offsetof(struct target_ucontext_v2, tuc_stack),
+                       0, get_sp_from_cpustate(env)) == -EFAULT) {
         return 1;
+    }
 
 #if 0
     /* Send SIGTRAP if we're single-stepping */
@@ -2094,7 +2098,10 @@ static long do_sigreturn_v2(CPUARMState *env)
         goto badframe;
     }
 
-    if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) {
+    if (do_sigframe_return_v2(env,
+                              frame_addr
+                              + offsetof(struct sigframe_v2, uc),
+                              &frame->uc)) {
         goto badframe;
     }
 
@@ -2181,7 +2188,10 @@ static long do_rt_sigreturn_v2(CPUARMState *env)
         goto badframe;
     }
 
-    if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) {
+    if (do_sigframe_return_v2(env,
+                              frame_addr
+                              + offsetof(struct rt_sigframe_v2, uc),
+                              &frame->uc)) {
         goto badframe;
     }
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: Fix incorrect offset of tuc_stack in ARM do_sigframe_return_v2
  2016-09-09 18:35 [Qemu-devel] [PATCH] linux-user: Fix incorrect offset of tuc_stack in ARM do_sigframe_return_v2 Timothy E Baldwin
@ 2016-09-09 20:02 ` Peter Maydell
  2016-09-21 19:17   ` Riku Voipio
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2016-09-09 20:02 UTC (permalink / raw)
  To: Timothy E Baldwin; +Cc: QEMU Developers, Riku Voipio

On 9 September 2016 at 19:35, Timothy E Baldwin
<T.E.Baldwin99@members.leeds.ac.uk> wrote:
> struct target_ucontext_v2 is not at the begining of the signal frame,
> therefore do_sigaltstack was being passed bogus arguments.
>
> As the offset depends on the type of signal frame fixed by passing in the
> beginning of the context from do_sigreturn_v2 and do_rt_sigreturn_v2.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
> ---

Thanks for the respin.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: Fix incorrect offset of tuc_stack in ARM do_sigframe_return_v2
  2016-09-09 20:02 ` Peter Maydell
@ 2016-09-21 19:17   ` Riku Voipio
  0 siblings, 0 replies; 3+ messages in thread
From: Riku Voipio @ 2016-09-21 19:17 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Timothy E Baldwin, QEMU Developers

On Fri, Sep 09, 2016 at 09:02:55PM +0100, Peter Maydell wrote:
> On 9 September 2016 at 19:35, Timothy E Baldwin
> <T.E.Baldwin99@members.leeds.ac.uk> wrote:
> > struct target_ucontext_v2 is not at the begining of the signal frame,
> > therefore do_sigaltstack was being passed bogus arguments.
> >
> > As the offset depends on the type of signal frame fixed by passing in the
> > beginning of the context from do_sigreturn_v2 and do_rt_sigreturn_v2.
> >
> > Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> > Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
> > ---
> 
> Thanks for the respin.
> 
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Applied to linux-user que, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-21 19:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-09 18:35 [Qemu-devel] [PATCH] linux-user: Fix incorrect offset of tuc_stack in ARM do_sigframe_return_v2 Timothy E Baldwin
2016-09-09 20:02 ` Peter Maydell
2016-09-21 19:17   ` Riku Voipio

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).