aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-05-27 15:18:41 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-05-27 15:39:33 +0100
commite84ccae262751710b586c2438274945f427050ec (patch)
tree300ae8088744d8f95a0354ab1a431e7653970527
parent5b20da16760f0ca85e9d2a196268ee24c077b1b0 (diff)
downloadqemu-arm-e84ccae262751710b586c2438274945f427050ec.tar.gz
linux-user: Avoid possible misalignment in host_to_target_siginfo()
host_to_target_siginfo() is implemented by a combination of host_to_target_siginfo_noswap() followed by tswap_siginfo(). The first of these two functions assumes that the target_siginfo_t it is writing to is correctly aligned, but the pointer passed into host_to_target_siginfo() is directly from the guest and might be misaligned. Use a local variable to avoid this problem. (tswap_siginfo() does now correctly handle a misaligned destination.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--linux-user/signal.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 8ea0cbf0e6..7e2a80f578 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -400,8 +400,9 @@ static void tswap_siginfo(target_siginfo_t *tinfo,
void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info)
{
- host_to_target_siginfo_noswap(tinfo, info);
- tswap_siginfo(tinfo, tinfo);
+ target_siginfo_t tgt_tmp;
+ host_to_target_siginfo_noswap(&tgt_tmp, info);
+ tswap_siginfo(tinfo, &tgt_tmp);
}
/* XXX: we support only POSIX RT signals are used. */