From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/594 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: tough choice on thread pointer initialization issue Date: Sat, 25 Feb 2012 08:32:13 -0500 Message-ID: <20120225133213.GG184@brightrain.aerifal.cx> References: <20120210025824.GA25414@brightrain.aerifal.cx> <20120225065613.GF184@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1330176809 3654 80.91.229.3 (25 Feb 2012 13:33:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 25 Feb 2012 13:33:29 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-595-gllmg-musl=m.gmane.org@lists.openwall.com Sat Feb 25 14:33:27 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1S1Hkb-0001tL-Jp for gllmg-musl@plane.gmane.org; Sat, 25 Feb 2012 14:33:25 +0100 Original-Received: (qmail 30223 invoked by uid 550); 25 Feb 2012 13:33:24 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 30212 invoked from network); 25 Feb 2012 13:33:24 -0000 Content-Disposition: inline In-Reply-To: <20120225065613.GF184@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:594 Archived-At: On Sat, Feb 25, 2012 at 01:56:13AM -0500, Rich Felker wrote: > I've looked into the "solution 4" that Solar proposed, which simply > put is making __pthread_self() check for a clobbered thread register > and restore it. While this sounds simple, there are a few issues I've > run into whereby it starts to get ugly... Some revisions... it's not quite as bad as I said, but still not good either.. > with, but from reading the kernel sources, it looks like %fs is 0 and > a hidden 64-bit offset is stored in a privileged register accessible > only by the kernel (one which hopefully would not be clobbered by > sigreturn, but I'm not sure...) when the thread pointer does not fit > in 32 bits, and the old i386 method (LDT entry and non-zero %fs > selector value) is used when the thread pointer fits in 32 bits. This Got the cases reversed I think, but the issue still stands. > pointer is valid, we can't restore it (and the value of %fs might > actually need to differ per-thread if some threads are below the 4gb > boundary and others are located above). Per-thread difference is irrelevant since only the main thread can ever experience this problem; all new threads start with a valid thread pointer. Rich