From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5834 invoked from network); 28 Jul 2021 19:36:43 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 28 Jul 2021 19:36:43 -0000 Received: (qmail 25767 invoked by uid 550); 28 Jul 2021 19:36:41 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 25749 invoked from network); 28 Jul 2021 19:36:40 -0000 Date: Wed, 28 Jul 2021 15:36:28 -0400 From: Rich Felker To: Jasper Hugunin Cc: musl@lists.openwall.com Message-ID: <20210728193628.GS13220@brightrain.aerifal.cx> References: <20210728155340.GQ13220@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="hQiwHBbRI9kgIhsi" Content-Disposition: inline In-Reply-To: <20210728155340.GQ13220@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Bug in src/signal/block.c --hQiwHBbRI9kgIhsi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > > > > .. > > > > 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 --hQiwHBbRI9kgIhsi Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sigblock-mips.diff" 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 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 --hQiwHBbRI9kgIhsi--