about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-07-05 06:18:19 +0000
committerUlrich Drepper <drepper@redhat.com>2003-07-05 06:18:19 +0000
commita1ed6b4cabb0109106490f501ba64c2f45fa84e5 (patch)
tree4375002351b1ab6ddcd653c2639d224460975835
parentbdbecaa3f162567085a7c7f1e9788e51743983c1 (diff)
downloadglibc-a1ed6b4cabb0109106490f501ba64c2f45fa84e5.tar.gz
glibc-a1ed6b4cabb0109106490f501ba64c2f45fa84e5.tar.xz
glibc-a1ed6b4cabb0109106490f501ba64c2f45fa84e5.zip
(sigcancel_handler): Change parameters to match handler for SA_SIGACTION. Check signal number and code to recognize invalid invocations.
-rw-r--r--nptl/init.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/nptl/init.c b/nptl/init.c
index 3e041edeb3..abc785730a 100644
--- a/nptl/init.c
+++ b/nptl/init.c
@@ -132,8 +132,19 @@ static struct pthread_functions pthread_functions =
 
 /* For asynchronous cancellation we use a signal.  This is the handler.  */
 static void
-sigcancel_handler (int sig __attribute ((unused)))
+sigcancel_handler (int sig, siginfo_t *si, void *ctx)
 {
+  /* Safety check.  It would be possible to call this function for
+     other signals and send a signal from another thread.  This is not
+     correct and might even be a security problem.  Try to catch as
+     many incorrect invocations as possible.  */
+  if (sig != SIGCANCEL
+      || si->si_code != SI_TKILL)
+    /* XXX The Linux kernel currently does not report the correct PID
+       in the si->si_pid field.  Once this is changed another test
+       will be added.  */
+    return;
+
   struct pthread *self = THREAD_SELF;
 
   int oldval = THREAD_GETMEM (self, cancelhandling);
@@ -209,8 +220,8 @@ __pthread_initialize_minimal_internal (void)
      cannot install the handler we do not abort.  Maybe we should, but
      it is only asynchronous cancellation which is affected.  */
   struct sigaction sa;
-  sa.sa_handler = sigcancel_handler;
-  sa.sa_flags = 0;
+  sa.sa_sigaction = sigcancel_handler;
+  sa.sa_flags = SA_SIGINFO;
   sigemptyset (&sa.sa_mask);
 
   (void) __libc_sigaction (SIGCANCEL, &sa, NULL);