[PATCH v2] linux: Enforce zero fill of siginfo_t
mengqinggang
mengqinggang@loongson.cn
Tue Apr 21 03:51:19 GMT 2026
Can this patch be pushed to master?
tst-pidfd also failed on LoongArch32 without this patch.
Thanks,
Meng
在 2026/1/20 21:13, Adhemerval Zanella 写道:
> 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).
>
> 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. */
> + 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);
> }
>
More information about the Libc-alpha
mailing list