[PATCH v2 13/15] linux-user/s390x: Add build asserts for sigset sizes

Richard Henderson posted 15 patches 4 years, 9 months ago
[PATCH v2 13/15] linux-user/s390x: Add build asserts for sigset sizes
Posted by Richard Henderson 4 years, 9 months ago
At point of usage, it's not immediately obvious that
we don't need a loop to copy these arrays.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/s390x/signal.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c
index 81ba59b46a..839a7ae4b3 100644
--- a/linux-user/s390x/signal.c
+++ b/linux-user/s390x/signal.c
@@ -141,6 +141,8 @@ void setup_frame(int sig, struct target_sigaction *ka,
         return;
     }
 
+    /* Make sure that we're initializing all of oldmask. */
+    QEMU_BUILD_BUG_ON(ARRAY_SIZE(frame->sc.oldmask) != 1);
     __put_user(set->sig[0], &frame->sc.oldmask[0]);
 
     save_sigregs(env, &frame->sregs);
@@ -266,6 +268,9 @@ long do_sigreturn(CPUS390XState *env)
         force_sig(TARGET_SIGSEGV);
         return -TARGET_QEMU_ESIGRETURN;
     }
+
+    /* Make sure that we're initializing all of target_set. */
+    QEMU_BUILD_BUG_ON(ARRAY_SIZE(target_set.sig) != 1);
     __get_user(target_set.sig[0], &frame->sc.oldmask[0]);
 
     target_to_host_sigset_internal(&set, &target_set);
-- 
2.25.1


Re: [PATCH v2 13/15] linux-user/s390x: Add build asserts for sigset sizes
Posted by David Hildenbrand 4 years, 9 months ago
On 28.04.21 21:34, Richard Henderson wrote:
> At point of usage, it's not immediately obvious that
> we don't need a loop to copy these arrays.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   linux-user/s390x/signal.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c
> index 81ba59b46a..839a7ae4b3 100644
> --- a/linux-user/s390x/signal.c
> +++ b/linux-user/s390x/signal.c
> @@ -141,6 +141,8 @@ void setup_frame(int sig, struct target_sigaction *ka,
>           return;
>       }
>   
> +    /* Make sure that we're initializing all of oldmask. */
> +    QEMU_BUILD_BUG_ON(ARRAY_SIZE(frame->sc.oldmask) != 1);
>       __put_user(set->sig[0], &frame->sc.oldmask[0]);
>   
>       save_sigregs(env, &frame->sregs);
> @@ -266,6 +268,9 @@ long do_sigreturn(CPUS390XState *env)
>           force_sig(TARGET_SIGSEGV);
>           return -TARGET_QEMU_ESIGRETURN;
>       }
> +
> +    /* Make sure that we're initializing all of target_set. */
> +    QEMU_BUILD_BUG_ON(ARRAY_SIZE(target_set.sig) != 1);
>       __get_user(target_set.sig[0], &frame->sc.oldmask[0]);
>   
>       target_to_host_sigset_internal(&set, &target_set);
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb