Skip to content

Commit

Permalink
linux-user/sh4: Clean env->flags on signal boundaries
Browse files Browse the repository at this point in the history
If a signal is delivered during the execution of a delay slot,
or a gUSA region, clear those bits from the environment so that
the signal handler does not start in that same state.

Cleaning the bits on signal return is paranoid good sense.

Reviewed-by: Aurelien Jarno <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Aurelien Jarno <[email protected]>
  • Loading branch information
rth7680 authored and aurel32 committed Jul 18, 2017
1 parent b0e4f0e commit b0e9c51
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions linux-user/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3549,6 +3549,7 @@ static void restore_sigcontext(CPUSH4State *regs, struct target_sigcontext *sc)
__get_user(regs->fpul, &sc->sc_fpul);

regs->tra = -1; /* disable syscall checks */
regs->flags &= ~(DELAY_SLOT_MASK | GUSA_MASK);
}

static void setup_frame(int sig, struct target_sigaction *ka,
Expand Down Expand Up @@ -3592,6 +3593,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
regs->gregs[5] = 0;
regs->gregs[6] = frame_addr += offsetof(typeof(*frame), sc);
regs->pc = (unsigned long) ka->_sa_handler;
regs->flags &= ~(DELAY_SLOT_MASK | GUSA_MASK);

unlock_user_struct(frame, frame_addr, 1);
return;
Expand Down Expand Up @@ -3654,6 +3656,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
regs->gregs[5] = frame_addr + offsetof(typeof(*frame), info);
regs->gregs[6] = frame_addr + offsetof(typeof(*frame), uc);
regs->pc = (unsigned long) ka->_sa_handler;
regs->flags &= ~(DELAY_SLOT_MASK | GUSA_MASK);

unlock_user_struct(frame, frame_addr, 1);
return;
Expand Down

0 comments on commit b0e9c51

Please sign in to comment.