Message ID | 20200403203201.7494-1-adhemerval.zanella@linaro.org |
---|---|
Headers |
Return-Path: <adhemerval.zanella@linaro.org> X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by sourceware.org (Postfix) with ESMTPS id D32E4385DC04 for <libc-alpha@sourceware.org>; Fri, 3 Apr 2020 20:32:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D32E4385DC04 Received: by mail-qk1-x743.google.com with SMTP id j4so9471113qkc.11 for <libc-alpha@sourceware.org>; Fri, 03 Apr 2020 13:32:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=pqM/Ely11eSAWsnVUN+urg7ZICA51zSwPRuNzA5Yt80=; b=Y4ZgWQXY6hDoia2JDgG57O7xQjDvnUZynfwf2WBjin483Xqdtjcsubw7Q1YULZ9c3y 1tAQmDKB23xFQB2BCXhBS44R4tfIsbgcHdTyQf0VinkwDywjK0h7ANCTDlq2h4WZhJpd s+GpcfZw6pJxJ7pPzY8345B58S6YaI+F4fvk/ETQYToR6gC2DD+z0eKaX+0vy5nPnLP9 yUu0kfCJjy0TjGawmc6XMjEsLhF5l4ukMfQbnMO1coLAVW50FlsjQ2iwrYFLGzDonmSi EEOVI+smpNrZhCjsWn4tnlmjj8GVaEWKAJHa6UtiSM0JRKLZ2o7DnaAck3r/GORrs3E3 xnNw== X-Gm-Message-State: AGi0PuZdnm0Y24DS/qF0dKL3EfzhAZFQwkadwUWM/SknScbHdI0lhvmS MzfeaFhlN81nzaa1tYwflBFetEq2Vuk= X-Google-Smtp-Source: APiQypIj1/+bkZY8j2iNmg0psbeaio7aTmIUGu8w11mz7mr5VK/Ko+PTGuBQDfTMhs3lzVsph0pnfw== X-Received: by 2002:a37:bd45:: with SMTP id n66mr10941754qkf.73.1585945927647; Fri, 03 Apr 2020 13:32:07 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id d141sm7063535qke.68.2020.04.03.13.32.06 for <libc-alpha@sourceware.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 13:32:07 -0700 (PDT) From: Adhemerval Zanella <adhemerval.zanella@linaro.org> To: libc-alpha@sourceware.org Subject: [PATCH v4 00/21] nptl: Fix Race conditions in pthread cancellation [BZ#12683] Date: Fri, 3 Apr 2020 17:31:40 -0300 Message-Id: <20200403203201.7494-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-18.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <http://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <http://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> X-List-Received-Date: Fri, 03 Apr 2020 20:32:11 -0000 |
Series |
nptl: Fix Race conditions in pthread cancellation [BZ#12683]
|
|
Message
Adhemerval Zanella Netto
April 3, 2020, 8:31 p.m. UTC
This is an updated version of my previous version [1] to fix BZ#12683 and it is based on cancel type and state refactor [2] [3] (still pending review). The changes from previous version are: - Use CANCELED_BITMASK on syscall_cancel.S instead of hardcoded value and remove the archors type. - Reorganized the __do_cancel macro and its usage on various pthread functions (and once pthread_exit is moved to libc.so it can be replaced by __pthread_exit call). - Reword x32 fix to use the its expected kernel ABI. Below there are the system where I could 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/pipermail/libc-alpha/2019-October/107284.html [2] https://sourceware.org/pipermail/libc-alpha/2020-April/112416.html [3] https://sourceware.org/pipermail/libc-alpha/2020-April/112417.html Adhemerval Zanella (21): nptl: Do not close the pipe on tst-cancel{2,3} 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: i386: 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: 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] Linux: 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 - io/creat.c | 1 - io/ppoll.c | 2 - malloc/malloc.c | 3 - manual/llio.texi | 4 +- nptl/Makefile | 10 +- nptl/Versions | 4 + nptl/cancellation.c | 78 ---------- nptl/descr.h | 3 - nptl/libc-cancellation.c | 44 +++++- nptl/nptl-init.c | 92 ++++++------ nptl/pthreadP.h | 58 ++++++-- nptl/pthread_cancel.c | 66 ++------- nptl/pthread_create.c | 7 +- nptl/pthread_exit.c | 9 +- nptl/pthread_join_common.c | 7 +- nptl/pthread_kill.c | 7 +- .../pthread_kill_internal.c | 21 +-- nptl/pthread_setcanceltype.c | 2 +- nptl/pthread_testcancel.c | 12 +- nptl/sem_wait.c | 2 +- nptl/tst-cancel2.c | 3 - nptl/tst-cancel29.c | 100 +++++++++++++ nptl/tst-cancel3.c | 3 - posix/nanosleep.c | 1 - rt/Makefile | 2 +- sysdeps/aarch64/nptl/tcb-offsets.sym | 3 + sysdeps/alpha/nptl/tcb-offsets.sym | 3 + sysdeps/arm/nptl/tcb-offsets.sym | 3 + sysdeps/csky/nptl/tcb-offsets.sym | 3 + .../syscall_types.h} | 13 +- sysdeps/generic/sysdep-cancel.h | 7 - sysdeps/hppa/nptl/tcb-offsets.sym | 3 + sysdeps/i386/nptl/tcb-offsets.sym | 3 + sysdeps/ia64/nptl/tcb-offsets.sym | 3 + sysdeps/m68k/nptl/tcb-offsets.sym | 3 + sysdeps/microblaze/nptl/tcb-offsets.sym | 3 + sysdeps/mips/dl-trampoline.c | 1 - sysdeps/mips/nptl/tcb-offsets.sym | 3 + sysdeps/nios2/nptl/tcb-offsets.sym | 3 + sysdeps/nptl/Makefile | 3 +- sysdeps/nptl/cancellation-pc-check.h | 53 +++++++ sysdeps/nptl/cancellation-sigmask.h | 30 ++++ sysdeps/nptl/futex-internal.h | 19 +-- sysdeps/nptl/lowlevellock-futex.h | 42 ++++-- sysdeps/posix/open64.c | 1 - sysdeps/posix/pause.c | 1 - sysdeps/posix/sigpause.c | 1 - sysdeps/posix/sigwait.c | 1 - sysdeps/powerpc/nptl/tcb-offsets.sym | 3 + sysdeps/powerpc/powerpc32/sysdep.h | 3 + sysdeps/powerpc/powerpc64/sysdep.h | 19 +++ sysdeps/pthread/thrd_sleep.c | 1 - sysdeps/riscv/nptl/tcb-offsets.sym | 3 + sysdeps/riscv/nptl/tls.h | 2 + sysdeps/s390/nptl/tcb-offsets.sym | 3 + sysdeps/sh/nptl/tcb-offsets.sym | 3 + sysdeps/sh/sysdep.h | 1 + sysdeps/sparc/nptl/tcb-offsets.sym | 3 + sysdeps/unix/sysdep.h | 139 ++++++++++++++---- .../unix/sysv/linux/aarch64/syscall_cancel.S | 59 ++++++++ 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 | 81 ++++++++++ sysdeps/unix/sysv/linux/arm/syscall_cancel.S | 78 ++++++++++ sysdeps/unix/sysv/linux/clock_nanosleep.c | 1 - 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 | 115 +++++++++++++++ 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 +- .../unix/sysv/linux/generic/inotify_init.c | 5 +- sysdeps/unix/sysv/linux/getrandom.c | 1 - sysdeps/unix/sysv/linux/hppa/syscall_cancel.S | 83 +++++++++++ sysdeps/unix/sysv/linux/hppa/sysdep.h | 1 + sysdeps/unix/sysv/linux/i386/Makefile | 2 +- sysdeps/unix/sysv/linux/i386/syscall_cancel.S | 104 +++++++++++++ .../sysv/linux/ia64/cancellation-pc-check.h | 48 ++++++ .../sysv/linux/ia64/cancellation-sigmask.h | 33 +++++ sysdeps/unix/sysv/linux/ia64/syscall_cancel.S | 81 ++++++++++ sysdeps/unix/sysv/linux/m68k/syscall_cancel.S | 85 +++++++++++ sysdeps/unix/sysv/linux/microblaze/pselect.c | 1 - .../sysv/linux/microblaze/syscall_cancel.S | 61 ++++++++ sysdeps/unix/sysv/linux/microblaze/sysdep.h | 1 + .../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 | 130 ++++++++++++++++ sysdeps/unix/sysv/linux/mips/mips64/sysdep.h | 52 +++---- 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 +- .../unix/sysv/linux/nios2/syscall_cancel.S | 95 ++++++++++++ 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/poll.c | 1 - .../unix/sysv/linux/powerpc/syscall_cancel.S | 65 ++++++++ sysdeps/unix/sysv/linux/ppoll.c | 3 - sysdeps/unix/sysv/linux/pread.c | 2 +- sysdeps/unix/sysv/linux/pread64.c | 2 +- sysdeps/unix/sysv/linux/pread64_nocancel.c | 1 - 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 | 5 +- 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 | 67 +++++++++ .../sysv/linux/s390/s390-32/syscall_cancel.S | 63 ++++++++ .../sysv/linux/s390/s390-64/syscall_cancel.S | 62 ++++++++ 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 | 126 ++++++++++++++++ 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 | 71 +++++++++ sysdeps/unix/sysv/linux/sparc/sparc64/pause.c | 25 ++++ .../sysv/linux/sparc/sparc64/syscall_cancel.S | 74 ++++++++++ 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 | 9 ++ 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/wait4.c | 2 +- sysdeps/unix/sysv/linux/waitid.c | 1 - sysdeps/unix/sysv/linux/write.c | 2 +- sysdeps/unix/sysv/linux/write_nocancel.c | 1 - sysdeps/unix/sysv/linux/writev.c | 2 +- .../unix/sysv/linux/x86_64/syscall_cancel.S | 59 ++++++++ .../sysv/linux/x86_64/x32/syscall_types.h | 40 +++++ 180 files changed, 2661 insertions(+), 544 deletions(-) delete mode 100644 nptl/cancellation.c rename sysdeps/unix/sysv/linux/pthread_kill.c => nptl/pthread_kill_internal.c (75%) create mode 100644 nptl/tst-cancel29.c rename sysdeps/{nptl/librt-cancellation.c => generic/syscall_types.h} (70%) delete mode 100644 sysdeps/generic/sysdep-cancel.h create mode 100644 sysdeps/nptl/cancellation-pc-check.h create mode 100644 sysdeps/nptl/cancellation-sigmask.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/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/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/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/cancellation-sigmask.h create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/pause.c 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 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