This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v3 0/7] nptl: Fix Race conditions in pthread cancellation (BZ#12683)


Hi,

This is a respin of my previous patch to fix BZ#12683 and supersedes the previous
ones. I have incorporated Joseph suggestions to split even more the patch on more
logical changes. Currently they are: 

1. Use inline syscalls for non-cancellable versions: add inline syscalls
   for non-cancellable versions to remove the requirement of __syscall_nocancel:
   symbol names.
2. A Function declaration cleanup, which basically change all the modified files
   to use ANSI C declarations.
3. Fix testcases for new pthread cancellation mechanism, that adds pthread_testcancel
   checks for cancellable syscalls that may have side effects.
4. x86_64: remove assembly implementation, which removes some x86_64 specific pthread
   code implemented in assembly.
5. Rewrite cancellation macros, which adds a new macro SYSCALL_CANCEL to encapsulate
   the LIBC_CANCEL_ASYNC/LIBC_CANCEL_RESET calls for subsequent change in its semantics.
6. Fix Race conditions in pthread cancellation, which the bulk of change to fix the
   issue and the working changes for ppc64.
7. x86_64: Fix Race conditions in pthread, the required changes for x86_64.
8. ppc32: Fix Race conditions in pthread cancellation, the required changes for ppc32.

Patches 1 to 5 does not change GLIBC pthread cancellation mechanism neither its
semantics and they are independent. Patch 6 changes GLIBC build for all the arches, 
so I think even after review and approved I will need help from arch maintainers to 
make adjust for each architecture. Patch 7 and 8 shows the required work for both x86_64 
and ppc32, which may vary from arch to arch.

I will update wiki pages with current steps to adequate other arches
to this change.  I also updated my branch [1] with the patchset and I think it is a good 
start to use for additional arch adjustments.

[1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/bz12683


 ChangeLog                                          |  394 +++++++++
 nptl/Makefile                                      |   21 +-
 nptl/Versions                                      |    3 +
 nptl/cancellation.c                                |   99 ---
 nptl/descr.h                                       |   15 +-
 nptl/libc-cancellation.c                           |   60 +-
 nptl/lowlevellock.c                                |    2 +-
 nptl/nptl-init.c                                   |   64 +-
 nptl/pt-system.c                                   |    3 -
 nptl/pthreadP.h                                    |   71 +-
 nptl/pthread_cancel.c                              |   72 +-
 nptl/pthread_cond_timedwait.c                      |   37 +-
 nptl/pthread_cond_wait.c                           |   24 +-
 nptl/pthread_create.c                              |    6 +-
 nptl/pthread_exit.c                                |   12 +-
 nptl/pthread_join.c                                |   13 +-
 nptl/pthread_timedjoin.c                           |   14 +-
 nptl/sem_timedwait.c                               |   19 +-
 nptl/sem_wait.c                                    |   26 +-
 nptl/tst-cancel-wrappers.sh                        |   92 ---
 nptl/tst-cancel2.c                                 |    3 +
 nptl/tst-cancel20.c                                |    6 +-
 nptl/tst-cancel21.c                                |    5 +
 nptl/tst-cancel4.c                                 |   11 +-
 rt/Makefile                                        |    1 -
 sysdeps/generic/sysdep-cancel.h                    |    3 -
 sysdeps/nptl/Makefile                              |    3 +-
 sysdeps/nptl/aio_misc.h                            |   15 +-
 sysdeps/nptl/gai_misc.h                            |   15 +-
 sysdeps/nptl/librt-cancellation.c                  |   24 -
 sysdeps/nptl/lowlevellock.h                        |    2 +-
 sysdeps/posix/sigpause.c                           |   11 +-
 sysdeps/posix/waitid.c                             |   17 +-
 sysdeps/powerpc/nptl/pthreaddef.h                  |   15 +
 sysdeps/unix/sysdep.h                              |   59 ++
 sysdeps/unix/sysv/linux/accept4.c                  |   12 +-
 sysdeps/unix/sysv/linux/alpha/fdatasync.c          |   26 +-
 sysdeps/unix/sysv/linux/arm/pread.c                |   28 +-
 sysdeps/unix/sysv/linux/arm/pread64.c              |   31 +-
 sysdeps/unix/sysv/linux/arm/pwrite.c               |   28 +-
 sysdeps/unix/sysv/linux/arm/pwrite64.c             |   31 +-
 sysdeps/unix/sysv/linux/clock_nanosleep.c          |   17 +-
 sysdeps/unix/sysv/linux/epoll_pwait.c              |   14 +-
 sysdeps/unix/sysv/linux/fallocate.c                |   18 +-
 sysdeps/unix/sysv/linux/fallocate64.c              |   24 +-
 sysdeps/unix/sysv/linux/fcntl.c                    |   36 +-
 sysdeps/unix/sysv/linux/generic/open.c             |   27 +-
 sysdeps/unix/sysv/linux/generic/open64.c           |   13 +-
 sysdeps/unix/sysv/linux/generic/pause.c            |   32 +-
 sysdeps/unix/sysv/linux/generic/poll.c             |   11 +-
 sysdeps/unix/sysv/linux/generic/recv.c             |   18 +-
 sysdeps/unix/sysv/linux/generic/select.c           |   16 +-
 sysdeps/unix/sysv/linux/generic/send.c             |   15 +-
 .../unix/sysv/linux/generic/wordsize-32/pread.c    |   25 +-
 .../unix/sysv/linux/generic/wordsize-32/pread64.c  |   28 +-
 .../unix/sysv/linux/generic/wordsize-32/preadv.c   |   21 +-
 .../unix/sysv/linux/generic/wordsize-32/preadv64.c |   22 +-
 .../unix/sysv/linux/generic/wordsize-32/pwrite.c   |   27 +-
 .../unix/sysv/linux/generic/wordsize-32/pwrite64.c |   28 +-
 .../unix/sysv/linux/generic/wordsize-32/pwritev.c  |   23 +-
 .../sysv/linux/generic/wordsize-32/pwritev64.c     |   25 +-
 sysdeps/unix/sysv/linux/i386/fcntl.c               |   14 +-
 sysdeps/unix/sysv/linux/i386/pselect.c             |   18 +-
 sysdeps/unix/sysv/linux/lowlevellock-futex.h       |   45 ++
 .../unix/sysv/linux/mips/mips32/sync_file_range.c  |   21 +-
 .../unix/sysv/linux/mips/mips64/n32/fallocate.c    |   12 +-
 .../unix/sysv/linux/mips/mips64/n32/fallocate64.c  |   12 +-
 sysdeps/unix/sysv/linux/mips/pread.c               |   31 +-
 sysdeps/unix/sysv/linux/mips/pread64.c             |   35 +-
 sysdeps/unix/sysv/linux/mips/pwrite.c              |   29 +-
 sysdeps/unix/sysv/linux/mips/pwrite64.c            |   35 +-
 sysdeps/unix/sysv/linux/msgrcv.c                   |   20 +-
 sysdeps/unix/sysv/linux/msgsnd.c                   |   20 +-
 sysdeps/unix/sysv/linux/not-cancel.h               |   80 +-
 sysdeps/unix/sysv/linux/open64.c                   |   11 +-
 sysdeps/unix/sysv/linux/openat.c                   |   22 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c  |   26 +-
 .../unix/sysv/linux/powerpc/powerpc32/pread64.c    |   29 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c |   26 +-
 .../unix/sysv/linux/powerpc/powerpc32/pwrite64.c   |   29 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc32/socket.S |   65 +-
 .../sysv/linux/powerpc/powerpc32/sysdep-cancel.h   |  125 ++-
 sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h |    8 +
 sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c  |   14 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc64/pread.c  |   23 +-
 .../unix/sysv/linux/powerpc/powerpc64/pread64.c    |   23 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite.c |   23 +-
 .../unix/sysv/linux/powerpc/powerpc64/pwrite64.c   |   23 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S |   80 +-
 .../sysv/linux/powerpc/powerpc64/sync_file_range.c |   12 +-
 .../sysv/linux/powerpc/powerpc64/sysdep-cancel.h   |  130 +--
 sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h |    9 +
 sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S   |   56 ++
 sysdeps/unix/sysv/linux/powerpc/sysdep.c           |   11 +
 sysdeps/unix/sysv/linux/ppoll.c                    |   12 +-
 sysdeps/unix/sysv/linux/pread.c                    |   29 +-
 sysdeps/unix/sysv/linux/pread64.c                  |   32 +-
 sysdeps/unix/sysv/linux/preadv.c                   |   18 +-
 sysdeps/unix/sysv/linux/pselect.c                  |   17 +-
 sysdeps/unix/sysv/linux/pthread_kill.c             |    9 +-
 sysdeps/unix/sysv/linux/pwrite.c                   |   29 +-
 sysdeps/unix/sysv/linux/pwrite64.c                 |   33 +-
 sysdeps/unix/sysv/linux/pwritev.c                  |   18 +-
 sysdeps/unix/sysv/linux/readv.c                    |   20 +-
 sysdeps/unix/sysv/linux/recvmmsg.c                 |   11 +-
 sysdeps/unix/sysv/linux/sendmmsg.c                 |   11 +-
 sysdeps/unix/sysv/linux/sh/pread.c                 |   25 +-
 sysdeps/unix/sysv/linux/sh/pread64.c               |   28 +-
 sysdeps/unix/sysv/linux/sh/pwrite.c                |   25 +-
 sysdeps/unix/sysv/linux/sh/pwrite64.c              |   29 +-
 sysdeps/unix/sysv/linux/sigsuspend.c               |   30 +-
 sysdeps/unix/sysv/linux/sigtimedwait.c             |   31 +-
 sysdeps/unix/sysv/linux/sigwait.c                  |   40 +-
 sysdeps/unix/sysv/linux/sigwaitinfo.c              |   28 +-
 sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c     |   22 +-
 sysdeps/unix/sysv/linux/sync_file_range.c          |   39 +-
 sysdeps/unix/sysv/linux/tcdrain.c                  |   12 +-
 sysdeps/unix/sysv/linux/timer_routines.c           |    9 +-
 sysdeps/unix/sysv/linux/wait.c                     |   11 +-
 sysdeps/unix/sysv/linux/waitid.c                   |   13 +-
 sysdeps/unix/sysv/linux/waitpid.c                  |   19 +-
 sysdeps/unix/sysv/linux/wordsize-64/fallocate.c    |   12 +-
 sysdeps/unix/sysv/linux/wordsize-64/preadv.c       |   11 +-
 sysdeps/unix/sysv/linux/wordsize-64/pwritev.c      |   11 +-
 sysdeps/unix/sysv/linux/writev.c                   |   20 +-
 sysdeps/unix/sysv/linux/x86_64/cancellation.S      |  117 ---
 sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S |   21 -
 .../unix/sysv/linux/x86_64/librt-cancellation.S    |   21 -
 sysdeps/unix/sysv/linux/x86_64/lowlevellock.h      |   41 +-
 .../sysv/linux/x86_64/pthread_cond_timedwait.S     |  840 --------------------
 sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S |  555 -------------
 sysdeps/unix/sysv/linux/x86_64/recv.c              |   11 +-
 sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S     |  380 ---------
 sysdeps/unix/sysv/linux/x86_64/sem_wait.S          |  176 ----
 sysdeps/unix/sysv/linux/x86_64/send.c              |   12 +-
 sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S    |   49 ++
 sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h     |   63 +-
 sysdeps/unix/sysv/linux/x86_64/sysdep.h            |    9 +
 sysdeps/x86_64/nptl/pthreaddef.h                   |   13 +
 sysdeps/x86_64/nptl/tcb-offsets.sym                |    1 -
 sysdeps/x86_64/nptl/tls.h                          |   11 -
 141 files changed, 1400 insertions(+), 4524 deletions(-)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]