Skip to contentSkip to conversation

Fix do_rt_sigreturn on m68k linux userspace emulation

PATCH In review Michael Karcher 2 participants 3 messages Dec 12, 2015

lore
Share & tools
lore
#0 lore raw

v2 cover Fix do_rt_sigreturn on m68k linux userspace emulation

Changelog:
v2: Avoid unneeded copy, use correct endianness.

Michael Karcher (1):
Fix do_rt_sigreturn on m68k linux userspace emulation

 linux-user/signal.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH v2 1/1 Fix do_rt_sigreturn on m68k linux userspace emulation

do_rt_sigreturn uses an uninitialised local variable instead of fetching the old signal mask directly from the signal frame when restoring the mask, so the signal mask is undefined after do_rt_sigreturn. As the signal frame data is in target-endian order, target_to_host_sigset instead of target_to_host_sigset_internal is required.

do_sigreturn is correct in using target_to_host_sigset_internal, because get_user already did the endianness conversion.

---
 linux-user/signal.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
linux-user/signal.c +1 -2
index e03ed60..13f9142 100644
@@ -5258,14 +5258,13 @@ long do_rt_sigreturn(CPUM68KState *env)
 {
     struct target_rt_sigframe *frame;
     abi_ulong frame_addr = env->aregs[7] - 4;
-    target_sigset_t target_set;
     sigset_t set;
     int d0;
 
     if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
         goto badframe;
 
-    target_to_host_sigset_internal(&set, &target_set);
+    target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
     do_sigprocmask(SIG_SETMASK, &set, NULL);
 
     /* restore registers */
Signature · 1 line
2.1.4
Reviewed-by Tested-by on v2 1/1
#2 lore raw
Quoted 25 lines · Michael Karcher

do_rt_sigreturn uses an uninitialised local variable instead of fetching the old signal mask directly from the signal frame when restoring the mask, so the signal mask is undefined after do_rt_sigreturn. As the signal frame data is in target-endian order, target_to_host_sigset instead of target_to_host_sigset_internal is required.

do_sigreturn is correct in using target_to_host_sigset_internal, because get_user already did the endianness conversion.

---
 linux-user/signal.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
linux-user/signal.c +0 -1
index e03ed60..13f9142 100644
@@ -5258,14 +5258,13 @@ long do_rt_sigreturn(CPUM68KState *env)
 {
     struct target_rt_sigframe *frame;
     abi_ulong frame_addr = env->aregs[7] - 4;
-    target_sigset_t target_set;
     sigset_t set;

linux-user/signal.c long do_rt_sigreturn(CPUM68KState *env) · line 5270

Quoted 10 lines
linux-user/signal.c +1 -1
     int d0;
 
     if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
         goto badframe;
 
-    target_to_host_sigset_internal(&set, &target_set);
+    target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
     do_sigprocmask(SIG_SETMASK, &set, NULL);
 
     /* restore registers */