From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14223 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [proposal] Add detection of thread ID in pthread-related interfaces Date: Tue, 11 Jun 2019 10:36:24 -0400 Message-ID: <20190611143624.GA1506@brightrain.aerifal.cx> References: <4CF320752F2B99449115298D4A06B22F34E3DD31@dggemm509-mbx.china.huawei.com> <20190611135741.GY16415@port70.net> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="182535"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) Cc: helitao , "Huangqiang (H)" , Jinyongming , leijitang , "liuyutao (C)" , "Liyu (Marvin, Euler Dept)" , "Threefifteen Wang(Kunfeng)" , "Wudilong (Michael)" To: musl@lists.openwall.com Original-X-From: musl-return-14239-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jun 11 16:36:40 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hahtA-000lCj-E1 for gllmg-musl@m.gmane.org; Tue, 11 Jun 2019 16:36:40 +0200 Original-Received: (qmail 21582 invoked by uid 550); 11 Jun 2019 14:36:37 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 21559 invoked from network); 11 Jun 2019 14:36:37 -0000 Content-Disposition: inline In-Reply-To: <20190611135741.GY16415@port70.net> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14223 Archived-At: On Tue, Jun 11, 2019 at 03:57:42PM +0200, Szabolcs Nagy wrote: > * pengyuanhong [2019-06-11 11:36:59 +0000]: > > I find that all pthread-related interfaces directly access the input > > parameter `pthread_t` without any check. If I pass an invalid thread ID > > (e.g. an exited thread ID) to these interfaces, then segment fault > > happens. > > > > Both glibc and freebsd can do simple detection of thread ID(pthread_t) > > passed by user and return ESRCH when no thread can be found. They > > that's a historical bug in posix: it required ESRCH > which is not possible when the thread id is reused, > so all such requirments were removed in posix 2008 > https://collaboration.opengroup.org/austin/interps/documents/14366/AI-142.txt > > passing invalid id is simply undefined now, an ^^^^ It was always undefined; the text stating that it's undefined was present in old POSIX too. The "shall fail" text in the ESRCH errors was if "the implementation has detected..." or similar, which oddly imposed a requirement to report something if it was detected, but didn't (and fundamentally couldn't, since it's undetectable with identifier reusage) impose a requirement to detect. The committee recognized that this made no sense and fixed it by removing the "shall fail" text. This was not a functional change, only a clarification, and thus didn't require a new version of the standard, just a TC. Rich