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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 12448 invoked from network); 6 Jul 2020 22:38:05 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 6 Jul 2020 22:38:05 -0000 Received: (qmail 27688 invoked by uid 550); 6 Jul 2020 22:38:00 -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 27670 invoked from network); 6 Jul 2020 22:37:59 -0000 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yqxmail.com; s=dkim; t=1594075067; bh=C1JuCFP1EafzQ0PEIAP8HO1Myugq3TehHBOIWGCzLXA=; h=Date:From:To:Subject:In-Reply-To:References:From; b=XpEQXlIB5Be7LEHjtuXXX8EJL4AT/lUZlD9rlG5V3sgAJvAGoy/GyZ0t3oc7X/Pz0 B+8u1bcBBskS6lVfk/EFTV0Vhoy0WqoHva9qFx6nwFG8B7+4ohrmddRK7F6qoKE9pE nDmBU6q65rpVCmFUH97xC4xVpZRCYJlgEgHY49hsdyEBxYNf9cuWJ+Nqk9nccdkGg2 H3Tw/eQXtw//kU/ZRCYQAs21jCPHdksHedvewcVxdYxu6pZkp8pNM20dXP49QJCX1T SRFBf1MZsNixJsQs1H7YEu0JWHuVW43rMfMdyO89zE7wsI107e7wNrp4t3Zr2fKvDa n6x1yvGoma1XQ== Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 06 Jul 2020 15:37:47 -0700 From: Hydro Flask To: musl@lists.openwall.com In-Reply-To: <20200706222202.GN6430@brightrain.aerifal.cx> References: <20200630044323.GD6430@brightrain.aerifal.cx> <20200630092644.GE6430@brightrain.aerifal.cx> <20200630145851.GD13001@voyager> <275470aa6820d420339929a1fe409d89@yqxmail.com> <477cc243-b950-3363-e9f4-4c8a203b6bea@samersoff.net> <20200630195409.GH6430@brightrain.aerifal.cx> <300a1bdb9e9041bf05312ef032cbdc66@yqxmail.com> <20200706220024.GJ6430@brightrain.aerifal.cx> <20200706222202.GN6430@brightrain.aerifal.cx> Message-ID: <5144617df2c8010b62813b5ed2c0dfef@yqxmail.com> Subject: Re: [musl] Potential deadlock in pthread_kill() On 2020-07-06 15:22, Rich Felker wrote: > On Mon, Jul 06, 2020 at 03:14:43PM -0700, Hydro Flask wrote: >> On 2020-07-06 15:00, Rich Felker wrote: >> >Yes, I see it clearly now. Sorry it took a while. I have prepared the >> >attached patch which I'll push soon if there are no problems. >> >> Needs one more tiny tweak. I noticed that pthread_cancel() calls >> pthread_kill(). That means pthread_kill() must be async-cancel-safe. >> If an asynchronous cancellation happens after pthread_kill() grabs >> the killlock, then it will deadlock because the asynchronous >> pthread_exit(PTHREAD_CANCELED) call will then recursively try to >> grab killlock. >> >> The solution as far as I can tell is to not just block app signals >> when grabbing killlock, but all signals. > > Are you in agreement that it suffices for only pthread_kill to block > all signals? (Still blocking just app signals everywhere else) The > scheduling functions could be changed too, but I'm hesitant to change > pthread_exit without thinking about it further since it has a lot more > subtleties. And I think only pthread_kill needs it since it's the only > one that needs to be AC-safe. Yes I think that's right, since every other function that grabs the killlock can assume that async cancellation won't happen.