[PATCH v2] sigaction: don't sign-extend sa_flags
Florian Weimer
fweimer@redhat.com
Tue Jun 3 08:50:21 GMT 2025
* наб:
> Before:
> rt_sigaction(SIGBUS, {sa_handler=0x55abb9960139, sa_mask=[], sa_flags=SA_RESTORER|SA_RESETHAND|SA_SIGINFO|0xffffffff00000000, sa_restorer=0x7fb1b2a82050}, NULL, 8) = 0
>
> After:
> rt_sigaction(SIGBUS, {sa_handler=0x7f6a70dce139, sa_mask=[], sa_flags=SA_RESTORER|SA_RESETHAND|SA_SIGINFO, sa_restorer=0x7f6a70c28f60}, NULL, 8) = 0
>
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
> ---
> FTR I didn't think this were strace-reportable,
> since it accurately represents what the contents of the syscall are,
> but you're right that these upper bits aren't used
> (linux does & ALL_VALID_FLAGS) or usable
> (ulong>int only on kLP64, as you note) at all;
> I'll post a strace patch as well.
>
> sysdeps/unix/sysv/linux/libc_sigaction.c | 2 +-
> sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/libc_sigaction.c b/sysdeps/unix/sysv/linux/libc_sigaction.c
> index bbfc177655..67dbc04aee 100644
> --- a/sysdeps/unix/sysv/linux/libc_sigaction.c
> +++ b/sysdeps/unix/sysv/linux/libc_sigaction.c
> @@ -49,7 +49,7 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
> {
> kact.k_sa_handler = act->sa_handler;
> memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
> - kact.sa_flags = act->sa_flags;
> + kact.sa_flags = (unsigned int) act->sa_flags;
> SET_SA_RESTORER (&kact, act);
> }
>
> diff --git a/sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c b/sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c
> index 006c532127..812e023584 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c
> +++ b/sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c
> @@ -22,7 +22,7 @@
> extern void restore_rt (void) asm ("__restore_rt") attribute_hidden;
>
> #define SET_SA_RESTORER(kact, act) \
> - (kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
> + (kact)->sa_flags |= SA_RESTORER; \
> (kact)->sa_restorer = &restore_rt
>
> #define RESET_SA_RESTORER(act, kact) \
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Per the previous discussion, I'm going to push this for you. I'll just
mention “Linux” in the commit subject.
Thanks,
Florian
More information about the Libc-alpha
mailing list