From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 673D93858C41 for ; Fri, 19 May 2023 18:57:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 673D93858C41 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q05Ia-0008AM-JY; Fri, 19 May 2023 14:57:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=18OwKutq8OAg4VjRPyyFfLlNP5RcFOYAdkIxh9Jg3aM=; b=GYJkOEMHo7V1Gaqvy9bx vYulARF8tBYdE/7D/wHn4XAF6qmA1YABCzk0MCfj0XI66EVySZm1YQsWaxLscEqr+FvIrVlpuegmu vswtUF/Zti/XhvFSWQY4XQWMwz7kiLLqMD2+SvQtHMzMxPkMj9Vl9g2/Qvo38uzW+H3K8QbvQvoDf HC5zc04EQFdGXWgOJUd38mXMrD74rN4sGdnpn+5/y8qHRB2O1e2RTaWn1MmfuCrBG3GOb30Dpr4hh 3TtnOuJjylFWYUqyg6dSY7jgubhCrxh0mR/DeZYIsdSEgUy9X/pcAnC5D0gZOOKrLMTiiMfKlaJVy sfrnKQg8U6ILyA==; Received: from 2a01cb008c251f00de41a9fffe47ec49.ipv6.abo.wanadoo.fr ([2a01:cb00:8c25:1f00:de41:a9ff:fe47:ec49] helo=begin.home) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q05IZ-0003b0-QY; Fri, 19 May 2023 14:57:56 -0400 Received: from samy by begin.home with local (Exim 4.96) (envelope-from ) id 1q05IW-006Ujj-1e; Fri, 19 May 2023 20:57:52 +0200 Date: Fri, 19 May 2023 20:57:52 +0200 From: Samuel Thibault To: Sergey Bugaev Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org, Joseph Myers Subject: Re: [PATCH] hurd: Fix using interposable hurd_thread_self Message-ID: <20230519185752.oj5x6ub7ufch6o3k@begin> Mail-Followup-To: Sergey Bugaev , libc-alpha@sourceware.org, bug-hurd@gnu.org, Joseph Myers References: <33736439-2470-fe8e-d22f-5f6c444d2817@codesourcery.com> <20230519144724.334179-1-bugaevc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230519144724.334179-1-bugaevc@gmail.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Checked and applied, thanks! Sergey Bugaev, le ven. 19 mai 2023 17:47:24 +0300, a ecrit: > Create a private hidden __hurd_thread_self alias, and use that one. > > Fixes 2f8ecb58a59eb82c43214d000842d99644a662d1 > "hurd: Fix x86_64 _hurd_tls_fork" and > c7fcce38c83a2bb665ef5dc4981bf20c7e586123 > "hurd: Make sure to not use tcb->self" > > Reported-by: Joseph Myers > Signed-off-by: Sergey Bugaev > --- > > This should hopefully fix it (but please test!); I have only checked > that it builds on x86_64-gnu, and that _Fork now calls > __GI___hurd_thread_self without the PLT, and that libpthread.so only > references __hurd_thread_self@GLIBC_PRIVATE. > > hurd/Versions | 1 + > hurd/thread-self.c | 5 ++++- > sysdeps/hurd/include/hurd.h | 3 +++ > sysdeps/mach/hurd/i386/htl/pt-setup.c | 2 +- > sysdeps/mach/hurd/x86_64/htl/pt-setup.c | 2 +- > sysdeps/mach/hurd/x86_64/tls.h | 7 +++++-- > 6 files changed, 15 insertions(+), 5 deletions(-) > > diff --git a/hurd/Versions b/hurd/Versions > index 3d8b412d..439e8abf 100644 > --- a/hurd/Versions > +++ b/hurd/Versions > @@ -156,6 +156,7 @@ libc { > __libc_open; __libc_close; > > # Used by libpthread. > + __hurd_thread_self; > _hurd_sigstate_set_global_rcv; > _hurd_sigstate_lock; > _hurd_sigstate_pending; > diff --git a/hurd/thread-self.c b/hurd/thread-self.c > index f3718165..af013503 100644 > --- a/hurd/thread-self.c > +++ b/hurd/thread-self.c > @@ -19,7 +19,10 @@ > #include > > thread_t > -hurd_thread_self (void) > +__hurd_thread_self (void) > { > return _hurd_self_sigstate ()->thread; > } > + > +libc_hidden_def (__hurd_thread_self) > +weak_alias (__hurd_thread_self, hurd_thread_self) > diff --git a/sysdeps/hurd/include/hurd.h b/sysdeps/hurd/include/hurd.h > index 7da9af26..5d904e0e 100644 > --- a/sysdeps/hurd/include/hurd.h > +++ b/sysdeps/hurd/include/hurd.h > @@ -11,5 +11,8 @@ void _hurd_libc_proc_init (char **argv); > libc_hidden_proto (_hurd_exec_paths) > libc_hidden_proto (_hurd_init) > libc_hidden_proto (_hurd_libc_proc_init) > + > +extern thread_t __hurd_thread_self (void); > +libc_hidden_proto (__hurd_thread_self) > #endif > #endif > diff --git a/sysdeps/mach/hurd/i386/htl/pt-setup.c b/sysdeps/mach/hurd/i386/htl/pt-setup.c > index ba108b96..27e5c98b 100644 > --- a/sysdeps/mach/hurd/i386/htl/pt-setup.c > +++ b/sysdeps/mach/hurd/i386/htl/pt-setup.c > @@ -79,7 +79,7 @@ __pthread_setup (struct __pthread *thread, > { > error_t err; > > - if (thread->kernel_thread == hurd_thread_self ()) > + if (thread->kernel_thread == __hurd_thread_self ()) > /* Fix up the TCB for the main thread. The C library has already > installed a TCB, which we want to keep using. This TCB must not > be freed so don't register it in the thread structure. On the > diff --git a/sysdeps/mach/hurd/x86_64/htl/pt-setup.c b/sysdeps/mach/hurd/x86_64/htl/pt-setup.c > index 7dc62912..8eebaf97 100644 > --- a/sysdeps/mach/hurd/x86_64/htl/pt-setup.c > +++ b/sysdeps/mach/hurd/x86_64/htl/pt-setup.c > @@ -56,7 +56,7 @@ __pthread_setup (struct __pthread *thread, > struct i386_thread_state state; > struct i386_fsgs_base_state fsgs_state; > > - if (thread->kernel_thread == hurd_thread_self ()) > + if (thread->kernel_thread == __hurd_thread_self ()) > /* Fix up the TCB for the main thread. The C library has already > installed a TCB, which we want to keep using. This TCB must not > be freed so don't register it in the thread structure. On the > diff --git a/sysdeps/mach/hurd/x86_64/tls.h b/sysdeps/mach/hurd/x86_64/tls.h > index 468f703f..a5a49a47 100644 > --- a/sysdeps/mach/hurd/x86_64/tls.h > +++ b/sysdeps/mach/hurd/x86_64/tls.h > @@ -132,6 +132,10 @@ THREAD_TCB (thread_t thread, > ((descr)->pointer_guard \ > = THREAD_GETMEM (THREAD_SELF, pointer_guard)) > > +/* From hurd.h, reproduced here to avoid a circular include. */ > +extern thread_t __hurd_thread_self (void); > +libc_hidden_proto (__hurd_thread_self) > + > /* Set up TLS in the new thread of a fork child, copying from the original. */ > static inline kern_return_t __attribute__ ((unused)) > _hurd_tls_fork (thread_t child, thread_t orig, > @@ -141,8 +145,7 @@ _hurd_tls_fork (thread_t child, thread_t orig, > struct i386_fsgs_base_state state; > mach_msg_type_number_t state_count = i386_FSGS_BASE_STATE_COUNT; > > - extern thread_t hurd_thread_self (void); > - if (orig != hurd_thread_self ()) > + if (orig != __hurd_thread_self ()) > { > err = __thread_get_state (orig, i386_FSGS_BASE_STATE, > (thread_state_t) &state, > -- > 2.40.1 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.