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 12535 invoked from network); 30 Jun 2020 16:29:02 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 30 Jun 2020 16:29:02 -0000 Received: (qmail 18345 invoked by uid 550); 30 Jun 2020 16:28:58 -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 18324 invoked from network); 30 Jun 2020 16:28:57 -0000 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yqxmail.com; s=dkim; t=1593534525; bh=XZg1kctY4Lqxdfbaxu456uBaLiQz6VRpdW/+3H7gbro=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iP5+EFUCeblCi7cU2gNE3shAE6c//tfRH6tUISAmltKTXykxSjKUpXpJwpGzjdFSw l9c1iP2JgR6mY1tdjb+08obWBKFz/XTySEmJSfjr/KONrFLO7mYvoLxDOF1GRBBhiR 8SoyaYQXU1spGFo/kT8aJKYY/P84vd+UyJVLFaYazOJXGC0XkNVqNsHaNmhQ0ItqN7 l4/PD7xv2Ojyxq5oUEGtiDblW/0OCNwgjabgM5lZf3/w2C79P9MrBvjCf5LtqfiJtB 6kUQtYHXEHl9iXFIBT3K+33rwwfDR7IGsPbKSL/aNSVAgp3le5le/VfcqN2sonJq1u tiL0aRHt7Y+XQ== Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 30 Jun 2020 09:28:44 -0700 From: Hydro Flask To: musl@lists.openwall.com Cc: Markus Wichmann In-Reply-To: <20200630145851.GD13001@voyager> References: <0217b8838100175725993b0ed0114ee7@thelig.ht> <20200630044323.GD6430@brightrain.aerifal.cx> <20200630092644.GE6430@brightrain.aerifal.cx> <20200630145851.GD13001@voyager> Message-ID: <275470aa6820d420339929a1fe409d89@yqxmail.com> Subject: Re: [musl] Potential deadlock in pthread_kill() On 2020-06-30 07:58, Markus Wichmann wrote: > On Tue, Jun 30, 2020 at 05:26:46AM -0400, Rich Felker wrote: >> On Mon, Jun 29, 2020 at 11:19:39PM -0700, Hydro Flask wrote: >> > >> > Just to be clear, this doesn't only occur when calling >> > pthread_kill() and using pthread_self() as the target, it can be any >> > target thread, as long as it's the same target thread is used in the >> > signal handler and in the synchronous context. >> >> How so? If the target is different, the rest of the pthread_kill, >> including the unlock, will proceed concurrently with the signal >> handler. However you may be able to construct mutual-signaling >> deadlock cases. >> > > Thread A calls pthread_kill(thread_c, ...). Thread B calls > (concurrently) pthread_kill(thread_a, ...). Thread B's signal arrives > while thread A holds the killlock. Signal handler calls > pthread_kill(thread_c, ...). You can trigger it much more simply than that. Doesn't require multiple threads: 1. pthread_kill(th) 2. LOCK(killlock) 3. 4. signal handler: pthread_kill(th) 5. signal handler: LOCK(killlock) In the preceding example "th" can be any pthread_t value, the only requirement is that it's the same pthread_t in both the synchronous and signal handler context.