[v3,0/2] Fix pthread_cancel, pthread_kill race (bug 12889)

Message ID cover.1630931178.git.fweimer@redhat.com
Headers show
Series
  • Fix pthread_cancel, pthread_kill race (bug 12889)
Related show

Message

H.J. Lu via Libc-alpha Sept. 6, 2021, 12:33 p.m.
This is a repost of the previous series, with an internal (futex-based)
lock and separate flag in struct pthread.  __pthread_call_with_tid is
gone (it's inlined into __pthread_kill_internal).

This is the version I propose to backport to glibc 2.34.  I think it
should go into the main branch as well, unless Adhemerval's larger
series is committed first.

I had to fix a defect in the tst-pthread_kill-exiting.  The sending
threads were not signaled in all cases, leading to a deadlock.

Thanks,
Florian

Florian Weimer (2):
  nptl: pthread_kill, pthread_cancel should not fail after exit (bug
    19193)
  nptl: Fix race between pthread_kill and thread exit (bug 12889)

 nptl/allocatestack.c                          |   3 +
 nptl/descr.h                                  |   6 +
 nptl/pthread_cancel.c                         |   9 +-
 nptl/pthread_create.c                         |  14 ++
 nptl/pthread_kill.c                           |  60 ++++++---
 sysdeps/pthread/Makefile                      |   7 +-
 sysdeps/pthread/tst-kill4.c                   |  89 -------------
 sysdeps/pthread/tst-pthread_cancel-exited.c   |  45 +++++++
 .../pthread/tst-pthread_cancel-select-loop.c  |  87 +++++++++++++
 sysdeps/pthread/tst-pthread_kill-exited.c     |  46 +++++++
 sysdeps/pthread/tst-pthread_kill-exiting.c    | 123 ++++++++++++++++++
 11 files changed, 375 insertions(+), 114 deletions(-)
 delete mode 100644 sysdeps/pthread/tst-kill4.c
 create mode 100644 sysdeps/pthread/tst-pthread_cancel-exited.c
 create mode 100644 sysdeps/pthread/tst-pthread_cancel-select-loop.c
 create mode 100644 sysdeps/pthread/tst-pthread_kill-exited.c
 create mode 100644 sysdeps/pthread/tst-pthread_kill-exiting.c

-- 
2.31.1