[PATCH v2 04/30] linux-user: Zero out target_siginfo_t in force_sig()

Richard Henderson posted 30 patches 4 years, 5 months ago
Maintainers: Cornelia Huck <cohuck@redhat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Laurent Vivier <laurent@vivier.eu>, Taylor Simpson <tsimpson@quicinc.com>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Thomas Huth <thuth@redhat.com>, Aurelien Jarno <aurelien@aurel32.net>
There is a newer version of this series
[PATCH v2 04/30] linux-user: Zero out target_siginfo_t in force_sig()
Posted by Richard Henderson 4 years, 5 months ago
From: Peter Maydell <peter.maydell@linaro.org>

The target_siginfo_t we populate in force_sig() will eventually
get copied onto the target's stack. Zero it out so that any extra
padding in the sifields union is consistently zero when the guest
sees it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20210813131809.28655-5-peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index a8faea6f09..fd3c6a3e60 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -636,7 +636,7 @@ void force_sig(int sig)
 {
     CPUState *cpu = thread_cpu;
     CPUArchState *env = cpu->env_ptr;
-    target_siginfo_t info;
+    target_siginfo_t info = {};
 
     info.si_signo = sig;
     info.si_errno = 0;
-- 
2.25.1


Re: [PATCH v2 04/30] linux-user: Zero out target_siginfo_t in force_sig()
Posted by Philippe Mathieu-Daudé 4 years, 5 months ago
On 8/22/21 5:55 AM, Richard Henderson wrote:
> From: Peter Maydell <peter.maydell@linaro.org>
> 
> The target_siginfo_t we populate in force_sig() will eventually
> get copied onto the target's stack. Zero it out so that any extra
> padding in the sifields union is consistently zero when the guest
> sees it.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> Message-Id: <20210813131809.28655-5-peter.maydell@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/signal.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>