Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20261104034410.GQ23438@brightrain.aerifal.cx>
Date: Tue, 3 Nov 2026 22:44:10 -0500
From: Rich Felker <dalias@...c.org>
To: Imre Kaloz <kaloz@...nel.org>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH 04/10] add SYSCALL_RT_SIGACTION_RESTORER hook for
 sparc

On Mon, Nov 02, 2026 at 05:58:31PM +0100, Imre Kaloz wrote:
> sparc's rt_sigaction takes the restorer as a fourth argument, before
> sigsetsize, and has no SA_RESTORER; the kernel reads it only when an
> action is installed. sparc32 builds an rt frame only for SA_SIGINFO
> handlers and returns from the two frames by different syscalls, so the
> restorer follows SA_SIGINFO.
> ---
>  src/signal/sigaction.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/signal/sigaction.c b/src/signal/sigaction.c
> index e45308fa..2404279a 100644
> --- a/src/signal/sigaction.c
> +++ b/src/signal/sigaction.c
> @@ -20,6 +20,9 @@ volatile int __eintr_valid_flag;
>  int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
>  {
>  	struct k_sigaction ksa, ksa_old;
> +#ifdef SYSCALL_RT_SIGACTION_RESTORER
> +	void (*restorer)(void) = __restore_rt;
> +#endif
>  	if (sa) {
>  		if ((uintptr_t)sa->sa_handler > 1UL) {
>  			a_or_l(handler_set+(sig-1)/(8*sizeof(long)),
> @@ -48,10 +51,19 @@ int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigact
>  #ifdef SA_RESTORER
>  		ksa.flags |= SA_RESTORER;
>  		ksa.restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore;
> +#endif
> +#ifdef SYSCALL_RT_SIGACTION_RESTORER
> +		restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore;
> +		ksa.restorer = restorer;
>  #endif
>  		memcpy(&ksa.mask, &sa->sa_mask, _NSIG/8);
>  	}
> +#ifdef SYSCALL_RT_SIGACTION_RESTORER
> +	int r = __syscall(SYS_rt_sigaction, sig, sa?&ksa:0, old?&ksa_old:0,
> +		restorer, _NSIG/8);
> +#else
>  	int r = __syscall(SYS_rt_sigaction, sig, sa?&ksa:0, old?&ksa_old:0, _NSIG/8);
> +#endif
>  	if (old && !r) {
>  		old->sa_handler = ksa_old.handler;
>  		old->sa_flags = ksa_old.flags;
> -- 
> 2.47.3

I think this patch misses other places SYS_rt_sigaction is used, and
puts arch-specific ifdefs we shouldn't be doing inline each place the
syscall is used.

Probably we should either (or both) replace direct use of the syscall
with a __sys_sigaction (like __sys_open, etc.) defined in
src/internal/syscall.h if the arch doesn't first define it, or #undef
SYS_rt_sigaction on sparc and have a case for where that's not
defined, to be safe against missing instances of its use or adding new
ones with silent breakage.

Note that since __restore and __restore_rt are the same,
__sys_sigaction does not need a conditional on flags. It can just
always pass __restore in the extra slot.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.