From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11180 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] pthread_sigmask: check 'how' only when 'set' is not NULL Date: Wed, 22 Mar 2017 08:49:21 -0400 Message-ID: <20170322124921.GE17319@brightrain.aerifal.cx> References: <1490185183-17680-1-git-send-email-yszhou4tech@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1490186985 16587 195.159.176.226 (22 Mar 2017 12:49:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 22 Mar 2017 12:49:45 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11195-gllmg-musl=m.gmane.org@lists.openwall.com Wed Mar 22 13:49:39 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1cqfhh-0002oA-7O for gllmg-musl@m.gmane.org; Wed, 22 Mar 2017 13:49:29 +0100 Original-Received: (qmail 13636 invoked by uid 550); 22 Mar 2017 12:49:33 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 13618 invoked from network); 22 Mar 2017 12:49:33 -0000 Content-Disposition: inline In-Reply-To: <1490185183-17680-1-git-send-email-yszhou4tech@gmail.com> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11180 Archived-At: On Wed, Mar 22, 2017 at 08:19:43PM +0800, Yousong Zhou wrote: > According to POSIX document > > If set is a null pointer, the value of the argument how is not > significant and the thread's signal mask shall be unchanged; thus > the call can be used to enquire about currently blocked signals. > > This is also how the current Linux kernel syscall is doing. So the > following function call from binutils-gdb should not fail > > sigprocmask (0, NULL, &original_signal_mask); > --- > src/thread/pthread_sigmask.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/thread/pthread_sigmask.c b/src/thread/pthread_sigmask.c > index 88c333f..f188782 100644 > --- a/src/thread/pthread_sigmask.c > +++ b/src/thread/pthread_sigmask.c > @@ -5,7 +5,7 @@ > int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old) > { > int ret; > - if ((unsigned)how - SIG_BLOCK > 2U) return EINVAL; > + if (set && (unsigned)how - SIG_BLOCK > 2U) return EINVAL; > ret = -__syscall(SYS_rt_sigprocmask, how, set, old, _NSIG/8); > if (!ret && old) { > if (sizeof old->__bits[0] == 8) { > -- > 2.6.4 I don't think this change is conforming. There is a requirement to produce an error ("shall fail") independent of whether the set argument is a null pointer: The pthread_sigmask() and sigprocmask() functions shall fail if: [EINVAL] The value of the how argument is not equal to one of the defined values. http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html If gdb is calling it with an invalid argument (rather, one that's conditionally invalid depending on the platform's definitions of the how macros), a patch should be sent to gdb to fix it. Rich