From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5178 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [UGLY PATCH v3] Support for no-legacy-syscalls archs Date: Thu, 29 May 2014 19:04:35 -0400 Message-ID: <20140529230434.GT507@brightrain.aerifal.cx> References: <20140525054237.GA18085@brightrain.aerifal.cx> <20140527052625.GC507@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1401404697 23236 80.91.229.3 (29 May 2014 23:04:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 May 2014 23:04:57 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-5183-gllmg-musl=m.gmane.org@lists.openwall.com Fri May 30 01:04:50 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Wq9NQ-0004o6-Pn for gllmg-musl@plane.gmane.org; Fri, 30 May 2014 01:04:48 +0200 Original-Received: (qmail 19787 invoked by uid 550); 29 May 2014 23:04:47 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 19779 invoked from network); 29 May 2014 23:04:46 -0000 Content-Disposition: inline In-Reply-To: <20140527052625.GC507@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:5178 Archived-At: 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 > +#include > #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