Commit 8cfc114a authored by Stefan Weil's avatar Stefan Weil Committed by Edgar E. Iglesias
Browse files

linux-user: Fix trampoline code for CRIS



__put_user can write bytes, words (2 bytes) or longwords (4 bytes).
Here obviously words should have been written, but bytes were written,
so values like 0x9c5f were truncated to 0x5f.

Fix this by changing retcode from uint8_t to to uint16_t in
target_signal_frame and also in the unused rt_signal_frame.

This problem was reported by static code analysis (smatch).

Cc: qemu-stable@nongnu.org
Signed-off-by: default avatarStefan Weil <sw@weilnetz.de>
Acked-by: default avatarRiku Voipio <riku.voipio@linaro.org>
Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Tested-by: default avatarEdgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: default avatarEdgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: default avatarEdgar E. Iglesias <edgar.iglesias@xilinx.com>
parent ce603d8e
...@@ -3659,7 +3659,7 @@ struct target_sigcontext { ...@@ -3659,7 +3659,7 @@ struct target_sigcontext {
struct target_signal_frame { struct target_signal_frame {
struct target_sigcontext sc; struct target_sigcontext sc;
uint32_t extramask[TARGET_NSIG_WORDS - 1]; uint32_t extramask[TARGET_NSIG_WORDS - 1];
uint8_t retcode[8]; /* Trampoline code. */ uint16_t retcode[4]; /* Trampoline code. */
}; };
struct rt_signal_frame { struct rt_signal_frame {
...@@ -3667,7 +3667,7 @@ struct rt_signal_frame { ...@@ -3667,7 +3667,7 @@ struct rt_signal_frame {
void *puc; void *puc;
siginfo_t info; siginfo_t info;
struct ucontext uc; struct ucontext uc;
uint8_t retcode[8]; /* Trampoline code. */ uint16_t retcode[4]; /* Trampoline code. */
}; };
static void setup_sigcontext(struct target_sigcontext *sc, CPUCRISState *env) static void setup_sigcontext(struct target_sigcontext *sc, CPUCRISState *env)
...@@ -3745,8 +3745,8 @@ static void setup_frame(int sig, struct target_sigaction *ka, ...@@ -3745,8 +3745,8 @@ static void setup_frame(int sig, struct target_sigaction *ka,
*/ */
err |= __put_user(0x9c5f, frame->retcode+0); err |= __put_user(0x9c5f, frame->retcode+0);
err |= __put_user(TARGET_NR_sigreturn, err |= __put_user(TARGET_NR_sigreturn,
frame->retcode+2); frame->retcode + 1);
err |= __put_user(0xe93d, frame->retcode+4); err |= __put_user(0xe93d, frame->retcode + 2);
/* Save the mask. */ /* Save the mask. */
err |= __put_user(set->sig[0], &frame->sc.oldmask); err |= __put_user(set->sig[0], &frame->sc.oldmask);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment