[PATCH v2] linux: Enforce zero fill of siginfo_t

enh enh@google.com
Mon Jan 26 16:35:01 GMT 2026


On Tue, Jan 20, 2026 at 8:14 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> The glibc siginfo struct is larger than the kABI one, and the kernel
> enforces that for an unknown si_code, all the extra bytes should be 0
> (post_copy_siginfo_from_user).
>
> For armhf, gcc-15 is fully zero-filling the struct (it seems to be a
> compiler issue, although I haven't found any already registered on
> gcc bugzilla).

i assume you mean "isn't" rather than "is" here, right? (since the `=
{ .a = b };` style is explicitly defined to zero out all the other
bytes.)

or do you meant that the compiler bug is that it's doing the zeroing
but dropping the assignments?

> In any case, to avoid false positives, force zero-filling on the
> structure.
>
> Checked on arm-linux-gnueabihf.
> --
> Changes from v1:
> * Use memset and add a comment why it is needed.
> ---
>  sysdeps/unix/sysv/linux/tst-pidfd.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/tst-pidfd.c b/sysdeps/unix/sysv/linux/tst-pidfd.c
> index d50e36b18a..7dd83e8aa7 100644
> --- a/sysdeps/unix/sysv/linux/tst-pidfd.c
> +++ b/sysdeps/unix/sysv/linux/tst-pidfd.c
> @@ -30,6 +30,7 @@
>  #include <sys/pidfd.h>
>  #include <sys/wait.h>
>  #include <stdlib.h>
> +#include <string.h>
>  #include <unistd.h>
>
>  #define REMOTE_PATH "/dev/null"
> @@ -210,14 +211,15 @@ do_test (void)
>    /* Wait for second sigtimedwait.  */
>    support_process_state_wait (pid, support_process_state_sleeping);
>    {
> -    siginfo_t info =
> -      {
> -       .si_signo = SIGUSR2,
> -       .si_errno = EAGAIN,
> -       .si_code = -10,
> -       .si_pid = ppid,
> -       .si_uid = puid
> -      };
> +    siginfo_t info;
> +    /* The glibc siginfo struct is larger than the kABI one, and the kernel
> +       enforces that for an unknown si_code, all the extra bytes should be 0.  */

given the above, this ought to explicitly reference the compiler bug
you're working around.

(iirc clang or clang-tidy [or _something_ that's looking at my code in
Android anyway!] explicitly tells you to clean up the old memset()
style into the newer style.)

> +    memset (&info, 0, sizeof (info));
> +    info.si_signo = SIGUSR2;
> +    info.si_errno = EAGAIN;
> +    info.si_code = -10;
> +    info.si_pid = ppid;
> +    info.si_uid = puid;
>      TEST_COMPARE (pidfd_send_signal (pidfd, SIGUSR2, &info, 0), 0);
>    }
>
> --
> 2.43.0
>


More information about the Libc-alpha mailing list