aboutsummaryrefslogtreecommitdiff
path: root/nptl/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/init.c')
-rw-r--r--nptl/init.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/nptl/init.c b/nptl/init.c
index 4db3e0c..7cfe803 100644
--- a/nptl/init.c
+++ b/nptl/init.c
@@ -148,6 +148,14 @@ static const struct pthread_functions pthread_functions =
static void
sigcancel_handler (int sig, siginfo_t *si, void *ctx)
{
+#ifdef __ASSUME_CORRECT_SI_PID
+ /* Determine the process ID. It might be negative if the thread is
+ in the middle of a fork() call. */
+ pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
+ if (__builtin_expect (pid < 0, 0))
+ pid = -pid;
+#endif
+
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
@@ -156,7 +164,7 @@ sigcancel_handler (int sig, siginfo_t *si, void *ctx)
#ifdef __ASSUME_CORRECT_SI_PID
/* Kernels before 2.5.75 stored the thread ID and not the process
ID in si_pid so we skip this test. */
- || si->si_pid != THREAD_GETMEM (THREAD_SELF, pid)
+ || si->si_pid != pid
#endif
|| si->si_code != SI_TKILL)
return;
@@ -201,6 +209,14 @@ struct xid_command *__xidcmd attribute_hidden;
static void
sighandler_setxid (int sig, siginfo_t *si, void *ctx)
{
+#ifdef __ASSUME_CORRECT_SI_PID
+ /* Determine the process ID. It might be negative if the thread is
+ in the middle of a fork() call. */
+ pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
+ if (__builtin_expect (pid < 0, 0))
+ pid = -pid;
+#endif
+
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
@@ -209,7 +225,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx)
#ifdef __ASSUME_CORRECT_SI_PID
/* Kernels before 2.5.75 stored the thread ID and not the process
ID in si_pid so we skip this test. */
- || si->si_pid != THREAD_GETMEM (THREAD_SELF, pid)
+ || si->si_pid != pid
#endif
|| si->si_code != SI_TKILL)
return;