Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250102124222.GA3109289@schwarzgerat.orthanc>
Date: Thu, 2 Jan 2025 07:42:22 -0500
From: nick black <dankamongmen@...il.com>
To: musl@...ts.openwall.com
Subject: [patch] don't use SA_ONSTACK for SIGCANCEL

this is not necessarily a bug in musl, but it's certainly close
imho. thanks for the great work on musl over the years!

my alternate stack is not a verdant field to be stomped upon by
wayward signals of the musl golden horde. i expect it to be
used for the signals i have registered with SA_ONSTACK.

there is an argument to be made that "The range of addresses
starting at ss_sp up to but not including ss_sp+ ss_size is
available to the implementation for use as the stack." makes the
alternate signal stack free game. i would be stunned, however,
if some named signal was handled on the alternate stack without
me having called SA_ONSTACK in conjunction with it (and this
would not happen with musl -- only SIGCANCEL acts thus).

this caused problems as noticed in
https://github.com/dankamongmen/notcurses/issues/2828

now, free()ing a stack i still have registered for my thread is
unorthodox, perhaps even questionable. definitely questionable.
if there's no benefit from the SA_ONSTACK here, though, i feel
it serves the Law of Least Astonishment to kill it.

commit 8c4a1758bfd432b677db0bae8e4a1a3482dec31d
Author: nick black <dankamongmen@...il.com>
Date:   Thu Jan 2 07:32:10 2025 -0500

    [pthread_cancel] don't handle SIGCANCEL on altstack
    
    Don't use the receiving thread's alternate signal
    stack for SIGCANCEL; they gave us no permission
    to do so.
    
    Signed-off-by: nick black <dankamongmen@...il.com>

diff --git src/thread/pthread_cancel.c src/thread/pthread_cancel.c
index 139a6fc8..8ea0b545 100644
--- src/thread/pthread_cancel.c
+++ src/thread/pthread_cancel.c
@@ -82,7 +82,7 @@ void __testcancel()
 static void init_cancellation()
 {
 	struct sigaction sa = {
-		.sa_flags = SA_SIGINFO | SA_RESTART | SA_ONSTACK,
+		.sa_flags = SA_SIGINFO | SA_RESTART,
 		.sa_sigaction = cancel_handler
 	};
 	memset(&sa.sa_mask, -1, _NSIG/8);

-- 
nick black -=- https://nick-black.com
to make an apple pie from scratch,
you need first invent a universe.

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

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.