public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] hurd: Fix using interposable hurd_thread_self
@ 2023-05-19 18:57 Samuel Thibault
  0 siblings, 0 replies; only message in thread
From: Samuel Thibault @ 2023-05-19 18:57 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b44c1e12524bb5de0f93294a7c24c8e41c06bb75

commit b44c1e12524bb5de0f93294a7c24c8e41c06bb75
Author: Sergey Bugaev <bugaevc@gmail.com>
Date:   Fri May 19 17:47:24 2023 +0300

    hurd: Fix using interposable hurd_thread_self
    
    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 <joseph@codesourcery.com>
    Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>

Diff:
---
 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 3d8b412d49..439e8abf32 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 f37181656e..af013503bf 100644
--- a/hurd/thread-self.c
+++ b/hurd/thread-self.c
@@ -19,7 +19,10 @@
 #include <hurd/signal.h>
 
 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 7da9af2656..568092d670 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 ba108b9611..27e5c98bf4 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 7dc6291261..8eebaf97ee 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 6487ed3580..e791186934 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,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-19 18:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-19 18:57 [glibc] hurd: Fix using interposable hurd_thread_self Samuel Thibault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).