signal: Use SA_RESTORER on x86-64.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sat, 7 Sep 2019 16:52:09 +0000 (18:52 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 9 Sep 2019 14:04:15 +0000 (16:04 +0200)
* lib/linux/signal.c (signal)[x86_64]: Avoid segfault by setting
SA_RESTORER flag.

lib/linux/signal.c

index fe18d048edacf35fa4558828af3e8b965e80865b..2f17a3207c95306514053ae8b7ab49f6bb547121 100644 (file)
@@ -60,7 +60,11 @@ signal (int signum, sighandler_t action)
   setup_action.sa_mask.items[bitindex / itembitcount] = 1UL << (bitindex % itembitcount);
   old.sa_handler = SIG_DFL;
   setup_action.sa_flags = SA_RESTART;
-  int r = _sys_call4 (SYS_rt_sigaction, signum, &setup_action, &old, sizeof (sigset_t));
+#if __x86_64__
+  /* Tell kernel that we use a restorer, on penalty of segfault.  */
+  setup_action.sa_flags |= SA_RESTORER;
+#endif
+  int r = _sys_call4 (SYS_rt_sigaction, signum, (long)&setup_action, (long)&old, sizeof (sigset_t));
   if (r)
     return 0;
   return old.sa_handler;