public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v5 00/22] Fix Race conditions in pthread cancellation [BZ#12683]
@ 2023-04-10 19:58 Adhemerval Zanella
  2023-04-10 19:58 ` [PATCH v5 01/22] nptl: " Adhemerval Zanella
                   ` (8 more replies)
  0 siblings, 9 replies; 34+ messages in thread
From: Adhemerval Zanella @ 2023-04-10 19:58 UTC (permalink / raw)
  To: libc-alpha

This updated version from previous one [1] is simpler due the
changes already in done during past releases.  It only requires
changes on cancellation entrypoint, the SIGCANCEL handler, and
minor changes on pthread_cancel.  It also take in consideration
the recent regressions like 404656009b, where some syscall can
not be interrupted if not async mode is not enabled.

Each cancellable entrypoint is now a just tail call to internal
__syscall_cancel, with the nont required arguments set to 0 (it also
allows some code size optimization).  The single-thread or pthread
cancellation disable is handled at __syscall_cancel as well.

The first patch is the generic bits, while the rest is arch-specific
syscall_cancel.S entry points and/or arch-specific bits (like
7 argument support for mips or argument handling for x32).  So
it can not be installed separately, since the generic version does
not work correctly on all ABIs (another option might to move
the fix itself to be the last patch).

I have checked on x86_64, i686, aarch64, arm, powerpc, powerpc64,
powerpc64le, sparc64, and mips.  For the rest of the implementation
I manually crafted the syscall_cancel.S from the compiler generated
built of the generic syscall_cancel.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.

[1] https://sourceware.org/pipermail/libc-alpha/2020-April/112517.html

Adhemerval Zanella (22):
  nptl: Fix Race conditions in pthread cancellation [BZ#12683]
  x86_64: Fix Race conditions in pthread cancellation [BZ#12683]
  x32: Fix Race conditions in pthread cancellation [BZ#12683]
  i386: Fix Race conditions in pthread cancellation [BZ#12683]
  aarch64: Fix Race conditions in pthread cancellation [BZ#12683]
  arm: Fix Race conditions in pthread cancellation [BZ#12683]
  powerpc: Fix Race conditions in pthread cancellation [BZ#12683]
  sparc: Fix Race conditions in pthread cancellation [BZ#12683]
  s390: Fix Race conditions in pthread cancellation [BZ#12683]
  riscv: Fix Race conditions in pthread cancellation [BZ#12683]
  arc: Fix Race conditions in pthread cancellation [BZ #12683]
  ia64: Fix Race conditions in pthread cancellation [BZ#12683]
  sh: Fix Race conditions in pthread cancellation [BZ#12683]
  nios2: Fix Race conditions in pthread cancellation [BZ#12683]
  microblaze: Fix Race conditions in pthread cancellation [BZ#12683]
  hppa: Fix Race conditions in pthread cancellation [BZ#12683]
  m68k: Fix Race conditions in pthread cancellation [BZ#12683]
  alpha: Fix Race conditions in pthread cancellation [BZ#12683]
  csky: Fix Race conditions in pthread cancellation [BZ#12683]
  mips: Fix Race conditions in pthread cancellation [BZ#12683]
  or1k: Fix Race conditions in pthread cancellation [BZ#12683]
  loongarch: Fix Race conditions in pthread cancellation [BZ#12683]

 elf/Makefile                                  |   5 +-
 nptl/Makefile                                 |  11 +-
 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/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     |  54 ++++++
 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 +++++++
 .../unix/sysv/linux/powerpc/syscall_cancel.S  |  65 +++++++
 .../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 -
 53 files changed, 2551 insertions(+), 229 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/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

-- 
2.34.1


^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2023-04-27 11:14 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-10 19:58 [PATCH v5 00/22] Fix Race conditions in pthread cancellation [BZ#12683] Adhemerval Zanella
2023-04-10 19:58 ` [PATCH v5 01/22] nptl: " Adhemerval Zanella
2023-04-10 19:58 ` [PATCH v5 02/22] x86_64: " Adhemerval Zanella
2023-04-10 19:58 ` [PATCH v5 03/22] x32: " Adhemerval Zanella
2023-04-10 19:58 ` [PATCH v5 04/22] i386: " Adhemerval Zanella
2023-04-10 19:58 ` [PATCH v5 05/22] aarch64: " Adhemerval Zanella
2023-04-10 19:58 ` [PATCH v5 06/22] arm: " Adhemerval Zanella
2023-04-10 19:58 ` [PATCH v5 07/22] powerpc: " Adhemerval Zanella
2023-04-14 15:27   ` Paul E Murphy
2023-04-27 11:13     ` Adhemerval Zanella Netto
2023-04-10 19:58 ` [PATCH v5 08/22] sparc: " Adhemerval Zanella
2023-04-10 20:46 ` [PATCH v5 09/22] s390: " Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 10/22] riscv: " Adhemerval Zanella
2023-04-11  6:35     ` Xi Ruoyao
2023-04-11  7:01       ` Xi Ruoyao
2023-04-11 13:49         ` Adhemerval Zanella Netto
2023-04-10 20:46   ` [PATCH v5 11/22] arc: Fix Race conditions in pthread cancellation [BZ #12683] Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 12/22] ia64: Fix Race conditions in pthread cancellation [BZ#12683] Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 13/22] sh: " Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 14/22] nios2: " Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 15/22] microblaze: " Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 16/22] hppa: " Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 17/22] m68k: " Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 18/22] alpha: " Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 19/22] csky: " Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 20/22] mips: " Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 21/22] or1k: " Adhemerval Zanella
2023-04-10 20:46   ` [PATCH v5 22/22] loongarch: " Adhemerval Zanella
2023-04-11  6:19     ` Xi Ruoyao
2023-04-11 12:00       ` caiyinyu
2023-04-11 12:21         ` caiyinyu
2023-04-11 12:55         ` Xi Ruoyao
2023-04-11 13:54           ` Adhemerval Zanella Netto
2023-04-11 13:56   ` [PATCH v5 09/22] s390: " Stefan Liebler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).