From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by sourceware.org (Postfix) with ESMTPS id 57BB33858C41 for ; Fri, 19 May 2023 19:51:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 57BB33858C41 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-19a0f5db948so2744214fac.2 for ; Fri, 19 May 2023 12:51:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684525864; x=1687117864; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=2bZIWUyt4blYxqEI55c0mdiiJEsN61QsZC03TE1ZnWw=; b=VHWHEps2/vNRvQDsg/D4v0MWCLDIuI/cqw+LO4WLzRrmSJ/8xlCGLa7ctXZ7rZmL0W F6eB+B7aJSLnhibYXWGW+j0qJSW5cO2Yq26W6NLnrIlXOwD7b68MyjBQeOxW6hWJ0b2j OwebLGLbcX5g82Tqrol1o6mWpHTgfbRDIKvlxjxiJVYEF1Pr0Zgzna1XDxdMAJpBPegU Tng790aMR5XUPAN9UfgfNnR5axq4lRPwjoRqm83+pw3Gr/dwcQY+sLSWRQ2C+SZB+tGf Fgn+RSx/lc8IHrQttUrkIG/8q42m0B4yppZtcbnb590s+ylejpRpx3OesAjTa+yqP71/ FBCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684525864; x=1687117864; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2bZIWUyt4blYxqEI55c0mdiiJEsN61QsZC03TE1ZnWw=; b=XZoglzoqABhk9F5/bMGPkr8xgF/3cTipqGVTdCMPXSLoGjv6KgvFsVOhR1i3gX2okb NoVCyOQQcobojntTu5l68Z3dVTFGMcBCa3E8Axvr0g9AdgwIKnsiI+TCbPZUAWRmFNt3 NmpPfih+7K2MA4tJY0qa5cCk9uDzF9MowODyvzpWGLi6our3do72/o2knmh1iP/fsxK/ b6KuLYZkFQvnjzI82uRRQ7vCgCeLvkzG3Uxx/1KYicBdxG0LP+gpcEGQaTdt0YFOl2MC SrmfjXY7xrH9SBeR+K4IYNTlqv58Xz5lLXeyKbJZrgrlS72K6652syAWOJd1LxOQcrvN whrg== X-Gm-Message-State: AC+VfDx0X48lpofEQycJXALgwMgU+GOKuS8vR0hcmN+L/FHLz5G5nZbj cJ3JG3l9D4CZsc92hfAsxocuWnONk1V2mOm8SU0Avw== X-Google-Smtp-Source: ACHHUZ5hM9U2smd+aZlZ5/FIt4iOhhqymEopoWvhHg/BKTNB48rcsjWV/FqrGf6tgA5u5il+8+qbBg== X-Received: by 2002:a05:6870:4416:b0:187:c066:a39a with SMTP id u22-20020a056870441600b00187c066a39amr1495452oah.16.1684525864033; Fri, 19 May 2023 12:51:04 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:c914:8468:ca43:ec02:aa8d]) by smtp.gmail.com with ESMTPSA id l14-20020a056871068e00b0017f84f81f3csm2312321oao.52.2023.05.19.12.51.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 12:51:03 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v6 0/1] Fix Race conditions in pthread cancellation Date: Fri, 19 May 2023 16:50:58 -0300 Message-Id: <20230519195059.2802116-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 -- 2.34.1