Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20140529230434.GT507@brightrain.aerifal.cx>
Date: Thu, 29 May 2014 19:04:35 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: [UGLY PATCH v3] Support for no-legacy-syscalls archs

On Tue, May 27, 2014 at 01:26:25AM -0400, Rich Felker wrote:
> diff --git a/src/unistd/pause.c b/src/unistd/pause.c
> index f7ed17d..e259017 100644
> --- a/src/unistd/pause.c
> +++ b/src/unistd/pause.c
> @@ -1,8 +1,15 @@
>  #include <unistd.h>
> +#include <signal.h>
>  #include "syscall.h"
>  #include "libc.h"
>  
>  int pause(void)
>  {
> +#ifdef SYS_pause
>  	return syscall_cp(SYS_pause);
> +#else
> +	sigset_t mask;
> +	__syscall(SYS_rt_sigprocmask, SIG_BLOCK, 0, &mask, _NSIG/8);
> +	return syscall_cp(SYS_rt_sigsuspend, &mask, _NSIG/8);
> +#endif

This also potentially has a race condition: It's possible for a signal
handler to intervene between the two syscalls, changing the signal
mask, in which case the signal mask getting reverted by the sigsuspend
is potentially observable.

I'm inclined to leave it alone for now. It's unclear whether there's
even a fix using sigsuspend, and if so, it's going to be a mildly
expensive one. And the effect is only observable by doing something
that's not officially sanctioned as well-defined: changing the saved
signal mask in the ucontext received by a signal handler to effect a
new signal mask when the signal handler returns.

Of course if there's another syscall that could reasonably replace
pause, that might be a viable solution. (Perhaps ppoll with no file
descriptors and no timeout?)

Ok, yep, that works! Never mind then. Fixed.

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.