mbox series

[v6,0/1] Fix Race conditions in pthread cancellation

Message ID 20230519195059.2802116-1-adhemerval.zanella@linaro.org
Headers show
Series Fix Race conditions in pthread cancellation | expand

Message

Adhemerval Zanella Netto May 19, 2023, 7:50 p.m. UTC
This version now has all the required arch-specific bits, splitting
on different patch is tricky because the generic version does not
fully work on all architecture (it is still provided as architecture
guideline on how to implement it).

Not all architecture syscall_cancel.S are fully optimized, most of
I created from compiler generated code taking in consideration the
requirements constraints (the syscall instruction should be the
last on before the end label).  Each arch mantainer should check
if the resulting code is optimal.

Changes from v5:
  - Added scv support for powerpc.
  - Use tail on riscv.
  - Rewrite loongarch syscall_cancel.S (by Xi Ruoyao).
  - Fixed tst-cancel2.c.

Changes from v4:
  - Rebased against master, added or1k and loongarch.
  - Make SYSCALL_CANCEL and INTERNAL_SYSCALL_CANCEL macros to work
    better as tail call, to do not require argument suffling.
  - Fixed x32 to use TYPEFY and ARGIFY macros.
  - Fixed m68k to use names registers.
  - Fixed typos from last version.

Adhemerval Zanella (1):
  nptl: Fix Race conditions in pthread cancellation [BZ#12683]

 elf/Makefile                                  |   5 +-
 nptl/Makefile                                 |  10 +-
 nptl/cancellation.c                           | 115 ++++++------
 nptl/cleanup_defer.c                          |   5 +-
 nptl/descr-const.sym                          |   6 +
 nptl/descr.h                                  |  18 ++
 nptl/libc-cleanup.c                           |   5 +-
 nptl/pthread_cancel.c                         |  78 +++-----
 nptl/pthread_exit.c                           |   4 +-
 nptl/pthread_setcancelstate.c                 |   2 +-
 nptl/pthread_setcanceltype.c                  |   2 +-
 nptl/pthread_testcancel.c                     |   5 +-
 nptl/tst-cancel31.c                           | 100 ++++++++++
 sysdeps/generic/syscall_types.h               |  25 +++
 sysdeps/nptl/cancellation-pc-check.h          |  54 ++++++
 sysdeps/nptl/lowlevellock-futex.h             |  20 +-
 sysdeps/nptl/pthreadP.h                       |  11 +-
 sysdeps/powerpc/powerpc32/sysdep.h            |   3 +
 sysdeps/powerpc/powerpc64/sysdep.h            |  19 ++
 sysdeps/pthread/tst-cancel2.c                 |   4 +
 sysdeps/sh/sysdep.h                           |   1 +
 sysdeps/unix/sysdep.h                         | 173 ++++++++++++++----
 .../unix/sysv/linux/aarch64/syscall_cancel.S  |  59 ++++++
 .../unix/sysv/linux/alpha/syscall_cancel.S    |  80 ++++++++
 sysdeps/unix/sysv/linux/arc/syscall_cancel.S  |  56 ++++++
 sysdeps/unix/sysv/linux/arm/syscall_cancel.S  |  78 ++++++++
 sysdeps/unix/sysv/linux/csky/syscall_cancel.S | 114 ++++++++++++
 sysdeps/unix/sysv/linux/hppa/syscall_cancel.S |  81 ++++++++
 sysdeps/unix/sysv/linux/i386/syscall_cancel.S | 103 +++++++++++
 .../sysv/linux/ia64/cancellation-pc-check.h   |  48 +++++
 sysdeps/unix/sysv/linux/ia64/syscall_cancel.S |  81 ++++++++
 .../sysv/linux/loongarch/syscall_cancel.S     |  50 +++++
 sysdeps/unix/sysv/linux/m68k/syscall_cancel.S |  84 +++++++++
 .../sysv/linux/microblaze/syscall_cancel.S    |  61 ++++++
 .../sysv/linux/mips/mips32/syscall_cancel.S   | 128 +++++++++++++
 sysdeps/unix/sysv/linux/mips/mips32/sysdep.h  |   4 +
 .../linux/mips/mips64/n32/syscall_types.h     |  28 +++
 .../sysv/linux/mips/mips64/syscall_cancel.S   | 108 +++++++++++
 sysdeps/unix/sysv/linux/mips/mips64/sysdep.h  |  52 +++---
 .../unix/sysv/linux/nios2/syscall_cancel.S    |  95 ++++++++++
 sysdeps/unix/sysv/linux/or1k/syscall_cancel.S |  63 +++++++
 .../linux/powerpc/cancellation-pc-check.h     |  65 +++++++
 .../unix/sysv/linux/powerpc/syscall_cancel.S  |  86 +++++++++
 .../unix/sysv/linux/riscv/syscall_cancel.S    |  67 +++++++
 .../sysv/linux/s390/s390-32/syscall_cancel.S  |  62 +++++++
 .../sysv/linux/s390/s390-64/syscall_cancel.S  |  62 +++++++
 sysdeps/unix/sysv/linux/sh/syscall_cancel.S   | 126 +++++++++++++
 sysdeps/unix/sysv/linux/socketcall.h          |  35 +++-
 .../sysv/linux/sparc/sparc32/syscall_cancel.S |  71 +++++++
 .../sysv/linux/sparc/sparc64/syscall_cancel.S |  74 ++++++++
 sysdeps/unix/sysv/linux/syscall_cancel.c      |  73 ++++++++
 sysdeps/unix/sysv/linux/sysdep-cancel.h       |  12 --
 .../unix/sysv/linux/x86_64/syscall_cancel.S   |  57 ++++++
 .../sysv/linux/x86_64/x32/syscall_types.h     |  34 ++++
 sysdeps/x86_64/nptl/tcb-offsets.sym           |   3 -
 55 files changed, 2637 insertions(+), 228 deletions(-)
 create mode 100644 nptl/descr-const.sym
 create mode 100644 nptl/tst-cancel31.c
 create mode 100644 sysdeps/generic/syscall_types.h
 create mode 100644 sysdeps/nptl/cancellation-pc-check.h
 create mode 100644 sysdeps/unix/sysv/linux/aarch64/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/alpha/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/arm/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/hppa/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/i386/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/ia64/cancellation-pc-check.h
 create mode 100644 sysdeps/unix/sysv/linux/ia64/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/m68k/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips32/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/syscall_types.h
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/nios2/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/or1k/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/cancellation-pc-check.h
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/riscv/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/sh/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/syscall_cancel.c
 create mode 100644 sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/x86_64/x32/syscall_types.h