93dc2d
Downstream adjustment: Change return type of
93dc2d
rseq_register_current_thread to bool.  Upstream, this was part of the
93dc2d
commit that introduced the ABI symbols.
93dc2d
93dc2d
commit a41c8e92350e744a4bc639df5025153d05263e7f
93dc2d
Author: Florian Weimer <fweimer@redhat.com>
93dc2d
Date:   Thu Dec 9 09:49:32 2021 +0100
93dc2d
93dc2d
    nptl: rseq failure after registration on main thread is fatal
93dc2d
93dc2d
    This simplifies the application programming model.
93dc2d
93dc2d
    Browser sandboxes have already been fixed:
93dc2d
93dc2d
      Sandbox is incompatible with rseq registration
93dc2d
      <https://bugzilla.mozilla.org/show_bug.cgi?id=1651701>
93dc2d
93dc2d
      Allow rseq in the Linux sandboxes. r=gcp
93dc2d
      <https://hg.mozilla.org/mozilla-central/rev/042425712eb1>
93dc2d
93dc2d
      Sandbox needs to support rseq system call
93dc2d
      <https://bugs.chromium.org/p/chromium/issues/detail?id=1104160>
93dc2d
93dc2d
      Linux sandbox: Allow rseq(2)
93dc2d
      <https://chromium.googlesource.com/chromium/src.git/+/230675d9ac8f1>
93dc2d
93dc2d
    Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
93dc2d
93dc2d
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
93dc2d
index f405fa356c2955ce..109c5e3dc78c9aa2 100644
93dc2d
--- a/nptl/pthread_create.c
93dc2d
+++ b/nptl/pthread_create.c
93dc2d
@@ -371,7 +371,8 @@ start_thread (void *arg)
93dc2d
   /* Register rseq TLS to the kernel.  */
93dc2d
   {
93dc2d
     bool do_rseq = THREAD_GETMEM (pd, flags) & ATTR_FLAG_DO_RSEQ;
93dc2d
-    rseq_register_current_thread (pd, do_rseq);
93dc2d
+    if (!rseq_register_current_thread (pd, do_rseq) && do_rseq)
93dc2d
+      __libc_fatal ("Fatal glibc error: rseq registration failed\n");
93dc2d
   }
93dc2d
 
93dc2d
 #ifndef __ASSUME_SET_ROBUST_LIST
93dc2d
diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h b/sysdeps/unix/sysv/linux/rseq-internal.h
93dc2d
index 15bc7ffd6eda632d..6a3441f2cc49e7c4 100644
93dc2d
--- a/sysdeps/unix/sysv/linux/rseq-internal.h
93dc2d
+++ b/sysdeps/unix/sysv/linux/rseq-internal.h
93dc2d
@@ -26,7 +26,7 @@
93dc2d
 #include <sys/rseq.h>
93dc2d
 
93dc2d
 #ifdef RSEQ_SIG
93dc2d
-static inline void
93dc2d
+static inline bool
93dc2d
 rseq_register_current_thread (struct pthread *self, bool do_rseq)
93dc2d
 {
93dc2d
   if (do_rseq)
93dc2d
@@ -35,15 +35,17 @@ rseq_register_current_thread (struct pthread *self, bool do_rseq)
93dc2d
                                        sizeof (self->rseq_area),
93dc2d
                                        0, RSEQ_SIG);
93dc2d
       if (!INTERNAL_SYSCALL_ERROR_P (ret))
93dc2d
-        return;
93dc2d
+        return true;
93dc2d
     }
93dc2d
   THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED);
93dc2d
+  return false;
93dc2d
 }
93dc2d
 #else /* RSEQ_SIG */
93dc2d
 static inline void
93dc2d
 rseq_register_current_thread (struct pthread *self, bool do_rseq)
93dc2d
 {
93dc2d
   THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED);
93dc2d
+  return false;
93dc2d
 }
93dc2d
 #endif /* RSEQ_SIG */
93dc2d