Skip to content

Commit

Permalink
linux-user: Fix broken m68k signal handling on 64 bit hosts
Browse files Browse the repository at this point in the history
The m68k signal frame setup code which writes the signal return
trampoline code to the stack was assuming that a 'long' was 32 bits;
on 64 bit systems this meant we would end up writing the 32 bit
(2 insn) trampoline sequence to retaddr+4,retaddr+6 instead of
the intended retaddr+0,retaddr+2, resulting in a guest crash when
it tried to execute the invalid zero-bytes at retaddr+0.
Fix by using uint32_t instead; also use uint16_t rather than short
for consistency. This fixes bug LP:1404690.

Reported-by: Michel Boaventura
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
  • Loading branch information
pm215 authored and Riku Voipio committed Jan 27, 2015
1 parent ec355f1 commit 1669add
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions linux-user/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5066,7 +5066,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
/* moveq #,d0; trap #0 */

__put_user(0x70004e40 + (TARGET_NR_sigreturn << 16),
(long *)(frame->retcode));
(uint32_t *)(frame->retcode));

/* Set up to return from userspace */

Expand Down Expand Up @@ -5200,8 +5200,8 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
/* moveq #,d0; notb d0; trap #0 */

__put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16),
(long *)(frame->retcode + 0));
__put_user(0x4e40, (short *)(frame->retcode + 4));
(uint32_t *)(frame->retcode + 0));
__put_user(0x4e40, (uint16_t *)(frame->retcode + 4));

if (err)
goto give_sigsegv;
Expand Down

0 comments on commit 1669add

Please sign in to comment.