public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 00/21] nptl: Fix Race conditions in pthread cancellation (BZ#12683)
@ 2019-10-14 20:57 Adhemerval Zanella
  2019-10-14 20:57 ` [PATCH v3 01/21] nptl: Handle EPIPE on tst-cancel2 Adhemerval Zanella
                   ` (20 more replies)
  0 siblings, 21 replies; 38+ messages in thread
From: Adhemerval Zanella @ 2019-10-14 20:57 UTC (permalink / raw)
  To: libc-alpha

This is an updated version of my previous version [1] to fix BZ#12683.
All the required internal changes not related to fix itself were
already pushed, so the patchset contains only the changes to fix
the issue itself.

The changes from previous version [1] are:

  - Add a syscall_cancel.S implementation for every port, as suggested
    by Zack Weinberg.  I agree with him that the reference C
    implementation is somewhat fragile to generate the correct markers,
    so I keep it only to use as reference for future ports to which
    semantic it should implement.

  - Fixed issues on ia64 regarding architecture instruction bundle
    and how kernel returned a syscall with side-effects.

  - Rework the SIGCANCEL handler so architectures that uses a different
    signature other than ucontext_t as third argument can override the
    required fields.

I also extended the architectures I fully tested with a make check
on real hardware:

	aarch64			no regresssions
	alpha			no regresssions
	arm			no regresssions
	csky			no coverage
	hppa			no regresssions
	i386			no regresssions
	ia64			1 regression *
	m68k			basic tests on simulator
	microblaze		no coverage
	mips64			no regresssions
	mips64n32		no regresssions
	mips			no regresssions
	nios2			no coverage
	powerpc			no regresssions
	powerpc64		no regresssions
	powerpc64le		no regresssions
	riscv64			no coverage
	s390x			no regresssions
	s390			no regresssions
	sh4			no regresssions
	sparc64			1 regression **
	sparcv9			no regresssions
	x86_64			no regresssions
	x86_64-32		no regresssions

*  On ia64 I am seeing nptl/tst-cancel21{-static} failure on libunwind stack
   unwind on third internal test (for SA_SIGINFO).  It only happens also for
   exception based unwind (-fexceptions), so I presume it might be related to
   the arch-specific syscall_cancel.S implementation.

** on sparc64 I am seeing intermitent nptl/tst-cond25 failures I can't
   pinpoint exactly what is triggering the SEGFAULT.  I am inclined to
   see it as a codegen issue, I will try with an updated compiler.

[1] https://sourceware.org/ml/libc-alpha/2018-02/msg00782.html

Adhemerval Zanella (21):
  nptl: Handle EPIPE on tst-cancel2
  nptl: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: x86_64: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: ia64: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: mips: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: i386: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: aarch64: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: arm: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: powerpc: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: microblaze: Fix Race conditions in pthread cancellation
    (BZ#12683)
  nptl: sparc: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: hppa: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: m68k: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: alpha: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: sh: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: riscv: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: s390: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: nios2: Fix Race conditions in pthread cancellation (BZ#12683)
  nptl: csky: Fix Race conditions in pthread cancellation (BZ#12683)
  Remove sysdep-cancel header

 elf/dl-close.c                                |   1 -
 elf/dl-lookup.c                               |   1 -
 elf/dl-open.c                                 |   1 -
 elf/dl-runtime.c                              |   1 -
 elf/dl-scope.c                                |   1 -
 elf/dl-sym.c                                  |   1 -
 include/libc-pointer-arith.h                  |  16 ++-
 io/creat.c                                    |   1 -
 io/ppoll.c                                    |   1 -
 malloc/malloc.c                               |   3 -
 manual/llio.texi                              |   4 +-
 misc/pselect.c                                |   1 -
 nptl/Makefile                                 |  12 +-
 nptl/Versions                                 |   3 +
 nptl/cancellation.c                           | 101 -------------
 nptl/descr.h                                  |  15 +-
 nptl/libc-cancellation.c                      |  46 +++++-
 nptl/nptl-init.c                              |  88 ++++++------
 nptl/pthreadP.h                               |  40 +++++-
 nptl/pthread_cancel.c                         |  69 ++-------
 nptl/pthread_create.c                         |   7 +-
 nptl/pthread_exit.c                           |   5 +-
 nptl/pthread_join_common.c                    |   2 +-
 nptl/pthread_kill.c                           |   7 +-
 .../pthread_kill_internal.c                   |  15 +-
 nptl/pthread_setcanceltype.c                  |   2 +-
 nptl/thrd_sleep.c                             |   8 +-
 nptl/tst-cancel2.c                            |   3 -
 nptl/tst-cancel28.c                           | 100 +++++++++++++
 rt/Makefile                                   |   2 +-
 sysdeps/generic/sysdep-cancel.h               |   7 -
 sysdeps/htl/pthreadP.h                        |   1 +
 sysdeps/mach/hurd/sysdep-cancel.h             |   8 --
 sysdeps/mips/dl-trampoline.c                  |   1 -
 sysdeps/mips/nptl/tls.h                       |   2 +-
 sysdeps/nptl/Makefile                         |   3 +-
 sysdeps/nptl/cancellation-pc-check.h          |  40 ++++++
 .../cancellation-sigmask.h}                   |  21 ++-
 sysdeps/posix/open64.c                        |   1 -
 sysdeps/posix/pause.c                         |   1 -
 sysdeps/posix/sigpause.c                      |   1 -
 sysdeps/posix/sigwait.c                       |   1 -
 sysdeps/posix/waitid.c                        |   1 -
 sysdeps/powerpc/powerpc32/sysdep.h            |   3 +
 sysdeps/powerpc/powerpc64/sysdep.h            |  19 +++
 sysdeps/sh/sysdep.h                           |   1 +
 sysdeps/unix/clock_nanosleep.c                |   1 -
 sysdeps/unix/sysdep.h                         | 136 ++++++++++++++----
 .../unix/sysv/linux/aarch64/syscall_cancel.S  |  61 ++++++++
 sysdeps/unix/sysv/linux/accept.c              |   1 -
 sysdeps/unix/sysv/linux/accept4.c             |   1 -
 sysdeps/unix/sysv/linux/access.c              |   2 +-
 sysdeps/unix/sysv/linux/alpha/select.c        |   1 -
 .../unix/sysv/linux/alpha/syscall_cancel.S    |  82 +++++++++++
 sysdeps/unix/sysv/linux/arm/syscall_cancel.S  |  80 +++++++++++
 sysdeps/unix/sysv/linux/clock_nanosleep.c     |   7 +-
 sysdeps/unix/sysv/linux/close.c               |   1 -
 sysdeps/unix/sysv/linux/close_nocancel.c      |   1 -
 sysdeps/unix/sysv/linux/connect.c             |   1 -
 sysdeps/unix/sysv/linux/copy_file_range.c     |   1 -
 sysdeps/unix/sysv/linux/creat.c               |   1 -
 sysdeps/unix/sysv/linux/creat64.c             |   1 -
 sysdeps/unix/sysv/linux/csky/syscall_cancel.S | 116 +++++++++++++++
 sysdeps/unix/sysv/linux/epoll_pwait.c         |   1 -
 sysdeps/unix/sysv/linux/epoll_wait.c          |   1 -
 sysdeps/unix/sysv/linux/fallocate.c           |   1 -
 sysdeps/unix/sysv/linux/fallocate64.c         |   1 -
 sysdeps/unix/sysv/linux/fcntl.c               |   1 -
 sysdeps/unix/sysv/linux/fcntl64.c             |   1 -
 sysdeps/unix/sysv/linux/fcntl_nocancel.c      |   1 -
 sysdeps/unix/sysv/linux/fdatasync.c           |   2 +-
 sysdeps/unix/sysv/linux/fsync.c               |   2 +-
 sysdeps/unix/sysv/linux/futex-internal.h      |  19 +--
 sysdeps/unix/sysv/linux/getrandom.c           |   1 -
 sysdeps/unix/sysv/linux/hppa/syscall_cancel.S |  82 +++++++++++
 sysdeps/unix/sysv/linux/i386/Makefile         |   2 +-
 sysdeps/unix/sysv/linux/i386/syscall_cancel.S | 105 ++++++++++++++
 .../sysv/linux/ia64/cancellation-pc-check.h   |  48 +++++++
 .../sysv/linux/ia64/cancellation-sigmask.h    |  33 +++++
 sysdeps/unix/sysv/linux/ia64/syscall_cancel.S |  83 +++++++++++
 sysdeps/unix/sysv/linux/lowlevellock-futex.h  |  46 ++++--
 sysdeps/unix/sysv/linux/m68k/syscall_cancel.S |  87 +++++++++++
 .../sysv/linux/microblaze/syscall_cancel.S    |  64 +++++++++
 .../sysv/linux/mips/mips32/syscall_cancel.S   | 128 +++++++++++++++++
 sysdeps/unix/sysv/linux/mips/mips32/sysdep.h  |   4 +
 .../sysv/linux/mips/mips64/syscall_cancel.S   | 114 +++++++++++++++
 sysdeps/unix/sysv/linux/mq_timedreceive.c     |   2 +-
 sysdeps/unix/sysv/linux/mq_timedsend.c        |   2 +-
 sysdeps/unix/sysv/linux/msgrcv.c              |   2 +-
 sysdeps/unix/sysv/linux/msgsnd.c              |   2 +-
 sysdeps/unix/sysv/linux/msync.c               |   2 +-
 sysdeps/unix/sysv/linux/nanosleep.c           |   3 +-
 sysdeps/unix/sysv/linux/nanosleep_nocancel.c  |   1 -
 .../unix/sysv/linux/nios2/syscall_cancel.S    |  97 +++++++++++++
 sysdeps/unix/sysv/linux/open.c                |   3 +-
 sysdeps/unix/sysv/linux/open64.c              |   4 +-
 sysdeps/unix/sysv/linux/open_by_handle_at.c   |   2 +-
 sysdeps/unix/sysv/linux/open_nocancel.c       |   1 -
 sysdeps/unix/sysv/linux/openat.c              |   3 +-
 sysdeps/unix/sysv/linux/openat64.c            |   3 +-
 sysdeps/unix/sysv/linux/openat64_nocancel.c   |   1 -
 sysdeps/unix/sysv/linux/openat_nocancel.c     |   1 -
 sysdeps/unix/sysv/linux/pause.c               |   2 +-
 sysdeps/unix/sysv/linux/pause_nocancel.c      |   1 -
 sysdeps/unix/sysv/linux/poll.c                |   1 -
 .../unix/sysv/linux/powerpc/syscall_cancel.S  |  67 +++++++++
 sysdeps/unix/sysv/linux/ppoll.c               |   2 -
 sysdeps/unix/sysv/linux/pread.c               |   2 +-
 sysdeps/unix/sysv/linux/pread64.c             |   2 +-
 sysdeps/unix/sysv/linux/preadv.c              |   2 +-
 sysdeps/unix/sysv/linux/preadv2.c             |   2 +-
 sysdeps/unix/sysv/linux/preadv64.c            |   2 +-
 sysdeps/unix/sysv/linux/preadv64v2.c          |   2 +-
 sysdeps/unix/sysv/linux/pselect.c             |   2 -
 ...pthread_kill.c => pthread_kill_internal.c} |  22 +--
 sysdeps/unix/sysv/linux/pwrite.c              |   2 +-
 sysdeps/unix/sysv/linux/pwrite64.c            |   2 +-
 sysdeps/unix/sysv/linux/pwritev.c             |   2 +-
 sysdeps/unix/sysv/linux/pwritev2.c            |   2 +-
 sysdeps/unix/sysv/linux/pwritev64.c           |   2 +-
 sysdeps/unix/sysv/linux/pwritev64v2.c         |   2 +-
 sysdeps/unix/sysv/linux/read.c                |   2 +-
 sysdeps/unix/sysv/linux/read_nocancel.c       |   1 -
 sysdeps/unix/sysv/linux/readv.c               |   2 +-
 sysdeps/unix/sysv/linux/recv.c                |   1 -
 sysdeps/unix/sysv/linux/recvfrom.c            |   1 -
 sysdeps/unix/sysv/linux/recvmmsg.c            |   1 -
 sysdeps/unix/sysv/linux/recvmsg.c             |   1 -
 .../unix/sysv/linux/riscv/syscall_cancel.S    |  68 +++++++++
 .../sysv/linux/s390/s390-32/syscall_cancel.S  |  83 +++++++++++
 .../sysv/linux/s390/s390-64/syscall_cancel.S  |  83 +++++++++++
 sysdeps/unix/sysv/linux/select.c              |   1 -
 sysdeps/unix/sysv/linux/send.c                |   1 -
 sysdeps/unix/sysv/linux/sendmmsg.c            |   1 -
 sysdeps/unix/sysv/linux/sendmsg.c             |   1 -
 sysdeps/unix/sysv/linux/sendto.c              |   1 -
 sysdeps/unix/sysv/linux/sh/syscall_cancel.S   | 128 +++++++++++++++++
 sysdeps/unix/sysv/linux/sigsuspend.c          |   2 +-
 sysdeps/unix/sysv/linux/sigtimedwait.c        |   1 -
 sysdeps/unix/sysv/linux/sigwait.c             |   1 -
 sysdeps/unix/sysv/linux/sigwaitinfo.c         |   1 -
 sysdeps/unix/sysv/linux/socketcall.h          |  42 ++++--
 .../sysv/linux/sparc/cancellation-sigmask.h   |  39 +++++
 .../sysv/linux/sparc/sparc32/syscall_cancel.S |  76 ++++++++++
 .../sysv/linux/sparc/sparc64/pause.c}         |  17 +--
 .../sysv/linux/sparc/sparc64/syscall_cancel.S |  77 ++++++++++
 sysdeps/unix/sysv/linux/splice.c              |   2 +-
 sysdeps/unix/sysv/linux/sync_file_range.c     |   2 +-
 sysdeps/unix/sysv/linux/syscall_cancel.c      |  64 +++++++++
 sysdeps/unix/sysv/linux/sysdep-cancel.h       |  67 ---------
 sysdeps/unix/sysv/linux/sysdep.h              |  20 +++
 sysdeps/unix/sysv/linux/tcdrain.c             |   1 -
 sysdeps/unix/sysv/linux/tee.c                 |   2 +-
 sysdeps/unix/sysv/linux/timer_routines.c      |   1 -
 sysdeps/unix/sysv/linux/vmsplice.c            |   2 +-
 sysdeps/unix/sysv/linux/wait.c                |   1 -
 sysdeps/unix/sysv/linux/waitid.c              |   1 -
 sysdeps/unix/sysv/linux/waitpid.c             |   1 -
 sysdeps/unix/sysv/linux/waitpid_nocancel.c    |   1 -
 sysdeps/unix/sysv/linux/write.c               |   2 +-
 sysdeps/unix/sysv/linux/write_nocancel.c      |   1 -
 sysdeps/unix/sysv/linux/writev.c              |   2 +-
 sysdeps/unix/sysv/linux/x86_64/cancellation.S | 104 --------------
 .../unix/sysv/linux/x86_64/syscall_cancel.S   |  61 ++++++++
 sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h   |  13 ++
 sysdeps/x86_64/nptl/tcb-offsets.sym           |   1 -
 166 files changed, 2560 insertions(+), 660 deletions(-)
 delete mode 100644 nptl/cancellation.c
 rename sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S => nptl/pthread_kill_internal.c (72%)
 create mode 100644 nptl/tst-cancel28.c
 delete mode 100644 sysdeps/generic/sysdep-cancel.h
 delete mode 100644 sysdeps/mach/hurd/sysdep-cancel.h
 create mode 100644 sysdeps/nptl/cancellation-pc-check.h
 rename sysdeps/{unix/sysv/linux/x86_64/librt-cancellation.S => nptl/cancellation-sigmask.h} (60%)
 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/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/cancellation-sigmask.h
 create mode 100644 sysdeps/unix/sysv/linux/ia64/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/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/nios2/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S
 rename sysdeps/unix/sysv/linux/{pthread_kill.c => pthread_kill_internal.c} (75%)
 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/cancellation-sigmask.h
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S
 rename sysdeps/{nptl/librt-cancellation.c => unix/sysv/linux/sparc/sparc64/pause.c} (63%)
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/syscall_cancel.S
 create mode 100644 sysdeps/unix/sysv/linux/syscall_cancel.c
 delete mode 100644 sysdeps/unix/sysv/linux/sysdep-cancel.h
 delete mode 100644 sysdeps/unix/sysv/linux/x86_64/cancellation.S
 create mode 100644 sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S

-- 
2.17.1

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

end of thread, other threads:[~2019-10-21 13:29 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-14 20:57 [PATCH v3 00/21] nptl: Fix Race conditions in pthread cancellation (BZ#12683) Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 01/21] nptl: Handle EPIPE on tst-cancel2 Adhemerval Zanella
2019-10-15  9:03   ` Florian Weimer
2019-10-14 20:57 ` [PATCH v3 03/21] nptl: x86_64: Fix Race conditions in pthread cancellation (BZ#12683) Adhemerval Zanella
2019-10-15 11:03   ` Florian Weimer
2019-10-16 21:22     ` Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 19/21] nptl: nios2: " Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 04/21] nptl: x32: " Adhemerval Zanella
2019-10-15 11:06   ` Florian Weimer
2019-10-14 20:57 ` [PATCH v3 20/21] nptl: csky: " Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 15/21] nptl: alpha: " Adhemerval Zanella
2019-10-17  3:01   ` Matt Turner
2019-10-14 20:57 ` [PATCH v3 12/21] nptl: sparc: " Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 11/21] nptl: microblaze: " Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 18/21] nptl: s390: " Adhemerval Zanella
2019-10-16 15:46   ` Stefan Liebler
2019-10-17 13:54     ` Adhemerval Zanella
2019-10-17 15:01       ` Stefan Liebler
2019-10-17 19:46         ` Adhemerval Zanella
2019-10-18 12:58           ` Stefan Liebler
2019-10-14 20:57 ` [PATCH v3 14/21] nptl: m68k: " Adhemerval Zanella
2019-10-14 21:13   ` Andreas Schwab
2019-10-14 20:57 ` [PATCH v3 17/21] nptl: riscv: " Adhemerval Zanella
2019-10-14 23:22   ` Andrew Waterman
2019-10-14 20:57 ` [PATCH v3 05/21] nptl: ia64: " Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 02/21] nptl: " Adhemerval Zanella
2019-10-15 10:56   ` Florian Weimer
2019-10-16 20:42     ` Adhemerval Zanella
2019-10-18 12:38   ` Internal SIGTIMER use (was: Re: [PATCH v3 02/21] nptl: Fix Race conditions in pthread cancellation (BZ#12683)) Florian Weimer
2019-10-21 13:29     ` Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 08/21] nptl: aarch64: Fix Race conditions in pthread cancellation (BZ#12683) Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 09/21] nptl: arm: " Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 06/21] nptl: mips: " Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 07/21] nptl: i386: " Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 16/21] nptl: sh: " Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 13/21] nptl: hppa: " Adhemerval Zanella
2019-10-14 20:57 ` [PATCH v3 10/21] nptl: powerpc: " Adhemerval Zanella
2019-10-14 20:58 ` [PATCH v3 21/21] Remove sysdep-cancel header Adhemerval Zanella

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).