Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230211174609.GJ4163@brightrain.aerifal.cx>
Date: Sat, 11 Feb 2023 12:46:09 -0500
From: Rich Felker <dalias@...c.org>
To: Markus Wichmann <nullplan@....net>
Cc: musl@...ts.openwall.com, Alexey Izbyshev <izbyshev@...ras.ru>
Subject: Re: [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

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.