Linux: Explicitly disable cancellation checking in the dynamic loader
authorFlorian Weimer <fweimer@redhat.com>
Mon, 10 May 2021 08:31:41 +0000 (10:31 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 10 May 2021 08:31:41 +0000 (10:31 +0200)
Historically, SINGLE_THREAD_P is defined to 1 in the dynamic loader.
This has the side effect of disabling cancellation points.  In order
to enable future use of SINGLE_THREAD_P for single-thread
optimizations in the dynamic loader (which becomes important once
more code is moved from libpthread), introduce a new
NO_SYSCALL_CANCEL_CHECKING macro which is always 1 for IS_IN (rtld),
indepdently of the actual SINGLE_THREAD_P value.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
sysdeps/unix/sysdep.h

index 2fa6bfa..664d093 100644 (file)
 #define INLINE_SYSCALL_CALL(...) \
   __INLINE_SYSCALL_DISP (__INLINE_SYSCALL, __VA_ARGS__)
 
+#if IS_IN (rtld)
+/* All cancellation points are compiled out in the dynamic loader.  */
+# define NO_SYSCALL_CANCEL_CHECKING 1
+#else
+# define NO_SYSCALL_CANCEL_CHECKING SINGLE_THREAD_P
+#endif
+
 #define SYSCALL_CANCEL(...) \
   ({                                                                        \
     long int sc_ret;                                                        \
-    if (SINGLE_THREAD_P)                                                    \
+    if (NO_SYSCALL_CANCEL_CHECKING)                                         \
       sc_ret = INLINE_SYSCALL_CALL (__VA_ARGS__);                           \
     else                                                                    \
       {                                                                             \
 #define INTERNAL_SYSCALL_CANCEL(...) \
   ({                                                                        \
     long int sc_ret;                                                        \
-    if (SINGLE_THREAD_P)                                                    \
+    if (NO_SYSCALL_CANCEL_CHECKING)                                         \
       sc_ret = INTERNAL_SYSCALL_CALL (__VA_ARGS__);                         \
     else                                                                    \
       {                                                                             \