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=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32455 invoked from network); 11 Feb 2023 17:46:26 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 11 Feb 2023 17:46:26 -0000 Received: (qmail 26051 invoked by uid 550); 11 Feb 2023 17:46:23 -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 26018 invoked from network); 11 Feb 2023 17:46:22 -0000 Date: Sat, 11 Feb 2023 12:46:09 -0500 From: Rich Felker To: Markus Wichmann Cc: musl@lists.openwall.com, Alexey Izbyshev Message-ID: <20230211174609.GJ4163@brightrain.aerifal.cx> References: <20221109104613.48062-1-izbyshev@ispras.ru> <20221214022618.GB15716@brightrain.aerifal.cx> <1a0289c15879bef6d538c0066f58545c@ispras.ru> <20230210162957.GB4163@brightrain.aerifal.cx> <63c0897d647936c946268f5a967a5e4d@ispras.ru> <20230211150603.GI4163@brightrain.aerifal.cx> <20230211171338.GD1903@voyager> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230211171338.GD1903@voyager> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH] mq_notify: fix close/recv race on failure path On Sat, Feb 11, 2023 at 06:13:38PM +0100, Markus Wichmann wrote: > On Sat, Feb 11, 2023 at 10:06:03AM -0500, Rich Felker wrote: > > --- a/src/thread/pthread_detach.c > > +++ b/src/thread/pthread_detach.c > > @@ -5,8 +5,12 @@ static int __pthread_detach(pthread_t t) > > { > > /* If the cas fails, detach state is either already-detached > > * or exiting/exited, and pthread_join will trap or cleanup. */ > > - if (a_cas(&t->detach_state, DT_JOINABLE, DT_DETACHED) != DT_JOINABLE) > > + if (a_cas(&t->detach_state, DT_JOINABLE, DT_DETACHED) != DT_JOINABLE) { > > + int cs; > > + __pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); > > return __pthread_join(t, 0); > ^^^^^^ I think you forgot to rework this. > > + __pthread_setcancelstate(cs, 0); > > + } > > return 0; > > } > > > > I see no other obvious missteps, though. Thanks. I'll just remove the return keyword. There's no possible return value except 0; anything else would be UB (and we already trap it where possible). Rich