From: Rich Felker <dalias@libc.org>
To: Jasper Hugunin <jasper@hugunin.net>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Bug in src/signal/block.c
Date: Wed, 28 Jul 2021 15:36:28 -0400 [thread overview]
Message-ID: <20210728193628.GS13220@brightrain.aerifal.cx> (raw)
In-Reply-To: <20210728155340.GQ13220@brightrain.aerifal.cx>
[-- Attachment #1: Type: text/plain, Size: 1385 bytes --]
On Wed, Jul 28, 2021 at 11:53:41AM -0400, Rich Felker wrote:
> On Wed, Jul 28, 2021 at 08:00:00AM -0700, Jasper Hugunin wrote:
> > Hello,
> >
> > In musl, as far as I can tell, `_NSIG` is always defined as either 65, or
> > 128 (for all three MIPS architectures) at the bottom of
> > `${arch}/bits/signal.h`. Meanwhile, in `src/signal/block.c`, there is a
> > test `#if ULONG_MAX == 0xffffffff && _NSIG == 129`, which will never
> > succeed since _NSIG will be 128 instead of 129. This seems likely to be
> > left over from Commit: fix _NSIG and SIGRTMAX on mips
> > <https://git.musl-libc.org/cgit/musl/commit/arch?id=7c440977db9444d7e6b1c3dcb1fdf4ee49ca4158>
> > ..
> >
> > I have not demonstrated the bug, I found it by inspection of the source. My
> > guess is that this bug causes __block_all_sigs to fail to block high real
> > time signals on MIPS. At best, however, this test seems to be dead code.
> >
> > (I am not subscribed to the mailing list; please cc me directly on any
> > responses I need to see.)
> > My apologies if I have misunderstood the situation.
>
> Thanks! This is a real bug that will prevent signal blocking from
> working correctly on mips, resulting in application code being able to
> run in contexts where it is unsafe for that to happen if the
> application installs signal handlers on high signal numbers.
Does the attached patch look ok?
Rich
[-- Attachment #2: sigblock-mips.diff --]
[-- Type: text/plain, Size: 433 bytes --]
diff --git a/src/signal/block.c b/src/signal/block.c
index d7f61001..cc8698f0 100644
--- a/src/signal/block.c
+++ b/src/signal/block.c
@@ -3,9 +3,9 @@
#include <signal.h>
static const unsigned long all_mask[] = {
-#if ULONG_MAX == 0xffffffff && _NSIG == 129
+#if ULONG_MAX == 0xffffffff && _NSIG > 65
-1UL, -1UL, -1UL, -1UL
-#elif ULONG_MAX == 0xffffffff
+#elif ULONG_MAX == 0xffffffff || _NSIG > 65
-1UL, -1UL
#else
-1UL
next prev parent reply other threads:[~2021-07-28 19:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-28 15:00 Jasper Hugunin
2021-07-28 15:53 ` Rich Felker
2021-07-28 17:11 ` Laurent Bercot
2021-07-28 18:43 ` Michael Forney
2021-07-28 19:30 ` Rich Felker
2021-07-28 19:36 ` Rich Felker [this message]
2021-07-28 19:52 ` Jasper Hugunin
2021-07-28 22:04 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210728193628.GS13220@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=jasper@hugunin.net \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).