From eae81d70574e923ce3c59078b8df857ae192efa6 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 1 Oct 2021 18:16:41 +0200 Subject: nptl: pthread_kill must send signals to a specific thread [BZ #28407] The choice between the kill vs tgkill system calls is not just about the TID reuse race, but also about whether the signal is sent to the whole process (and any thread in it) or to a specific thread. This was caught by the openposix test suite: LTP: openposix test suite - FAIL: SIGUSR1 is member of new thread pendingset. Fixes commit 526c3cf11ee9367344b6b15d669e4c3cb461a2be ("nptl: Fix race between pthread_kill and thread exit (bug 12889)"). Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell --- nptl/pthread_kill.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'nptl') diff --git a/nptl/pthread_kill.c b/nptl/pthread_kill.c index a44dc8f2d9..35bf1f973e 100644 --- a/nptl/pthread_kill.c +++ b/nptl/pthread_kill.c @@ -40,7 +40,7 @@ __pthread_kill_implementation (pthread_t threadid, int signo, int no_tid) below. POSIX only guarantees delivery of a single signal, which may not be the right one.) */ pid_t tid = INTERNAL_SYSCALL_CALL (gettid); - int ret = INTERNAL_SYSCALL_CALL (kill, tid, signo); + int ret = INTERNAL_SYSCALL_CALL (tgkill, __getpid (), tid, signo); return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0; } @@ -59,8 +59,6 @@ __pthread_kill_implementation (pthread_t threadid, int signo, int no_tid) ret = no_tid; else { - /* Using tgkill is a safety measure. pd->exit_lock ensures that - the target thread cannot exit. */ ret = INTERNAL_SYSCALL_CALL (tgkill, __getpid (), pd->tid, signo); ret = INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0; } -- cgit 1.4.1