* [Qemu-devel] [PATCH] exec.c: Initialize sa_flags passed to sigaction()
@ 2018-05-15 18:27 Peter Maydell
2018-05-15 19:24 ` Alex Bennée
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Peter Maydell @ 2018-05-15 18:27 UTC (permalink / raw)
To: qemu-devel; +Cc: patches, Paolo Bonzini
Coverity points out that in the user-only version of cpu_abort() we
call sigaction() with a partially initialized struct sigaction
(CID 1005351). Correct the omission.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
exec.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/exec.c b/exec.c
index ffa1099547..bd8833fc9d 100644
--- a/exec.c
+++ b/exec.c
@@ -1124,6 +1124,7 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
struct sigaction act;
sigfillset(&act.sa_mask);
act.sa_handler = SIG_DFL;
+ act.sa_flags = 0;
sigaction(SIGABRT, &act, NULL);
}
#endif
--
2.17.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] exec.c: Initialize sa_flags passed to sigaction()
2018-05-15 18:27 [Qemu-devel] [PATCH] exec.c: Initialize sa_flags passed to sigaction() Peter Maydell
@ 2018-05-15 19:24 ` Alex Bennée
2018-05-15 20:53 ` Philippe Mathieu-Daudé
2018-05-16 7:25 ` Paolo Bonzini
2 siblings, 0 replies; 5+ messages in thread
From: Alex Bennée @ 2018-05-15 19:24 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, Paolo Bonzini, patches
Peter Maydell <peter.maydell@linaro.org> writes:
> Coverity points out that in the user-only version of cpu_abort() we
> call sigaction() with a partially initialized struct sigaction
> (CID 1005351). Correct the omission.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> exec.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/exec.c b/exec.c
> index ffa1099547..bd8833fc9d 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1124,6 +1124,7 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
> struct sigaction act;
> sigfillset(&act.sa_mask);
> act.sa_handler = SIG_DFL;
> + act.sa_flags = 0;
> sigaction(SIGABRT, &act, NULL);
> }
> #endif
--
Alex Bennée
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] exec.c: Initialize sa_flags passed to sigaction()
2018-05-15 18:27 [Qemu-devel] [PATCH] exec.c: Initialize sa_flags passed to sigaction() Peter Maydell
2018-05-15 19:24 ` Alex Bennée
@ 2018-05-15 20:53 ` Philippe Mathieu-Daudé
2018-05-15 21:40 ` Eric Blake
2018-05-16 7:25 ` Paolo Bonzini
2 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-05-15 20:53 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: Paolo Bonzini, patches
On 05/15/2018 03:27 PM, Peter Maydell wrote:
> Coverity points out that in the user-only version of cpu_abort() we
> call sigaction() with a partially initialized struct sigaction
> (CID 1005351). Correct the omission.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> exec.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/exec.c b/exec.c
> index ffa1099547..bd8833fc9d 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1124,6 +1124,7 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
> struct sigaction act;
I'd have used the more generic:
struct sigaction act = { };
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> sigfillset(&act.sa_mask);
> act.sa_handler = SIG_DFL;
> + act.sa_flags = 0;
> sigaction(SIGABRT, &act, NULL);
> }
> #endif
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] exec.c: Initialize sa_flags passed to sigaction()
2018-05-15 20:53 ` Philippe Mathieu-Daudé
@ 2018-05-15 21:40 ` Eric Blake
0 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2018-05-15 21:40 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Peter Maydell, qemu-devel
Cc: Paolo Bonzini, patches
On 05/15/2018 03:53 PM, Philippe Mathieu-Daudé wrote:
> On 05/15/2018 03:27 PM, Peter Maydell wrote:
>> Coverity points out that in the user-only version of cpu_abort() we
>> call sigaction() with a partially initialized struct sigaction
>> (CID 1005351). Correct the omission.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> exec.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/exec.c b/exec.c
>> index ffa1099547..bd8833fc9d 100644
>> --- a/exec.c
>> +++ b/exec.c
>> @@ -1124,6 +1124,7 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
>> struct sigaction act;
>
> I'd have used the more generic:
>
> struct sigaction act = { };
That's a gcc/clang extension (although we have used it before,
particularly to shut up buggy versions of clang); better is:
struct sigaction act = { 0 };
if that doesn't trigger the clang bug.
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
>> sigfillset(&act.sa_mask);
>> act.sa_handler = SIG_DFL;
The sigfillset() has to be done after initialization, but you could also
use:
struct sigaction act = {
.sa_handler = SIG_DFL;
};
sigfillset(&act.sa_mask);
as a way to zero-initialize all other fields.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] exec.c: Initialize sa_flags passed to sigaction()
2018-05-15 18:27 [Qemu-devel] [PATCH] exec.c: Initialize sa_flags passed to sigaction() Peter Maydell
2018-05-15 19:24 ` Alex Bennée
2018-05-15 20:53 ` Philippe Mathieu-Daudé
@ 2018-05-16 7:25 ` Paolo Bonzini
2 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2018-05-16 7:25 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: patches
On 15/05/2018 20:27, Peter Maydell wrote:
> Coverity points out that in the user-only version of cpu_abort() we
> call sigaction() with a partially initialized struct sigaction
> (CID 1005351). Correct the omission.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> exec.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/exec.c b/exec.c
> index ffa1099547..bd8833fc9d 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1124,6 +1124,7 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
> struct sigaction act;
> sigfillset(&act.sa_mask);
> act.sa_handler = SIG_DFL;
> + act.sa_flags = 0;
> sigaction(SIGABRT, &act, NULL);
> }
> #endif
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-05-16 7:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-15 18:27 [Qemu-devel] [PATCH] exec.c: Initialize sa_flags passed to sigaction() Peter Maydell
2018-05-15 19:24 ` Alex Bennée
2018-05-15 20:53 ` Philippe Mathieu-Daudé
2018-05-15 21:40 ` Eric Blake
2018-05-16 7:25 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.