From bddde5860ffb8a78587854cc8e3e914bd69269ca Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sun, 22 Jan 2017 10:24:51 +0100 Subject: remove PID caching Follow GNU C Library from c579f48edba88380635ab98cb612030e3ed8691e and remove the PID caching. These simplifies the architecture specific assembly code. The run of the test suite found no regressions, it even solves some of the test failures for x86/x86_64/sparc. Reviewed-by: Max Filippov Reviewed-by: Vineet Gupta Acked-by: Matthew Fortune Acked-by: Alexey Brodkin --- libpthread/nptl/init.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'libpthread/nptl/init.c') diff --git a/libpthread/nptl/init.c b/libpthread/nptl/init.c index 0e1c60cda..09220c220 100644 --- a/libpthread/nptl/init.c +++ b/libpthread/nptl/init.c @@ -64,24 +64,13 @@ static const char nptl_version[] __attribute_used__ = VERSION; 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 many incorrect invocations as possible. */ if (sig != SIGCANCEL -#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 != pid -#endif + || si->si_pid != getpid() || si->si_code != SI_TKILL) return; @@ -125,24 +114,13 @@ 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 many incorrect invocations as possible. */ if (sig != SIGSETXID -#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 != pid -#endif + || si->si_pid != getpid() || si->si_code != SI_TKILL) return; @@ -191,7 +169,7 @@ __pthread_initialize_minimal_internal (void) /* Minimal initialization of the thread descriptor. */ struct pthread *pd = THREAD_SELF; INTERNAL_SYSCALL_DECL (err); - pd->pid = pd->tid = INTERNAL_SYSCALL (set_tid_address, err, 1, &pd->tid); + pd->tid = INTERNAL_SYSCALL (set_tid_address, err, 1, &pd->tid); THREAD_SETMEM (pd, specific[0], &pd->specific_1stblock[0]); THREAD_SETMEM (pd, user_stack, true); if (LLL_LOCK_INITIALIZER != 0) -- cgit v1.2.3