Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 11 Jun 2019 10:36:24 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Cc: helitao <helitao@...wei.com>,
	"Huangqiang (H)" <h.huangqiang@...wei.com>,
	Jinyongming <jinyongming@...wei.com>,
	leijitang <leijitang@...wei.com>,
	"liuyutao (C)" <liuyutao2@...wei.com>,
	"Liyu (Marvin, Euler Dept)" <marvin.tms@...wei.com>,
	"Threefifteen Wang(Kunfeng)" <threefifteen.wangkunfeng@...wei.com>,
	"Wudilong (Michael)" <wudilong@...wei.com>
Subject: Re: [proposal] Add detection of thread ID in pthread-related
 interfaces

On Tue, Jun 11, 2019 at 03:57:42PM +0200, Szabolcs Nagy wrote:
> * pengyuanhong <pengyuanhong@...wei.com> [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

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.