From patchwork Mon Oct 14 20:56:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176336 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5011295ill; Mon, 14 Oct 2019 13:57:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6WfbM728U+AVU9kPPmxY+r149/bV56gAGcV4QQIJUrWK5boLS7qXxC83sKspmYctZ4Eox X-Received: by 2002:a17:906:85c5:: with SMTP id i5mr30349050ejy.222.1571086637303; Mon, 14 Oct 2019 13:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086637; cv=none; d=google.com; s=arc-20160816; b=TcXFGfB0KYl0fvpo+s+nCK0R1i5zxIp86tlVEs+JYKkY6EkczkmTx7B7jA5D2KotwC LPOWnDAWIphMNhibSrJrfGipv6W2T2hJwupT8UxBPYXuwvZm3id1uImTpr7M7ebSSxUg UGOOSMU/VzdrKv+eMN0q32jJOozii0Kj5FkharexHQ61f+jLbbBgtwdCEr39rPB8SBOM PZEAv7VSqa7eAzXP8opcj74+ZNS0KMMR0t04t4FtJ6lWg6C1QACBZq/1s87RKUyVp/pm OTp1BOjtjlsJWmwdi0IXCYrVXqHQWAsUQivuh8TUsdkPZwowVCiD1wK86XsXSG3pRWF9 MHqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=Ax/Zw6d3MiKurhrCmPvgYNHm4ADZWu4IQtvNVALAnh8=; b=F3wM6mocNv2kX5/AGwuQbeVPCxjgLMRjn7OB6EaPLeiUw/eBlRKlBHlOkvg63GC2cx StTN5u65xth81oeibSfuEAlUtc9EGwpLpkOyIWVzgIBUTaZPXJ/kVdcabMZnNgywaoHu c2ojtYd8Fhf+jZ+lBdnB173n8dqUmKHXkuyJEIdyB9lMGHOhgKPKW6OCvayTLJuPvtoE Kt5srsPrdvkPIVQ9ovMo7FHpysGbgIisqLgdTarmXTJbjCCz7Wo6QLTHlhEeFOkmubp8 d/CEa1g2zt51nCLmPtidlxq8q323Bqzu5DwNqT7j2iwNnBV//sEwfg1GzIgJg2UUMMeR Dipw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=H32HZ9A6; dkim=pass header.i=@linaro.org header.s=google header.b=rLLDYw64; spf=pass (google.com: domain of libc-alpha-return-105927-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105927-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id gg10si11490553ejb.206.2019.10.14.13.57.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:57:17 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105927-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=H32HZ9A6; dkim=pass header.i=@linaro.org header.s=google header.b=rLLDYw64; spf=pass (google.com: domain of libc-alpha-return-105927-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105927-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=t8kJuwhKf0vMWmAnvYLqDfsG+juzE7V uPqvRENI5FEvSiw1MrW3qYAAWGv5AI51bRjJ3tVGYkSclL75Zu4j1m7XrSPzZ3Qv kFq/2yMlg7Utd0SvN7AXEA46hiYKdizPJNohPMTJQrMECU4qIEOR856XoS3K52HA GFa4sR+QjJ+o= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=55gl1ec8/uQBuk6zcFuFjPodAyc=; b=H32HZ 9A6AevAdEHuspoaQS1qhdd/iD15f3mdeU9n5YJhK1t8YVxLyGX6HkPXkQyaQczmi J8754x2JTG1YQWpiyPUKKfvcpLbhxXwUkSohYOsurN47MSKNx9Ns13BJjZf3kP+1 I/KOlT1JvNHNROe0zSv14JLioaEI0BGYRJ4RCU= Received: (qmail 112321 invoked by alias); 14 Oct 2019 20:57:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 111992 invoked by uid 89); 14 Oct 2019 20:57:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=puts X-HELO: mail-qk1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=Ax/Zw6d3MiKurhrCmPvgYNHm4ADZWu4IQtvNVALAnh8=; b=rLLDYw64uakaSRt4TTNzlhuAj0sg+MLos1tuNTidx1LGoKAH0UpHNLkpRN2R+NJEIF hT9AsSqlgtnBtBiCDV/wWsO60mg3oxKIUX47u5xwFXzkhvimzJsWuAnv/SadZ291iXe2 5ldcjlVHonTRTzVLuAMQUXlDd3i7lNpYq6HYaYSvfjwqtcrR6lkY2llUev9/Wyd8fQaN esWqGBLaTL8RathR4pSTObThk5+KDQZdoS7zfXsrZDINxIqp5/7mCJ1wybCg0gmvyFLU NfMynrcsWYz0Kmf+D/W+QDvx9hFfyxTpJeQ50kx/Ui/d3sbQIyGwsEZJ9z1Xgi7+3NHD cZ1w== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 01/21] nptl: Handle EPIPE on tst-cancel2 Date: Mon, 14 Oct 2019 17:56:36 -0300 Message-Id: <20191014205656.29834-2-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> The SIGPIPE can be catched before SIGCANCEL, which makes write fail and the thread return an non expected result. Checked on x86_64-linux-gnu and powerpc64le-linux-gnu. --- nptl/tst-cancel2.c | 3 --- 1 file changed, 3 deletions(-) -- 2.17.1 diff --git a/nptl/tst-cancel2.c b/nptl/tst-cancel2.c index b22bd496a7..2df2c00578 100644 --- a/nptl/tst-cancel2.c +++ b/nptl/tst-cancel2.c @@ -73,9 +73,6 @@ do_test (void) return 1; } - /* This will cause the write in the child to return. */ - close (fd[0]); - if (pthread_join (th, &r) != 0) { puts ("join failed"); From patchwork Mon Oct 14 20:56:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176345 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5012573ill; Mon, 14 Oct 2019 13:59:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJXo7jfQGSmdMBXdFrK0+mLGlf1lAHE8KxY22I3EDFaLoMZMysW/QVr3PvU+Pjy/D6KBdu X-Received: by 2002:a17:906:cc87:: with SMTP id oq7mr31146495ejb.123.1571086740098; Mon, 14 Oct 2019 13:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086740; cv=none; d=google.com; s=arc-20160816; b=KOXOu+YLGspzrXwUXgvXD01nHGItl1DjLRnNTuuh9th3mZX5y8I3r4tGwtfZGBQ+7e 9y82NRz5rb1P0bYIxtS3Qc7NgKAqfYdUraE3D43WpsmxvNTrSUpiBhgldBCZPv7U+oZX 0UlefMvlGBDW/HuNpSlB3RP9ggEs7/UKy5gwrKRcuM8bO/D6I1r3YpUQquFV6RUjjROD Z99mLUP0ucKDxHkbYEoAozomaI+89BdsjVuQGgquqkH3/gJwjeNrju/adZWvk+ekeF5o mHXCdDmlI5v5uwb6ffpycqYxu3UQFDtFvh4D4MwGmegmJuBk9ZYLC3BYJtoSYDwjJ7IT Suzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=8XxJCwuGfLAkhcxF1CF6tQZMsiAe2VsM3z8qpNj8Oj4=; b=kbEINceuekAzYAbQjz13Z2J7oqb9BtF6lVoeHwRUCoZy9EDzqqmfzsUTcmBYhYIite aMf4ulKY9QSXeWQKmNkQFFVszgKhCQcFBkTgDPKwoouIeaMxhdJXgwpUZ7NaSXOkWS98 nUg4oMYIQDMuKJS5ObDMQtcoi6LRAA+eV6SmomXWOd6mCiH9SrrLSuEj9wH7RZ63Q8tx 6LVY1W4Tkc/5pYYHWAs8bs8twNaM65edmcNXe4YpwRhzr7uA2CuJDGOwX/Gu3XkGmgvQ OebnzxKDNt9pioS9aJO2GrGdE//s7GKsXPN0yNLG+5WskRtI3BbEWHcBY0x857Xl1ekh oquw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=mtSEnQdU; dkim=pass header.i=@linaro.org header.s=google header.b=jPrK8CeI; spf=pass (google.com: domain of libc-alpha-return-105936-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105936-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y49si14331191edb.138.2019.10.14.13.58.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:59:00 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105936-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=mtSEnQdU; dkim=pass header.i=@linaro.org header.s=google header.b=jPrK8CeI; spf=pass (google.com: domain of libc-alpha-return-105936-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105936-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=MFPCdfvlnuHGLEmj/g7g1vpKCIxMFMl Hh6co5cuzRW6pu9Q2Xw1bGiay6IGDvJ7M+RE8eZ84/jNqa4DzPuoNdLBqsiPZ+R/ nST5l66tjsxPv8I9UaZSx2hLkVwoLRZY3GyITN/m7sR91hKOmJfLGw0RM55HzSvU 3YJ8gpk0fib4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=ACs2Jr41yRk39wv0I627ajlrGYI=; b=mtSEn QdURs8QOtKDdwxwAKFFMHlcxwR8DEl2Ks0WV4nDDKCCxT/TpLHrDA9dMtFVHpzxq u/J1Xv48sYFQKHJe2WBbG4+PGrJDb8pZk+IpsZe3X2De9O+g8qntwMK5UYlstWUs Lvi44pwgY4CRrO+PosvPykRj4Xqz+qUOMLqzbc= Received: (qmail 115133 invoked by alias); 14 Oct 2019 20:57:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 114778 invoked by uid 89); 14 Oct 2019 20:57:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=1718, 1611, 1101, locked X-HELO: mail-qt1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=8XxJCwuGfLAkhcxF1CF6tQZMsiAe2VsM3z8qpNj8Oj4=; b=jPrK8CeI77yhr4pt03I1YsWfu5B8appOF2DON4RI7PZ+iz4xWY13o2JuiyzmPaWqke S2l+Tkm7vHXjIKLxNxGJbH1zbDJOD9rURZyRhHY/OeiVUmp0z5/QMZocdjf0lBhhiXRD z7CTPyo+WyTkKGK23DaR+MXWHP9oQU5yEAKYixrh5KDaSq8tDsBs5lh6oj4bGwc2x1KQ ksxmAaRobf7pcPohcoM1JCMCoS1GG66Ha6NSouzjG3NAZg/S1f5rW9aYmJLhJ4+9AhhM TPBdvkiPOCYxAu4FpReB2cLMPTG02JWXp9XuMu0OxNotk6i6/2kNB+H2KnetA2zl2EWo rpNA== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 02/21] nptl: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:37 -0300 Message-Id: <20191014205656.29834-3-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch is the initial fix for race conditions in NPTL cancellation codei by redefining how cancellable syscalls are defined and handled. Current buggy approach is to enable asynchronous cancellation prior to making the syscall and restore the previous cancellation type once the syscall returns. As decribed in BZ#12683, this approach shows 2 important problems: 1. Cancellation can act after the syscall has returned from kernel, but before userspace saves the return value. It might result in a resource leak if the syscall allocated a resource or a side effect (partial read/write), and there is no way to program handle it with cancellation handlers. 2. If a signal is handled while the thread is blocked at a cancellable syscall, the entire signal handler runs with asynchronous cancellation enabled. This can lead to issues if the signal handler call functions which are async-signal-safe but not async-cancel-safe. For cancellation to work correctly, there are 5 points at which the cancellation signal could arrive: 1. Before the final "testcancel" and before the syscall is made. 2. Between the "testcancel" and the syscall. 3. While the syscall is blocked and no side effects have yet taken place. 4. While the syscall is blocked but with some side effects already having taken place (e.g. a partial read or write). 5. After the syscall has returned. And GLIBC wants to act on cancellation in cases 1, 2, and 3 but not in case 4 or 5. The proposed solution follows: * Handling case 1 is trivial: do a conditional branch based on whether the thread has received a cancellation request; * Case 2 can be caught by the signal handler determining that the saved program counter (from the ucontext_t) is in some address range beginning just before the "testcancel" and ending with the syscall instruction. * In this case, except for certain syscalls that ALWAYS fail with EINTR even for non-interrupting signals, the kernel will reset the program counter to point at the syscall instruction during signal handling, so that the syscall is restarted when the signal handler returns. So, from the signal handler's standpoint, this looks the same as case 2, and thus it's taken care of. * In this case, the kernel cannot restart the syscall; when it's interrupted by a signal, the kernel must cause the syscall to return with whatever partial result it obtained (e.g. partial read or write). * In this case, the saved program counter points just after the syscall instruction, so the signal handler won't act on cancellation. This one is equal to 4. since the program counter is past the syscall instruction already. Another case that needs handling is syscalls that fail with EINTR even when the signal handler is non-interrupting. In this case, the syscall wrapper code can just check the cancellation flag when the errno result is EINTR, and act on cancellation if it's set. The proposed GLIBC adjustments are: 1. Remove the enable_asynccancel/disable_asynccancel function usage in syscall definition and instead make them call a common symbol that will check if cancellation is enabled (__syscall_cancel at nptl/libc-cancellation.c), call the arch-specific cancellable entry-point (__syscall_cancel_arch) and cancel the thread when required. 2. Provide a arch-specific symbol that contains global markers. These markers will be used in SIGCANCEL handler to check if the interruption has been called in a valid syscall and if the syscalls has been completed or not. A reference implementation sysdeps/unix/sysv/linux/syscall_cancel.c is provided. However the markers may not be set on correct expected places depeding of how INTERNAL_SYSCALL_NCS is implemented by the underlying architecture, and it is uses compiler-speficic construct (asm volatile) to place the required markers. It is expected that all architectures implement an arch-specific. 3. Rewrite SIGCANCEL asynchronous handler to check for both cancelling type and if current IP from signal handler falls between the global markes and act accordingly (sigcancel_handler at nptl/nptl-init.c). 4. Adjust nptl/pthread_cancel.c to send an signal instead of acting directly. This avoid synchronization issues when updating the cancellation status and also focus the logic on signal handler and cancellation syscall code. 5. Adjust pthread code to replace CANCEL_ASYNC/CANCEL_RESET calls to appropriated cancelable futex syscalls. 6. Adjust libc code to replace LIBC_CANCEL_ASYNC/LIBC_CANCEL_RESET to appropriated cancelable syscalls. 7. Adjust 'lowlevellock-futex.h' arch-specific implementations to provide cancelable futex calls (used in libpthread code). This patch adds the proposed changes to NPTL common code and following patches add the requires arch-specific bits. The build for ia64-linux-gnu, mips-*, and x86_64-* are broken without the arch-specific patches. --- manual/llio.texi | 4 +- nptl/Makefile | 12 +- nptl/Versions | 3 + nptl/cancellation.c | 101 --------------- nptl/descr.h | 15 +-- nptl/libc-cancellation.c | 45 ++++++- nptl/nptl-init.c | 88 +++++++------- nptl/pthreadP.h | 39 +++++- 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 | 16 +-- nptl/pthread_setcanceltype.c | 2 +- nptl/thrd_sleep.c | 7 +- nptl/tst-cancel28.c | 100 +++++++++++++++ rt/Makefile | 2 +- sysdeps/generic/sysdep-cancel.h | 2 - sysdeps/htl/pthreadP.h | 1 + sysdeps/nptl/Makefile | 3 +- sysdeps/nptl/cancellation-pc-check.h | 40 ++++++ sysdeps/nptl/cancellation-sigmask.h | 30 +++++ sysdeps/unix/sysdep.h | 115 ++++++++++++++---- sysdeps/unix/sysv/linux/clock_nanosleep.c | 6 +- sysdeps/unix/sysv/linux/futex-internal.h | 18 +-- sysdeps/unix/sysv/linux/lowlevellock-futex.h | 45 +++++-- ...pthread_kill.c => pthread_kill_internal.c} | 22 +--- sysdeps/unix/sysv/linux/socketcall.h | 40 ++++-- sysdeps/unix/sysv/linux/syscall_cancel.c | 62 ++++++++++ sysdeps/unix/sysv/linux/sysdep.h | 20 +++ 31 files changed, 587 insertions(+), 341 deletions(-) delete mode 100644 nptl/cancellation.c rename sysdeps/nptl/librt-cancellation.c => nptl/pthread_kill_internal.c (70%) create mode 100644 nptl/tst-cancel28.c create mode 100644 sysdeps/nptl/cancellation-pc-check.h create mode 100644 sysdeps/nptl/cancellation-sigmask.h rename sysdeps/unix/sysv/linux/{pthread_kill.c => pthread_kill_internal.c} (75%) create mode 100644 sysdeps/unix/sysv/linux/syscall_cancel.c -- 2.17.1 diff --git a/manual/llio.texi b/manual/llio.texi index 447126b7eb..ecf175341d 100644 --- a/manual/llio.texi +++ b/manual/llio.texi @@ -2534,13 +2534,13 @@ aiocb64}, since the LFS transparently replaces the old interface. @c sigemptyset ok @c sigaddset ok @c setjmp ok -@c CANCEL_ASYNC -> pthread_enable_asynccancel ok +@c __pthread_setcanceltype ok @c do_cancel ok @c pthread_unwind ok @c Unwind_ForcedUnwind or longjmp ok [@ascuheap @acsmem?] @c lll_lock @asulock @aculock @c lll_unlock @asulock @aculock -@c CANCEL_RESET -> pthread_disable_asynccancel ok +@c __pthread_setcanceltype ok @c lll_futex_wait ok @c ->start_routine ok ----- @c call_tls_dtors @asulock @ascuheap @aculock @acsmem diff --git a/nptl/Makefile b/nptl/Makefile index 1129fd4516..02dd05f1aa 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -34,7 +34,8 @@ routines = alloca_cutoff forward libc-lowlevellock libc-cancellation \ pthread_attr_destroy pthread_attr_init pthread_attr_getdetachstate \ pthread_attr_setdetachstate pthread_attr_getinheritsched \ pthread_attr_setinheritsched pthread_attr_getschedparam \ - pthread_attr_setschedparam + pthread_attr_setschedparam \ + syscall_cancel shared-only-routines = forward static-only-routines = pthread_atfork @@ -103,7 +104,8 @@ libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \ pthread_barrierattr_setpshared \ pthread_key_create pthread_key_delete \ pthread_getspecific pthread_setspecific \ - pthread_sigmask pthread_kill pthread_sigqueue \ + pthread_sigmask pthread_kill pthread_kill_internal \ + pthread_sigqueue \ pthread_cancel pthread_testcancel \ pthread_setcancelstate pthread_setcanceltype \ pthread_once \ @@ -117,7 +119,6 @@ libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \ cleanup cleanup_defer cleanup_compat \ cleanup_defer_compat unwind \ pt-longjmp pt-cleanup\ - cancellation \ lowlevellock \ lll_timedlock_wait \ pt-fork pt-fcntl \ @@ -171,8 +172,7 @@ CFLAGS-pthread_setcanceltype.c += -fexceptions -fasynchronous-unwind-tables # These are internal functions which similar functionality as setcancelstate # and setcanceltype. -CFLAGS-cancellation.c += -fasynchronous-unwind-tables -CFLAGS-libc-cancellation.c += -fasynchronous-unwind-tables +CFLAGS-libc-cancellation.c += -fexceptions -fasynchronous-unwind-tables # Calling pthread_exit() must cause the registered cancel handlers to # be executed. Therefore exceptions have to be thrown through this @@ -286,7 +286,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \ tst-cancel11 tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 \ tst-cancel16 tst-cancel17 tst-cancel18 tst-cancel19 tst-cancel20 \ tst-cancel21 tst-cancel22 tst-cancel23 tst-cancel24 tst-cancel25 \ - tst-cancel26 tst-cancel27 \ + tst-cancel26 tst-cancel27 tst-cancel28 \ tst-cancel-self tst-cancel-self-cancelstate \ tst-cancel-self-canceltype tst-cancel-self-testcancel \ tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 tst-cleanup4 \ diff --git a/nptl/Versions b/nptl/Versions index be7e810875..afdb448ba9 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -39,6 +39,9 @@ libc { __libc_pthread_init; __libc_current_sigrtmin_private; __libc_current_sigrtmax_private; __libc_allocate_rtsig_private; + __syscall_cancel; + __syscall_cancel_arch_start; + __syscall_cancel_arch_end; } } diff --git a/nptl/cancellation.c b/nptl/cancellation.c deleted file mode 100644 index 7712845561..0000000000 --- a/nptl/cancellation.c +++ /dev/null @@ -1,101 +0,0 @@ -/* Copyright (C) 2002-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2002. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include "pthreadP.h" -#include - - -/* The next two functions are similar to pthread_setcanceltype() but - more specialized for the use in the cancelable functions like write(). - They do not need to check parameters etc. */ -int -attribute_hidden -__pthread_enable_asynccancel (void) -{ - struct pthread *self = THREAD_SELF; - int oldval = THREAD_GETMEM (self, cancelhandling); - - while (1) - { - int newval = oldval | CANCELTYPE_BITMASK; - - if (newval == oldval) - break; - - int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval, - oldval); - if (__glibc_likely (curval == oldval)) - { - if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval)) - { - THREAD_SETMEM (self, result, PTHREAD_CANCELED); - __do_cancel (); - } - - break; - } - - /* Prepare the next round. */ - oldval = curval; - } - - return oldval; -} - - -void -attribute_hidden -__pthread_disable_asynccancel (int oldtype) -{ - /* If asynchronous cancellation was enabled before we do not have - anything to do. */ - if (oldtype & CANCELTYPE_BITMASK) - return; - - struct pthread *self = THREAD_SELF; - int newval; - - int oldval = THREAD_GETMEM (self, cancelhandling); - - while (1) - { - newval = oldval & ~CANCELTYPE_BITMASK; - - int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval, - oldval); - if (__glibc_likely (curval == oldval)) - break; - - /* Prepare the next round. */ - oldval = curval; - } - - /* We cannot return when we are being canceled. Upon return the - thread might be things which would have to be undone. The - following loop should loop until the cancellation signal is - delivered. */ - while (__builtin_expect ((newval & (CANCELING_BITMASK | CANCELED_BITMASK)) - == CANCELING_BITMASK, 0)) - { - futex_wait_simple ((unsigned int *) &self->cancelhandling, newval, - FUTEX_PRIVATE); - newval = THREAD_GETMEM (self, cancelhandling); - } -} diff --git a/nptl/descr.h b/nptl/descr.h index d3f863aa18..a53f3326e6 100644 --- a/nptl/descr.h +++ b/nptl/descr.h @@ -275,23 +275,20 @@ struct pthread /* Bit set if asynchronous cancellation mode is selected. */ #define CANCELTYPE_BIT 1 #define CANCELTYPE_BITMASK (0x01 << CANCELTYPE_BIT) - /* Bit set if canceling has been initiated. */ -#define CANCELING_BIT 2 -#define CANCELING_BITMASK (0x01 << CANCELING_BIT) - /* Bit set if canceled. */ -#define CANCELED_BIT 3 + /* Bit set if thread is canceled. */ +#define CANCELED_BIT 2 #define CANCELED_BITMASK (0x01 << CANCELED_BIT) /* Bit set if thread is exiting. */ -#define EXITING_BIT 4 +#define EXITING_BIT 3 #define EXITING_BITMASK (0x01 << EXITING_BIT) /* Bit set if thread terminated and TCB is freed. */ -#define TERMINATED_BIT 5 +#define TERMINATED_BIT 4 #define TERMINATED_BITMASK (0x01 << TERMINATED_BIT) /* Bit set if thread is supposed to change XID. */ -#define SETXID_BIT 6 +#define SETXID_BIT 5 #define SETXID_BITMASK (0x01 << SETXID_BIT) /* Mask for the rest. Helps the compiler to optimize. */ -#define CANCEL_RESTMASK 0xffffff80 +#define CANCEL_RESTMASK 0xffffffc0 #define CANCEL_ENABLED_AND_CANCELED(value) \ (((value) & (CANCELSTATE_BITMASK | CANCELED_BITMASK | EXITING_BITMASK \ diff --git a/nptl/libc-cancellation.c b/nptl/libc-cancellation.c index 37654cfcfe..430e0b962e 100644 --- a/nptl/libc-cancellation.c +++ b/nptl/libc-cancellation.c @@ -18,7 +18,46 @@ #include "pthreadP.h" +/* Cancellation function called by all cancellable syscalls. */ +long int +__syscall_cancel (__syscall_arg_t nr, __syscall_arg_t a1, + __syscall_arg_t a2, __syscall_arg_t a3, + __syscall_arg_t a4, __syscall_arg_t a5, + __syscall_arg_t a6) +{ + pthread_t self = (pthread_t) THREAD_SELF; + struct pthread *pd = (struct pthread *) self; + long int result; -#define __pthread_enable_asynccancel __libc_enable_asynccancel -#define __pthread_disable_asynccancel __libc_disable_asynccancel -#include + /* If cancellation is not enabled, call the syscall directly. */ + if (pd->cancelhandling & CANCELSTATE_BITMASK) + { + INTERNAL_SYSCALL_DECL (err); + result = INTERNAL_SYSCALL_NCS_CALL (nr, err, a1, a2, a3, a4, a5, a6); + if (INTERNAL_SYSCALL_ERROR_P (result, err)) + return -INTERNAL_SYSCALL_ERRNO (result, err); + return result; + } + + /* Call the arch-specific entry points that contains the globals markers + to be checked by SIGCANCEL handler. */ + result = __syscall_cancel_arch (&pd->cancelhandling, nr, a1, a2, a3, a4, a5, + a6); + + if ((result == -EINTR) + && (pd->cancelhandling & CANCELED_BITMASK) + && !(pd->cancelhandling & CANCELSTATE_BITMASK)) + __do_cancel (); + + return result; +} +libc_hidden_def (__syscall_cancel) + +/* Since __do_cancel is a always inline function, this creates a symbol the + arch-specific symbol can call to cancel the thread. */ +_Noreturn void +attribute_hidden +__syscall_do_cancel (void) +{ + __do_cancel (); +} diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index ea91b9e138..09bfe16d45 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -39,6 +39,9 @@ #include #include #include +#include +#include +#include #ifndef TLS_MULTIPLE_THREADS_IN_TCB /* Pointer to the corresponding variable in libc. */ @@ -155,35 +158,23 @@ sigcancel_handler (int sig, siginfo_t *si, void *ctx) struct pthread *self = THREAD_SELF; - int oldval = THREAD_GETMEM (self, cancelhandling); - while (1) - { - /* We are canceled now. When canceled by another thread this flag - is already set but if the signal is directly send (internally or - from another process) is has to be done here. */ - int newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK; - - if (oldval == newval || (oldval & EXITING_BITMASK) != 0) - /* Already canceled or exiting. */ - break; - - int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval, - oldval); - if (curval == oldval) - { - /* Set the return value. */ - THREAD_SETMEM (self, result, PTHREAD_CANCELED); - - /* Make sure asynchronous cancellation is still enabled. */ - if ((newval & CANCELTYPE_BITMASK) != 0) - /* Run the registered destructors and terminate the thread. */ - __do_cancel (); - - break; - } - - oldval = curval; - } + if (((self->cancelhandling & (CANCELSTATE_BITMASK)) != 0) + || ((self->cancelhandling & CANCELED_BITMASK) == 0)) + return; + + /* Add SIGCANCEL on ignored sigmask to avoid the handler to be called + again. */ + ucontext_add_cancel (ctx); + + /* Check if asynchronous cancellation mode is set or if interrupted + instruction pointer falls within the cancellable syscall bridge. For + interruptable syscalls that might generate external side-effects (partial + reads or writes, for instance), the kernel will set the IP to after + '__syscall_cancel_arch_end', thus disabling the cancellation and allowing + the process to handle such conditions. */ + if (self->cancelhandling & CANCELTYPE_BITMASK + || ucontext_check_pc_boundary (ctx)) + __do_cancel (); } #endif @@ -286,38 +277,49 @@ __pthread_initialize_minimal_internal (void) THREAD_SETMEM (pd, report_events, __nptl_initial_report_events); #if defined SIGCANCEL || defined SIGSETXID - struct sigaction sa; - __sigemptyset (&sa.sa_mask); # ifdef SIGCANCEL /* Install the cancellation signal handler. If for some reason we cannot install the handler we do not abort. Maybe we should, but it is only asynchronous cancellation which is affected. */ - sa.sa_sigaction = sigcancel_handler; - sa.sa_flags = SA_SIGINFO; - (void) __libc_sigaction (SIGCANCEL, &sa, NULL); + { + struct sigaction sa; + sa.sa_sigaction = sigcancel_handler; + /* The signal handle should be non-interruptible to avoid the risk of + spurious EINTR caused by SIGCANCEL sent to process or if pthread_cancel + is called while cancellation is disabled in the target thread. */ + sa.sa_flags = SA_SIGINFO | SA_RESTART; + sa.sa_mask = SIGALL_SET; + __libc_sigaction (SIGCANCEL, &sa, NULL); + } # endif # ifdef SIGSETXID - /* Install the handle to change the threads' uid/gid. */ - sa.sa_sigaction = sighandler_setxid; - sa.sa_flags = SA_SIGINFO | SA_RESTART; - (void) __libc_sigaction (SIGSETXID, &sa, NULL); + { + /* Install the handle to change the threads' uid/gid. */ + struct sigaction sa; + __sigemptyset (&sa.sa_mask); + sa.sa_sigaction = sighandler_setxid; + sa.sa_flags = SA_SIGINFO | SA_RESTART; + __libc_sigaction (SIGSETXID, &sa, NULL); + } # endif /* The parent process might have left the signals blocked. Just in case, unblock it. We reuse the signal mask in the sigaction structure. It is already cleared. */ + { + struct sigaction sa; + __sigemptyset (&sa.sa_mask); # ifdef SIGCANCEL - __sigaddset (&sa.sa_mask, SIGCANCEL); + __sigaddset (&sa.sa_mask, SIGCANCEL); # endif # ifdef SIGSETXID - __sigaddset (&sa.sa_mask, SIGSETXID); + __sigaddset (&sa.sa_mask, SIGSETXID); # endif - { INTERNAL_SYSCALL_DECL (err); - (void) INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_UNBLOCK, &sa.sa_mask, - NULL, _NSIG / 8); + INTERNAL_SYSCALL_CALL (rt_sigprocmask, err, SIG_UNBLOCK, &sa.sa_mask, + NULL, _NSIG / 8); } #endif diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 070b3afa8d..cafd14f5af 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -296,20 +296,46 @@ extern void __nptl_unwind_freeres (void) attribute_hidden; #endif -/* Called when a thread reacts on a cancellation request. */ static inline void __attribute ((noreturn, always_inline)) -__do_cancel (void) +__do_cancel_with_result (void *result) { struct pthread *self = THREAD_SELF; - /* Make sure we get no more cancellations. */ - THREAD_ATOMIC_BIT_SET (self, cancelhandling, EXITING_BIT); + /* Make sure we get no more cancellations by clearing the cancel + state. */ + int oldval = THREAD_GETMEM (self, cancelhandling); + while (1) + { + int newval = oldval | CANCELSTATE_BITMASK | EXITING_BITMASK; + if (oldval == newval) + break; + + oldval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval, + oldval); + } + + THREAD_SETMEM (self, result, result); __pthread_unwind ((__pthread_unwind_buf_t *) THREAD_GETMEM (self, cleanup_jmp_buf)); } +/* Called when a thread reacts on a cancellation request. */ +static inline void +__attribute ((noreturn, always_inline)) +__do_cancel (void) +{ + __do_cancel_with_result (PTHREAD_CANCELED); +} + +extern long int __syscall_cancel_arch (volatile int *, __syscall_arg_t nr, + __syscall_arg_t arg1, __syscall_arg_t arg2, __syscall_arg_t arg3, + __syscall_arg_t arg4, __syscall_arg_t arg5, __syscall_arg_t arg6); +libc_hidden_proto (__syscall_cancel_arch); + +extern _Noreturn void __syscall_do_cancel (void) + attribute_hidden; /* Internal prototypes. */ @@ -469,11 +495,11 @@ extern int __pthread_equal (pthread_t thread1, pthread_t thread2); extern int __pthread_detach (pthread_t th); extern int __pthread_cancel (pthread_t th); extern int __pthread_kill (pthread_t threadid, int signo); +extern int __pthread_kill_internal (pthread_t threadid, int signo) + attribute_hidden; extern void __pthread_exit (void *value) __attribute__ ((__noreturn__)); extern int __pthread_join (pthread_t threadid, void **thread_return); extern int __pthread_setcanceltype (int type, int *oldtype); -extern int __pthread_enable_asynccancel (void) attribute_hidden; -extern void __pthread_disable_asynccancel (int oldtype) attribute_hidden; extern void __pthread_testcancel (void); extern int __pthread_timedjoin_ex (pthread_t, void **, const struct timespec *, bool); @@ -496,6 +522,7 @@ hidden_proto (__pthread_testcancel) hidden_proto (__pthread_mutexattr_init) hidden_proto (__pthread_mutexattr_settype) hidden_proto (__pthread_timedjoin_ex) +hidden_proto (__pthread_kill_internal) #endif extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond); diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c index 64ac12e60a..b20254bdba 100644 --- a/nptl/pthread_cancel.c +++ b/nptl/pthread_cancel.c @@ -37,67 +37,24 @@ __pthread_cancel (pthread_t th) #ifdef SHARED pthread_cancel_init (); #endif - int result = 0; - int oldval; - int newval; - do - { - again: - oldval = pd->cancelhandling; - newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK; - /* Avoid doing unnecessary work. The atomic operation can - potentially be expensive if the bug has to be locked and - remote cache lines have to be invalidated. */ - if (oldval == newval) - break; + THREAD_ATOMIC_BIT_SET (pd, cancelhandling, CANCELED_BIT); - /* If the cancellation is handled asynchronously just send a - signal. We avoid this if possible since it's more - expensive. */ - if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval)) - { - /* Mark the cancellation as "in progress". */ - if (atomic_compare_and_exchange_bool_acq (&pd->cancelhandling, - oldval | CANCELING_BITMASK, - oldval)) - goto again; - -#ifdef SIGCANCEL - /* The cancellation handler will take care of marking the - thread as canceled. */ - pid_t pid = __getpid (); - - INTERNAL_SYSCALL_DECL (err); - int val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, pd->tid, - SIGCANCEL); - if (INTERNAL_SYSCALL_ERROR_P (val, err)) - result = INTERNAL_SYSCALL_ERRNO (val, err); -#else - /* It should be impossible to get here at all, since - pthread_setcanceltype should never have allowed - PTHREAD_CANCEL_ASYNCHRONOUS to be set. */ - abort (); -#endif - - break; - } - - /* A single-threaded process should be able to kill itself, since - there is nothing in the POSIX specification that says that it - cannot. So we set multiple_threads to true so that cancellation - points get executed. */ - THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1); + /* A single-threaded process should be able to kill itself, since there is + nothing in the POSIX specification that says that it cannot. So we set + multiple_threads to true so that cancellation points get executed. */ + THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1); #ifndef TLS_MULTIPLE_THREADS_IN_TCB - __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1; + __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1; #endif - } - /* Mark the thread as canceled. This has to be done - atomically since other bits could be modified as well. */ - while (atomic_compare_and_exchange_bool_acq (&pd->cancelhandling, newval, - oldval)); - return result; + /* Avoid signaling when thread attempts cancel itself (pthread_kill + is expensive). */ + if (pd == THREAD_SELF + && (THREAD_GETMEM (pd, cancelhandling) & CANCELTYPE_BITMASK) == 0) + return 0; + + return __pthread_kill_internal (th, SIGCANCEL); } weak_alias (__pthread_cancel, pthread_cancel) diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 130937c3c4..8cab7f970c 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -406,7 +406,7 @@ START_THREAD_DEFN /* If the parent was running cancellation handlers while creating the thread the new thread inherited the signal mask. Reset the cancellation signal mask. */ - if (__glibc_unlikely (pd->parent_cancelhandling & CANCELING_BITMASK)) + if (__glibc_unlikely (pd->parent_cancelhandling & CANCELED_BITMASK)) { INTERNAL_SYSCALL_DECL (err); sigset_t mask; @@ -449,7 +449,8 @@ START_THREAD_DEFN have ownership (see CONCURRENCY NOTES above). */ if (__glibc_unlikely (pd->stopped_start)) { - int oldtype = CANCEL_ASYNC (); + int ct; + __pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &ct); /* Get the lock the parent locked to force synchronization. */ lll_lock (pd->lock, LLL_PRIVATE); @@ -459,7 +460,7 @@ START_THREAD_DEFN /* And give it up right away. */ lll_unlock (pd->lock, LLL_PRIVATE); - CANCEL_RESET (oldtype); + __pthread_setcanceltype (ct, NULL); } LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg); diff --git a/nptl/pthread_exit.c b/nptl/pthread_exit.c index 643c85bd6e..6c59cdf652 100644 --- a/nptl/pthread_exit.c +++ b/nptl/pthread_exit.c @@ -16,16 +16,13 @@ License along with the GNU C Library; if not, see . */ -#include #include "pthreadP.h" void __pthread_exit (void *value) { - THREAD_SETMEM (THREAD_SELF, result, value); - - __do_cancel (); + __do_cancel_with_result (value); } weak_alias (__pthread_exit, pthread_exit) diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c index 9545ae4bd3..43cdb2c7bc 100644 --- a/nptl/pthread_join_common.c +++ b/nptl/pthread_join_common.c @@ -100,7 +100,7 @@ __pthread_timedjoin_ex (pthread_t threadid, void **thread_return, if ((pd == self || (self->joinid == pd && (pd->cancelhandling - & (CANCELING_BITMASK | CANCELED_BITMASK | EXITING_BITMASK + & (CANCELED_BITMASK | EXITING_BITMASK | TERMINATED_BITMASK)) == 0)) && !CANCEL_ENABLED_AND_CANCELED (self->cancelhandling)) /* This is a deadlock situation. The threads are waiting for each diff --git a/nptl/pthread_kill.c b/nptl/pthread_kill.c index 2805c722a6..4c2672ae84 100644 --- a/nptl/pthread_kill.c +++ b/nptl/pthread_kill.c @@ -31,8 +31,9 @@ __pthread_kill (pthread_t threadid, int signo) /* Not a valid thread handle. */ return ESRCH; - return ENOSYS; + if (__is_internal_signal (signo)) + return EINVAL; + + return __pthread_kill_internal (threadid, signo); } strong_alias (__pthread_kill, pthread_kill) - -stub_warning (pthread_kill) diff --git a/sysdeps/nptl/librt-cancellation.c b/nptl/pthread_kill_internal.c similarity index 70% rename from sysdeps/nptl/librt-cancellation.c rename to nptl/pthread_kill_internal.c index 93ebe4aa71..b4f4f6dc78 100644 --- a/sysdeps/nptl/librt-cancellation.c +++ b/nptl/pthread_kill_internal.c @@ -1,6 +1,6 @@ -/* Copyright (C) 2002-2019 Free Software Foundation, Inc. +/* Send a signal to a specific pthread. Internal version. + Copyright (C) 2002-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2002. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -16,9 +16,11 @@ License along with the GNU C Library; if not, see . */ -#include +#include - -#define __pthread_enable_asynccancel __librt_enable_asynccancel -#define __pthread_disable_asynccancel __librt_disable_asynccancel -#include +int +__pthread_kill_internal (pthread_t threadid, int signo) +{ + return ENOSYS; +} +hidden_def (__pthread_kill_internal) diff --git a/nptl/pthread_setcanceltype.c b/nptl/pthread_setcanceltype.c index d771c31e46..84cc657aed 100644 --- a/nptl/pthread_setcanceltype.c +++ b/nptl/pthread_setcanceltype.c @@ -73,4 +73,4 @@ __pthread_setcanceltype (int type, int *oldtype) return 0; } -strong_alias (__pthread_setcanceltype, pthread_setcanceltype) +weak_alias (__pthread_setcanceltype, pthread_setcanceltype) diff --git a/nptl/thrd_sleep.c b/nptl/thrd_sleep.c index 2e185dd748..75c0d53f3e 100644 --- a/nptl/thrd_sleep.c +++ b/nptl/thrd_sleep.c @@ -24,13 +24,12 @@ int thrd_sleep (const struct timespec* time_point, struct timespec* remaining) { - INTERNAL_SYSCALL_DECL (err); - int ret = INTERNAL_SYSCALL_CANCEL (nanosleep, err, time_point, remaining); - if (INTERNAL_SYSCALL_ERROR_P (ret, err)) + long int ret = INTERNAL_SYSCALL_CANCEL (nanosleep, time_point, remaining); + if (SYSCALL_CANCEL_ERROR (ret)) { /* C11 states thrd_sleep function returns -1 if it has been interrupted by a signal, or a negative value if it fails. */ - ret = INTERNAL_SYSCALL_ERRNO (ret, err); + ret = -ret; if (ret == EINTR) return -1; return -2; diff --git a/nptl/tst-cancel28.c b/nptl/tst-cancel28.c new file mode 100644 index 0000000000..e27f5a0776 --- /dev/null +++ b/nptl/tst-cancel28.c @@ -0,0 +1,100 @@ +/* Check side-effect act for cancellable syscalls (BZ #12683). + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* This testcase checks if there is resource leakage if the syscall has + returned from kernelspace, but before userspace saves the return + value. The 'leaker' thread should be able to close the file descriptor + if the resource is already allocated, meaning that if the cancellation + signal arrives *after* the open syscal return from kernel, the + side-effect should be visible to application. */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +static void * +writeopener (void *arg) +{ + int fd; + for (;;) + { + fd = open (arg, O_WRONLY); + close (fd); + } + return NULL; +} + +static void * +leaker (void *arg) +{ + int fd = open (arg, O_RDONLY); + TEST_VERIFY_EXIT (fd > 0); + pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, 0); + close (fd); + return NULL; +} + + +#define ITER_COUNT 1000 +#define MAX_FILENO 1024 + +static int +do_test (void) +{ + char *dir = support_create_temp_directory ("tst-cancel28"); + char *name = xasprintf ("%s/fifo", dir); + TEST_COMPARE (mkfifo (name, 0600), 0); + add_temp_file (name); + + struct support_descriptors *descrs = support_descriptors_list (); + + srand (1); + + xpthread_create (NULL, writeopener, name); + for (int i = 0; i < ITER_COUNT; i++) + { + pthread_t td = xpthread_create (NULL, leaker, name); + struct timespec ts = + { .tv_nsec = rand () % 100000, .tv_sec = 0 }; + nanosleep (&ts, NULL); + /* Ignore pthread_cancel result because it might be the + case when pthread_cancel is called when thread is already + exited. */ + pthread_cancel (td); + xpthread_join (td); + } + + support_descriptors_check (descrs); + + support_descriptors_free (descrs); + + free (name); + + return 0; +} + +#define TIMEOUT 10 +#include diff --git a/rt/Makefile b/rt/Makefile index 6c8365e0c0..a7a9ec4cfc 100644 --- a/rt/Makefile +++ b/rt/Makefile @@ -56,7 +56,7 @@ include ../Rules CFLAGS-aio_suspend.c += -fexceptions CFLAGS-mq_timedreceive.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-mq_timedsend.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-librt-cancellation.c += -fasynchronous-unwind-tables +CFLAGS-clock_nanosleep.c += -fexceptions -fasynchronous-unwind-tables LDFLAGS-rt.so = -Wl,--enable-new-dtags,-z,nodelete diff --git a/sysdeps/generic/sysdep-cancel.h b/sysdeps/generic/sysdep-cancel.h index d22a786536..5c84b4499a 100644 --- a/sysdeps/generic/sysdep-cancel.h +++ b/sysdeps/generic/sysdep-cancel.h @@ -3,5 +3,3 @@ /* No multi-thread handling enabled. */ #define SINGLE_THREAD_P (1) #define RTLD_SINGLE_THREAD_P (1) -#define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */ -#define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */ diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h index e745dacac1..5628791de8 100644 --- a/sysdeps/htl/pthreadP.h +++ b/sysdeps/htl/pthreadP.h @@ -25,6 +25,7 @@ extern pthread_t __pthread_self (void); extern int __pthread_kill (pthread_t threadid, int signo); +extern int __pthread_kill_internal (pthread_t threadid, int signo); extern struct __pthread **__pthread_threads; extern int _pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr); diff --git a/sysdeps/nptl/Makefile b/sysdeps/nptl/Makefile index fbb9800a5c..19293a7b3e 100644 --- a/sysdeps/nptl/Makefile +++ b/sysdeps/nptl/Makefile @@ -21,8 +21,7 @@ libpthread-sysdep_routines += errno-loc endif ifeq ($(subdir),rt) -librt-sysdep_routines += timer_routines librt-cancellation -CFLAGS-librt-cancellation.c += -fexceptions -fasynchronous-unwind-tables +librt-sysdep_routines += timer_routines tests += tst-mqueue8x CFLAGS-tst-mqueue8x.c += -fexceptions diff --git a/sysdeps/nptl/cancellation-pc-check.h b/sysdeps/nptl/cancellation-pc-check.h new file mode 100644 index 0000000000..8b26c4ec4e --- /dev/null +++ b/sysdeps/nptl/cancellation-pc-check.h @@ -0,0 +1,40 @@ +/* Architecture specific code for pthread cancellation handling. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _NPTL_CANCELLATION_PC_CHECK +#define _NPTL_CANCELLATION_PC_CHECK + +#include + +/* Check if the program counter (PC) from ucontext CTX is within the start and + then end boundary from the __syscall_cancel_arch bridge. Return TRUE if + the PC is within the boundary, meaning the syscall does not have any side + effects; or FALSE otherwise. */ +static bool +ucontext_check_pc_boundary (void *ctx) +{ + /* Both are defined in syscall_cancel.S. */ + extern const char __syscall_cancel_arch_start[1]; + extern const char __syscall_cancel_arch_end[1]; + + uintptr_t pc = sigcontext_get_pc (ctx); + return pc >= (uintptr_t) __syscall_cancel_arch_start + && pc < (uintptr_t) __syscall_cancel_arch_end; +} + +#endif diff --git a/sysdeps/nptl/cancellation-sigmask.h b/sysdeps/nptl/cancellation-sigmask.h new file mode 100644 index 0000000000..77702c135e --- /dev/null +++ b/sysdeps/nptl/cancellation-sigmask.h @@ -0,0 +1,30 @@ +/* Architecture specific code for pthread cancellation handling. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _NPTL_CANCELLATION_SIGMASK_H +#define _NPTL_CANCELLATION_SIGMASK_H + +/* Add the SIGCANCEL signal on sigmask set at the ucontext CTX obtained from + the sigaction handler. */ +static void +ucontext_add_cancel (void *ctx) +{ + __sigaddset (&((ucontext_t*) ctx)->uc_sigmask, SIGCANCEL); +} + +#endif diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h index 10468c7129..04f30b8cbc 100644 --- a/sysdeps/unix/sysdep.h +++ b/sysdeps/unix/sysdep.h @@ -24,6 +24,9 @@ #define SYSCALL__(name, args) PSEUDO (__##name, name, args) #define SYSCALL(name, args) PSEUDO (name, name, args) +#ifndef __ASSEMBLER__ +# include + #define __SYSCALL_CONCAT_X(a,b) a##b #define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X (a, b) @@ -57,6 +60,29 @@ #define INTERNAL_SYSCALL_CALL(...) \ __INTERNAL_SYSCALL_DISP (__INTERNAL_SYSCALL, __VA_ARGS__) +#define __INTERNAL_SYSCALL_NCS0(name, err) \ + INTERNAL_SYSCALL_NCS (name, err, 0) +#define __INTERNAL_SYSCALL_NCS1(name, err, a1) \ + INTERNAL_SYSCALL_NCS (name, err, 1, a1) +#define __INTERNAL_SYSCALL_NCS2(name, err, a1, a2) \ + INTERNAL_SYSCALL_NCS (name, err, 2, a1, a2) +#define __INTERNAL_SYSCALL_NCS3(name, err, a1, a2, a3) \ + INTERNAL_SYSCALL_NCS (name, err, 3, a1, a2, a3) +#define __INTERNAL_SYSCALL_NCS4(name, err, a1, a2, a3, a4) \ + INTERNAL_SYSCALL_NCS (name, err, 4, a1, a2, a3, a4) +#define __INTERNAL_SYSCALL_NCS5(name, err, a1, a2, a3, a4, a5) \ + INTERNAL_SYSCALL_NCS (name, err, 5, a1, a2, a3, a4, a5) +#define __INTERNAL_SYSCALL_NCS6(name, err, a1, a2, a3, a4, a5, a6) \ + INTERNAL_SYSCALL_NCS (name, err, 6, a1, a2, a3, a4, a5, a6) +#define __INTERNAL_SYSCALL_NCS7(name, err, a1, a2, a3, a4, a5, a6, a7) \ + INTERNAL_SYSCALL_NCS (name, err, 7, a1, a2, a3, a4, a5, a6, a7) + +/* Issue a syscall defined by syscall number plus any other argument required. + It is similar to INTERNAL_SYSCALL_NCS macro, but without the need to pass + the expected argument number as third parameter. */ +#define INTERNAL_SYSCALL_NCS_CALL(...) \ + __INTERNAL_SYSCALL_DISP (__INTERNAL_SYSCALL_NCS, __VA_ARGS__) + #define __INLINE_SYSCALL0(name) \ INLINE_SYSCALL (name, 0) #define __INLINE_SYSCALL1(name, a1) \ @@ -88,35 +114,70 @@ #define INLINE_SYSCALL_CALL(...) \ __INLINE_SYSCALL_DISP (__INLINE_SYSCALL, __VA_ARGS__) -#define SYSCALL_CANCEL(...) \ - ({ \ - long int sc_ret; \ - if (SINGLE_THREAD_P) \ - sc_ret = INLINE_SYSCALL_CALL (__VA_ARGS__); \ - else \ - { \ - int sc_cancel_oldtype = LIBC_CANCEL_ASYNC (); \ - sc_ret = INLINE_SYSCALL_CALL (__VA_ARGS__); \ - LIBC_CANCEL_RESET (sc_cancel_oldtype); \ - } \ - sc_ret; \ - }) -/* Issue a syscall defined by syscall number plus any other argument - required. Any error will be returned unmodified (including errno). */ -#define INTERNAL_SYSCALL_CANCEL(...) \ - ({ \ - long int sc_ret; \ - if (SINGLE_THREAD_P) \ - sc_ret = INTERNAL_SYSCALL_CALL (__VA_ARGS__); \ - else \ - { \ - int sc_cancel_oldtype = LIBC_CANCEL_ASYNC (); \ - sc_ret = INTERNAL_SYSCALL_CALL (__VA_ARGS__); \ - LIBC_CANCEL_RESET (sc_cancel_oldtype); \ - } \ - sc_ret; \ +/* Cancellation macros. */ +#ifndef __SSC +typedef long int __syscall_arg_t; +# define __SSC(__x) ((__syscall_arg_t) (__x)) +#endif + +long int __syscall_cancel (__syscall_arg_t nr, __syscall_arg_t arg1, + __syscall_arg_t arg2, __syscall_arg_t arg3, + __syscall_arg_t arg4, __syscall_arg_t arg5, + __syscall_arg_t arg6); +libc_hidden_proto (__syscall_cancel); + +#define __SYSCALL_CANCEL0(name) \ + (__syscall_cancel)(__NR_##name, 0, 0, 0, 0, 0, 0) +#define __SYSCALL_CANCEL1(name, a1) \ + (__syscall_cancel)(__NR_##name, __SSC(a1), 0, 0, 0, 0, 0) +#define __SYSCALL_CANCEL2(name, a1, a2) \ + (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), 0, 0, 0, 0) +#define __SYSCALL_CANCEL3(name, a1, a2, a3) \ + (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), __SSC(a3), 0, 0, 0) +#define __SYSCALL_CANCEL4(name, a1, a2, a3, a4) \ + (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), __SSC(a3), \ + __SSC(a4), 0, 0) +#define __SYSCALL_CANCEL5(name, a1, a2, a3, a4, a5) \ + (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), __SSC(a3), \ + __SSC(a4), __SSC(a5), 0) +#define __SYSCALL_CANCEL6(name, a1, a2, a3, a4, a5, a6) \ + (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), __SSC(a3), \ + __SSC(a4), __SSC(a5), __SSC(a6)) + +#define __SYSCALL_CANCEL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n +#define __SYSCALL_CANCEL_NARGS(...) \ + __SYSCALL_CANCEL_NARGS_X (__VA_ARGS__,7,6,5,4,3,2,1,0,) +#define __SYSCALL_CANCEL_CONCAT_X(a,b) a##b +#define __SYSCALL_CANCEL_CONCAT(a,b) __SYSCALL_CANCEL_CONCAT_X (a, b) +#define __SYSCALL_CANCEL_DISP(b,...) \ + __SYSCALL_CANCEL_CONCAT (b,__SYSCALL_CANCEL_NARGS(__VA_ARGS__))(__VA_ARGS__) + +#define __SYSCALL_CANCEL_CALL(...) \ + __SYSCALL_CANCEL_DISP (__SYSCALL_CANCEL, __VA_ARGS__) + +/* Issue a cancellable syscall defined by syscall number NAME plus any other + argument required. If an error occurs its value is returned as an negative + number unmodified and errno is not set. */ +#define INTERNAL_SYSCALL_CANCEL(name, args...) \ + __SYSCALL_CANCEL_CALL (name, args) + +/* Issue a cancellable syscall defined first argument plus any other argument + required. If and error occurs its value, the macro returns -1 and sets + errno accordingly. */ +#if IS_IN (rtld) +/* The loader does not need to handle thread cancellation, use direct + syscall instead. */ +# define SYSCALL_CANCEL(...) INLINE_SYSCALL_CALL (__VA_ARGS__) +#else +# define SYSCALL_CANCEL(...) \ + ({ \ + long int sc_ret = __SYSCALL_CANCEL_CALL (__VA_ARGS__); \ + SYSCALL_CANCEL_RET ((sc_ret)); \ }) +#endif + +#endif /* __ASSEMBLER__ */ /* Machine-dependent sysdep.h files are expected to define the macro PSEUDO (function_name, syscall_name) to emit assembly code to define the diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index 1f240b8720..ddcdddcd5d 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -36,11 +36,9 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, /* If the call is interrupted by a signal handler or encounters an error, it returns a positive value similar to errno. */ - INTERNAL_SYSCALL_DECL (err); - int r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, err, clock_id, flags, + int r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, clock_id, flags, req, rem); - return (INTERNAL_SYSCALL_ERROR_P (r, err) - ? INTERNAL_SYSCALL_ERRNO (r, err) : 0); + return SYSCALL_CANCEL_ERROR (r) ? -r : 0; } versioned_symbol (libc, __clock_nanosleep, clock_nanosleep, GLIBC_2_17); diff --git a/sysdeps/unix/sysv/linux/futex-internal.h b/sysdeps/unix/sysv/linux/futex-internal.h index 5a4f4ff818..b41a4d9919 100644 --- a/sysdeps/unix/sysv/linux/futex-internal.h +++ b/sysdeps/unix/sysv/linux/futex-internal.h @@ -75,10 +75,7 @@ static __always_inline int futex_wait_cancelable (unsigned int *futex_word, unsigned int expected, int private) { - int oldtype; - oldtype = __pthread_enable_asynccancel (); - int err = lll_futex_timed_wait (futex_word, expected, NULL, private); - __pthread_disable_asynccancel (oldtype); + int err = lll_futex_timed_wait_cancel (futex_word, expected, NULL, private); switch (err) { case 0: @@ -129,10 +126,7 @@ futex_reltimed_wait_cancelable (unsigned int *futex_word, unsigned int expected, const struct timespec *reltime, int private) { - int oldtype; - oldtype = LIBC_CANCEL_ASYNC (); - int err = lll_futex_timed_wait (futex_word, expected, reltime, private); - LIBC_CANCEL_RESET (oldtype); + int err = lll_futex_timed_wait_cancel (futex_word, expected, reltime, private); switch (err) { case 0: @@ -203,12 +197,8 @@ futex_abstimed_wait_cancelable (unsigned int *futex_word, despite them being valid. */ if (__glibc_unlikely ((abstime != NULL) && (abstime->tv_sec < 0))) return ETIMEDOUT; - int oldtype; - oldtype = __pthread_enable_asynccancel (); - int err = lll_futex_clock_wait_bitset (futex_word, expected, - clockid, abstime, - private); - __pthread_disable_asynccancel (oldtype); + int err = lll_futex_clock_wait_bitset_cancel (futex_word, expected, clockid, + abstime, private); switch (err) { case 0: diff --git a/sysdeps/unix/sysv/linux/lowlevellock-futex.h b/sysdeps/unix/sysv/linux/lowlevellock-futex.h index b423673ed4..bd6d3b7cf7 100644 --- a/sysdeps/unix/sysv/linux/lowlevellock-futex.h +++ b/sysdeps/unix/sysv/linux/lowlevellock-futex.h @@ -74,6 +74,12 @@ ? -INTERNAL_SYSCALL_ERRNO (__ret, __err) : 0); \ }) +#define lll_futex_syscall_cp(...) \ + ({ \ + long int __ret = INTERNAL_SYSCALL_CANCEL (futex, __VA_ARGS__); \ + __ret; \ + }) + #define lll_futex_wait(futexp, val, private) \ lll_futex_timed_wait (futexp, val, NULL, private) @@ -148,19 +154,36 @@ /* Cancellable futex macros. */ #define lll_futex_wait_cancel(futexp, val, private) \ - ({ \ - int __oldtype = CANCEL_ASYNC (); \ - long int __err = lll_futex_wait (futexp, val, LLL_SHARED); \ - CANCEL_RESET (__oldtype); \ - __err; \ + lll_futex_timed_wait_cancel (futexp, val, NULL, private) + +#define lll_futex_timed_wait_cancel(futexp, val, timeout, private) \ + ({ \ + long int __ret; \ + int __op = FUTEX_WAIT; \ + __ret = lll_futex_syscall_cp (futexp, \ + __lll_private_flag (__op, private), \ + val, timeout); \ + __ret; \ }) -#define lll_futex_timed_wait_cancel(futexp, val, timeout, private) \ - ({ \ - int __oldtype = CANCEL_ASYNC (); \ - long int __err = lll_futex_timed_wait (futexp, val, timeout, private); \ - CANCEL_RESET (__oldtype); \ - __err; \ +#define lll_futex_clock_wait_bitset_cancel(futexp, val, clockid, \ + timeout, private) \ + ({ \ + long int __ret; \ + if (lll_futex_supported_clockid (clockid)) \ + { \ + const unsigned int clockbit = \ + (clockid == CLOCK_REALTIME) ? FUTEX_CLOCK_REALTIME : 0; \ + const int op = \ + __lll_private_flag (FUTEX_WAIT_BITSET | clockbit, private); \ + \ + __ret = lll_futex_syscall_cp (futexp, op, val, \ + timeout, NULL /* Unused. */, \ + FUTEX_BITSET_MATCH_ANY); \ + } \ + else \ + __ret = -EINVAL; \ + __ret; \ }) #endif /* !__ASSEMBLER__ */ diff --git a/sysdeps/unix/sysv/linux/pthread_kill.c b/sysdeps/unix/sysv/linux/pthread_kill_internal.c similarity index 75% rename from sysdeps/unix/sysv/linux/pthread_kill.c rename to sysdeps/unix/sysv/linux/pthread_kill_internal.c index 71305b90c6..31920deae4 100644 --- a/sysdeps/unix/sysv/linux/pthread_kill.c +++ b/sysdeps/unix/sysv/linux/pthread_kill_internal.c @@ -16,24 +16,15 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include -#include -#include #include +#include - +/* Used internally by pthread_cancel, so we can't filter SIGCANCEL. */ int -__pthread_kill (pthread_t threadid, int signo) +__pthread_kill_internal (pthread_t threadid, int signo) { struct pthread *pd = (struct pthread *) threadid; - /* Make sure the descriptor is valid. */ - if (DEBUGGING_P && INVALID_TD_P (pd)) - /* Not a valid thread handle. */ - return ESRCH; - /* Force load of pd->tid into local variable or register. Otherwise if a thread exits between ESRCH test and tgkill, we might return EINVAL, because pd->tid would be cleared by the kernel. */ @@ -42,11 +33,6 @@ __pthread_kill (pthread_t threadid, int signo) /* Not a valid thread handle. */ return ESRCH; - /* Disallow sending the signal we use for cancellation, timers, - for the setxid implementation. */ - if (signo == SIGCANCEL || signo == SIGTIMER || signo == SIGSETXID) - return EINVAL; - /* We have a special syscall to do the work. */ INTERNAL_SYSCALL_DECL (err); @@ -56,4 +42,4 @@ __pthread_kill (pthread_t threadid, int signo) return (INTERNAL_SYSCALL_ERROR_P (val, err) ? INTERNAL_SYSCALL_ERRNO (val, err) : 0); } -strong_alias (__pthread_kill, pthread_kill) +hidden_def (__pthread_kill_internal) diff --git a/sysdeps/unix/sysv/linux/socketcall.h b/sysdeps/unix/sysv/linux/socketcall.h index 1e6387cdbf..38af55feb4 100644 --- a/sysdeps/unix/sysv/linux/socketcall.h +++ b/sysdeps/unix/sysv/linux/socketcall.h @@ -87,18 +87,32 @@ }) -#if IS_IN (libc) -# define __pthread_enable_asynccancel __libc_enable_asynccancel -# define __pthread_disable_asynccancel __libc_disable_asynccancel -#endif - -#define SOCKETCALL_CANCEL(name, args...) \ - ({ \ - int oldtype = LIBC_CANCEL_ASYNC (); \ - long int sc_ret = __SOCKETCALL (SOCKOP_##name, args); \ - LIBC_CANCEL_RESET (oldtype); \ - sc_ret; \ - }) - +#define __SOCKETCALL_CANCEL1(__name, __a1) \ + SYSCALL_CANCEL (socketcall, __name, \ + ((long int [1]) { (long int) __a1 })) +#define __SOCKETCALL_CANCEL2(__name, __a1, __a2) \ + SYSCALL_CANCEL (socketcall, __name, \ + ((long int [2]) { (long int) __a1, (long int) __a2 })) +#define __SOCKETCALL_CANCEL3(__name, __a1, __a2, __a3) \ + SYSCALL_CANCEL (socketcall, __name, \ + ((long int [3]) { (long int) __a1, (long int) __a2, (long int) __a3 })) +#define __SOCKETCALL_CANCEL4(__name, __a1, __a2, __a3, __a4) \ + SYSCALL_CANCEL (socketcall, __name, \ + ((long int [4]) { (long int) __a1, (long int) __a2, (long int) __a3, \ + (long int) __a4 })) +#define __SOCKETCALL_CANCEL5(__name, __a1, __a2, __a3, __a4, __a5) \ + SYSCALL_CANCEL (socketcall, __name, \ + ((long int [5]) { (long int) __a1, (long int) __a2, (long int) __a3, \ + (long int) __a4, (long int) __a5 })) +#define __SOCKETCALL_CANCEL6(__name, __a1, __a2, __a3, __a4, __a5, __a6) \ + SYSCALL_CANCEL (socketcall, __name, \ + ((long int [6]) { (long int) __a1, (long int) __a2, (long int) __a3, \ + (long int) __a4, (long int) __a5, (long int) __a6 })) + +#define __SOCKETCALL_CANCEL(...) __SOCKETCALL_DISP (__SOCKETCALL_CANCEL,\ + __VA_ARGS__) + +#define SOCKETCALL_CANCEL(name, args...) \ + __SOCKETCALL_CANCEL (SOCKOP_##name, args) #endif /* sys/socketcall.h */ diff --git a/sysdeps/unix/sysv/linux/syscall_cancel.c b/sysdeps/unix/sysv/linux/syscall_cancel.c new file mode 100644 index 0000000000..79d66ec4f4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/syscall_cancel.c @@ -0,0 +1,62 @@ +/* Default cancellation syscall bridge. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +/* This is the generic version of the cancellable syscall code which + adds the label guards (__syscall_cancel_arch_{start,end}) used + on SIGCANCEL sigcancel_handler (nptl-init.c) to check if the cancelled + syscall have side-effects that need to be signaled to program. + + This implementation should be used a reference one to document the + implementation constraints: the __syscall_cancel_arch_end should point + to the immediate next instruction after the syscall one. This is because + kernel will signal interrupted syscall with side effects by setting + the signal frame program counter (on the ucontext_t third argument from + SA_SIGINFO signal handler) right after the syscall instruction. + + If the INTERNAL_SYSCALL_NCS macro use more instructions to get the + error condition from kernel (as for powerpc and sparc), uses an + out of the line helper (as for ARM thumb), or uses a kernel helper + gate (as for i686 or ia64) the architecture should adjust the + macro or provide a custom __syscall_cancel_arch implementation. */ +long int +__syscall_cancel_arch (volatile int *ch, __syscall_arg_t nr, + __syscall_arg_t a1, __syscall_arg_t a2, + __syscall_arg_t a3, __syscall_arg_t a4, + __syscall_arg_t a5, __syscall_arg_t a6) +{ +#define ADD_LABEL(__label) \ + asm volatile ( \ + ".global " __label "\t\n" \ + ".type " __label ",\%function\t\n" \ + __label ":\n"); + + ADD_LABEL ("__syscall_cancel_arch_start"); + if (__glibc_unlikely (*ch & CANCELED_BITMASK)) + __syscall_do_cancel(); + + INTERNAL_SYSCALL_DECL(err); + long int result = INTERNAL_SYSCALL_NCS (nr, err, 6, a1, a2, a3, a4, a5, a6); + ADD_LABEL ("__syscall_cancel_arch_end"); + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) + return -INTERNAL_SYSCALL_ERRNO (result, err); + return result; +} +libc_hidden_def (__syscall_cancel_arch) diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index fc9af51456..317bb7f973 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -27,6 +27,26 @@ -1l; \ }) +/* Check error from cancellable syscall and set errno accordingly. + Linux uses a negative return value to indicate syscall errors + and since version 2.1 the return value of a system call might be + negative even if the call succeeded (e.g., the `lseek' system call + might return a large offset). + Current contract is kernel make sure the no syscall returns a value + in -1 .. -4095 as a valid result so we can savely test with -4095. */ +#define SYSCALL_CANCEL_ERROR(__ret) \ + (__ret > -4096UL) + +#define SYSCALL_CANCEL_RET(__ret) \ + ({ \ + if (SYSCALL_CANCEL_ERROR(__ret)) \ + { \ + __set_errno (-__ret); \ + __ret = -1; \ + } \ + __ret; \ + }) + /* Provide a dummy argument that can be used to force register alignment for register pairs if required by the syscall ABI. */ #ifdef __ASSUME_ALIGNED_REGISTER_PAIRS From patchwork Mon Oct 14 20:56:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176338 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5011579ill; Mon, 14 Oct 2019 13:57:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqhhw99xfKrgO+12YL/C3DDeqJIl9OqGxsWl/Y7i2Cn6M5pcKTRxrsYSTQhSq2rbxGc9zG X-Received: by 2002:aa7:d898:: with SMTP id u24mr21340785edq.74.1571086658248; Mon, 14 Oct 2019 13:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086658; cv=none; d=google.com; s=arc-20160816; b=gWpr3UeOEH8b5wgGByyE9S7Ua6La0e1SZJPF4mVPtA4X1H3B8wp4BaHm1pV/+zZq2/ ndburUpXTepB52qFMfLQg31P+REhfz4GYynR14CvGV21aj9NJevAiPAbNHBDDkgvqI1I ZIqD0sJyheSHDy2Iukz9B/nupe/A8/hUR3mOYqLAybJt+JAWn14KGOYPr1XnOPy9w5Ra IHTowYKz1O9zuK612rbtAGiZv/+mBYOCmx/d3w49AMAITolccQ8tzeSrQY90RqlkbZCi 7JA4sIB6hB4gReXnpQ9hJG4LzSrEwIbix1W6BLjJmw4ojhLeEpkubknAbvbTcbA8nUJC pFuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=7ka8x6DhX7+RS753GO/8vR4A7KF1I8BxN39PU5tv66U=; b=tEky5qlVSDIpzfo8VGuVVcM6dVqJBooPEATlrnjVNTqzEoEbP+ROwkPOHyWqIiXlL2 Piyeze8YTYIChBRgOr7TezLgYIZPKA/m5Nvg4dLZvXmY7H+27uPeAI1jJwSeyDlOEjP1 wYkWwEoEdnRKZpGdWJqihPcs3+11OehDD/kyDIJx6+UrmaIRI3LRfl2z2jY4I/u2y6JM JJHRXIPjhHdQEKp+17XoTOJF04TLG4nnwdDWEzE2mZ9lstVAEe4nSnL9lR4CuTSHSIKY BBuiRmOJemIfQgHQjjN5vTkeym9bTIHhlUKqmQKlIAHJAuLMDYfMXe0z1F7QMFkhg2VM vM1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=fN022Sh0; dkim=pass header.i=@linaro.org header.s=google header.b=JlwCYYyL; spf=pass (google.com: domain of libc-alpha-return-105929-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105929-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v31si11541791edm.402.2019.10.14.13.57.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:57:38 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105929-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=fN022Sh0; dkim=pass header.i=@linaro.org header.s=google header.b=JlwCYYyL; spf=pass (google.com: domain of libc-alpha-return-105929-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105929-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=A4F7WlIdhFUXdVF+GA3cXeivrDyKshd +uZp4WXrLMJuJn5HOAik0k3BHm58YegciYIeT7MEEfa2ED9DLqtEx8ilD2TTfAgJ GH4Q0jbazqjL9zRBxZ4XPtnFrkxTBC6J+HgTYCSULRfGKwBUz9YiJq7wXopFNqk2 5t030iBYyRw4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=cQrjEjn9RCyZeIRNfubFVCtoadA=; b=fN022 Sh0moNgfo8mjWdQ4u0jcILSC1fH8UyUpjM369gMdk4hcwJcXDSc59gQGRU7mty2l lh003RDv7k3W398NxR+m6yse0pfQ0DMdlOQ92Q3epgPki4G3cK0e8QCbRVTQBsPs jgU1gTRdWrpZLYn09zM5nOPveHM/lPoHoflHLY= Received: (qmail 113673 invoked by alias); 14 Oct 2019 20:57:14 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 113572 invoked by uid 89); 14 Oct 2019 20:57:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=7ka8x6DhX7+RS753GO/8vR4A7KF1I8BxN39PU5tv66U=; b=JlwCYYyLvVLRY6bVXW9c/QMJI5T1w1nHf0w3j/hy8h99b7MBwUlBlYhMGpMbByGQWV YkC2iV3IZPFiloZ9WfWAa8GNEa1jAr0GWyOBaX3JNjf1xktfm++c5loLPXZd2aWMLSpC 0nLlA8jmcWMnGLY5IHgcFGsZbsejt0zXiFvJTLXqSOt7lVMtnso5lfNSvpRAxux+pulY wOYOC2kWPCa/Zjq/HMVW9ZdlOB7PFt8u0DrWCfsbCWF8dtUFuUn7cuqGz1x96woNnCcn u3cB5aeHAVzQIMUNjxvxXzOSpHwwUzL7EbVJ1ymP4vSrM/0aj1PtXYfnBIRzBpdvuWF5 ZM7w== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 03/21] nptl: x86_64: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:38 -0300 Message-Id: <20191014205656.29834-4-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patches adds the x86_64 modification required for the BZ#12683. The arch-specific {libc-,librt-}cancelation.S files are remove in favor of the default libc-cancellation implementation, the TCB_CANCELING_BITMASK is remove since it is now unused, and the arch-specific syscall_cancel is provided. Checked on x86_64-linux-gnu. --- sysdeps/unix/sysv/linux/x86_64/cancellation.S | 104 ------------------ .../sysv/linux/x86_64/libc-cancellation.S | 21 ---- .../sysv/linux/x86_64/librt-cancellation.S | 21 ---- .../unix/sysv/linux/x86_64/syscall_cancel.S | 61 ++++++++++ sysdeps/x86_64/nptl/tcb-offsets.sym | 1 - 5 files changed, 61 insertions(+), 147 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/x86_64/cancellation.S delete mode 100644 sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S delete mode 100644 sysdeps/unix/sysv/linux/x86_64/librt-cancellation.S create mode 100644 sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/sysdeps/unix/sysv/linux/x86_64/cancellation.S deleted file mode 100644 index f8a142da72..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/cancellation.S +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright (C) 2009-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2009. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include - -#define PTHREAD_UNWIND JUMPTARGET(__pthread_unwind) -#if IS_IN (libpthread) -# if defined SHARED && !defined NO_HIDDEN -# undef PTHREAD_UNWIND -# define PTHREAD_UNWIND __GI___pthread_unwind -# endif -#else -# ifndef SHARED - .weak __pthread_unwind -# endif -#endif - - -#define LOAD_PRIVATE_FUTEX_WAIT(reg) \ - movl $(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg - -/* It is crucial that the functions in this file don't modify registers - other than %rax and %r11. The syscall wrapper code depends on this - because it doesn't explicitly save the other registers which hold - relevant values. */ - .text - - .hidden __pthread_enable_asynccancel -ENTRY(__pthread_enable_asynccancel) - movl %fs:CANCELHANDLING, %eax -2: movl %eax, %r11d - orl $TCB_CANCELTYPE_BITMASK, %r11d - cmpl %eax, %r11d - je 1f - - lock - cmpxchgl %r11d, %fs:CANCELHANDLING - jnz 2b - - andl $(TCB_CANCELSTATE_BITMASK|TCB_CANCELTYPE_BITMASK|TCB_CANCELED_BITMASK|TCB_EXITING_BITMASK|TCB_CANCEL_RESTMASK|TCB_TERMINATED_BITMASK), %r11d - cmpl $(TCB_CANCELTYPE_BITMASK|TCB_CANCELED_BITMASK), %r11d - je 3f - -1: ret - -3: subq $8, %rsp - cfi_adjust_cfa_offset(8) - LP_OP(mov) $TCB_PTHREAD_CANCELED, %fs:RESULT - lock - orl $TCB_EXITING_BITMASK, %fs:CANCELHANDLING - mov %fs:CLEANUP_JMP_BUF, %RDI_LP - call PTHREAD_UNWIND - hlt -END(__pthread_enable_asynccancel) - - - .hidden __pthread_disable_asynccancel -ENTRY(__pthread_disable_asynccancel) - testl $TCB_CANCELTYPE_BITMASK, %edi - jnz 1f - - movl %fs:CANCELHANDLING, %eax -2: movl %eax, %r11d - andl $~TCB_CANCELTYPE_BITMASK, %r11d - lock - cmpxchgl %r11d, %fs:CANCELHANDLING - jnz 2b - - movl %r11d, %eax -3: andl $(TCB_CANCELING_BITMASK|TCB_CANCELED_BITMASK), %eax - cmpl $TCB_CANCELING_BITMASK, %eax - je 4f -1: ret - - /* Performance doesn't matter in this loop. We will - delay until the thread is canceled. And we will unlikely - enter the loop twice. */ -4: mov %fs:0, %RDI_LP - movl $__NR_futex, %eax - xorq %r10, %r10 - addq $CANCELHANDLING, %rdi - LOAD_PRIVATE_FUTEX_WAIT (%esi) - syscall - movl %fs:CANCELHANDLING, %eax - jmp 3b -END(__pthread_disable_asynccancel) diff --git a/sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S b/sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S deleted file mode 100644 index cf8da66eb7..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (C) 2009-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2009. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#define __pthread_enable_asynccancel __libc_enable_asynccancel -#define __pthread_disable_asynccancel __libc_disable_asynccancel -#include "cancellation.S" diff --git a/sysdeps/unix/sysv/linux/x86_64/librt-cancellation.S b/sysdeps/unix/sysv/linux/x86_64/librt-cancellation.S deleted file mode 100644 index e7dcc61f6e..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/librt-cancellation.S +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (C) 2009-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2009. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#define __pthread_enable_asynccancel __librt_enable_asynccancel -#define __pthread_disable_asynccancel __librt_disable_asynccancel -#include "cancellation.S" diff --git a/sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S b/sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S new file mode 100644 index 0000000000..c7364bfff8 --- /dev/null +++ b/sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S @@ -0,0 +1,61 @@ +/* Cancellable syscall wrapper - x86_64 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int [rax] __syscall_cancel_arch (volatile int *cancelhandling [%rdi], + __syscall_arg_t nr [%rsi], + __syscall_arg_t arg1 [%rdx], + __syscall_arg_t arg2 [%rcx], + __syscall_arg_t arg3 [%r8], + __syscall_arg_t arg4 [%r9], + __syscall_arg_t arg5 [SP+8], + __syscall_arg_t arg6 [SP+16]) */ + +ENTRY (__syscall_cancel_arch) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + mov (%rdi),%eax + testb $4, (%rdi) + jne __syscall_do_cancel + + /* Issue a 6 argument syscall, the nr [%rax] being the syscall + number. */ + mov %rdi,%r11 + mov %rsi,%rax + mov %rdx,%rdi + mov %rcx,%rsi + mov %r8,%rdx + mov %r9,%r10 + mov 8(%rsp),%r8 + mov 16(%rsp),%r9 + mov %r11,8(%rsp) + syscall + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + ret + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) diff --git a/sysdeps/x86_64/nptl/tcb-offsets.sym b/sysdeps/x86_64/nptl/tcb-offsets.sym index ae8034743b..5d033d1ac0 100644 --- a/sysdeps/x86_64/nptl/tcb-offsets.sym +++ b/sysdeps/x86_64/nptl/tcb-offsets.sym @@ -18,7 +18,6 @@ SSP_BASE_OFFSET offsetof (tcbhead_t, ssp_base) -- Not strictly offsets, but these values are also used in the TCB. TCB_CANCELSTATE_BITMASK CANCELSTATE_BITMASK TCB_CANCELTYPE_BITMASK CANCELTYPE_BITMASK -TCB_CANCELING_BITMASK CANCELING_BITMASK TCB_CANCELED_BITMASK CANCELED_BITMASK TCB_EXITING_BITMASK EXITING_BITMASK TCB_CANCEL_RESTMASK CANCEL_RESTMASK From patchwork Mon Oct 14 20:56:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176339 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5011706ill; Mon, 14 Oct 2019 13:57:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXcDEGmK4Myunc8mt48WUhWm26Ja3sHNZrbBjP/UbuLAvwKQBUgnGwf7h9MK885sFkdY75 X-Received: by 2002:a17:906:4cd2:: with SMTP id q18mr7594894ejt.319.1571086668310; Mon, 14 Oct 2019 13:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086668; cv=none; d=google.com; s=arc-20160816; b=GmxoZLPtQp8+8RqmHlLfzyyT/LLasa46raFeIRH/+enyjNo0+yeSy+wGRMuibSsVr/ 4Y8IF58g2howfd1vCUJPCtU2Nt7MllaN2sw4sr7cKN1PzjKRnzFCVph+kWLKqSnypfJT N11W25zTuSmdAajMxUYiaEMRVAyGjq4UpXh71ohtYCSvJO3Bq7P88+HqfJLZWKmdhW3L qE/gZ2AdXyhcjyz/KOpTff/c1Hw8fJifPhoDuoryxxPp4IG84DvqINiRIQmbagI6+jfQ Mnm6rZN2Cb/+KV8xPoxEP/QV7bWRas5Q8Fz6z71enHXia54+b+fEQF+6Terw8hgEkRUn 5fUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=qK1QMtopK/c1QQLbgPPXFUvm+Y3GEgQidzHkuFfoxV0=; b=03Vag/QUgf5IU5883rkIEcC9HRXUHGo25uHGs6EpmFgQ9K2h76ampOfBEQ6ZaPPOiR dgn6QYAYas4WAlE8QawshuKxR1BYxn4aZldf9ijll+s5n3jGoXZllF69vyiW4uS6ehVI 6i50w+2KDdppPeVieRiZDCF4jW33desE2hP2wtsIPVpeTdXCzWh4eqw5zJphvGfTR9ld /D4xr3PSiqJUBBnQehGOIGg9G4uNr0xjqZvnfwpHgiFb3deFBnF73NWkWtObd9CRAHva 2490rqwYfLdHILAjZ0si3UOrT8D0yYICClu/79DckIGcepI//Ti4ykgo5r5GKL3zAACb CCRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="jIexB/wB"; dkim=pass header.i=@linaro.org header.s=google header.b=w20nblId; spf=pass (google.com: domain of libc-alpha-return-105930-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105930-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v16si4251606ejx.96.2019.10.14.13.57.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:57:48 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105930-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="jIexB/wB"; dkim=pass header.i=@linaro.org header.s=google header.b=w20nblId; spf=pass (google.com: domain of libc-alpha-return-105930-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105930-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=LPKGRJacHQoQ/rQixRgGftgaezZCi2s xXK5yce5TUy3nh2GS4tmAQGzouYXmd1W9/qJGXYI5/aNsE7wDx8inQ+Rxyb3QGHq vElVDAXHn1YYmRtSK7Qg4YtDybqQBvpBphg8G5Nck7ZDkBdaBP7c+wJDvGS9kB0B UjBtZR82srIo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=gKFuD+q9rUpuexyqIQ10eGixIIo=; b=jIexB /wBx5AA7/4JfXEbHGDGUXuw0DF3yJCdz95/U26YLGNjklofKj7scVAiRKUmTvPno +l6uBhWv+T38jdDuQMhKeY9a6831f8VyRSb7+RxiRmIpn0VOwhn1voQ/q6hiNGcv eKTA7/Jm1cEf+I4bZbCf29vBO01UCGWgI6DvB4= Received: (qmail 113718 invoked by alias); 14 Oct 2019 20:57:15 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 113573 invoked by uid 89); 14 Oct 2019 20:57:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f193.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=qK1QMtopK/c1QQLbgPPXFUvm+Y3GEgQidzHkuFfoxV0=; b=w20nblId5eAD6/gkpN0UGlYshpWeirpYDfCpLVjdnyVBCju4yDqLcdLjcn4z6syWMy 5mqH5RC72zPfSwcKKgmSJ51buT4X1OifPWF89PzCe+KsCgZgNP4LY4UTfF28WKF5V2W/ zvPtnXkylz3vk3WQUhkVmPEbc6+ZWEO4+qAgbcLSPNNOvj0Jsijjr8FYzyhhiRb+cJEk xgjhFk0TYrovXD4jbCxzqCzz3GcVGZGapZ3cPPoxjp+/IPgryhFNUuejJJEB19f45XR3 ouYxWTE0aWpLUM2wXumiNfgFeXJCKDW56hlgdwyPY0APoBb9r0xpqxWSPo95Acdb1t5+ TJnQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 04/21] nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:39 -0300 Message-Id: <20191014205656.29834-5-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patches adds the x32 modification required for the BZ#12683. It basically adjust the syscall size used to pass the arguments to the syscall cancel wrappers by zero extending pointers type while preserting values for default types (such as off_t). Checked on x86_64-linux-gnu-x32. --- include/libc-pointer-arith.h | 16 +++++++++++----- sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h | 13 +++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/include/libc-pointer-arith.h b/include/libc-pointer-arith.h index b32df719d1..0e5bb83f56 100644 --- a/include/libc-pointer-arith.h +++ b/include/libc-pointer-arith.h @@ -25,17 +25,23 @@ # define __pointer_type(type) (__builtin_classify_type ((type) 0) == 5) /* intptr_t if P is true, or T if P is false. */ -# define __integer_if_pointer_type_sub(T, P) \ +# define __integer_if_pointer_type_sub(T, P, INTTYPE) \ __typeof__ (*(0 ? (__typeof__ (0 ? (T *) 0 : (void *) (P))) 0 \ - : (__typeof__ (0 ? (intptr_t *) 0 : (void *) (!(P)))) 0)) + : (__typeof__ (0 ? (INTTYPE *) 0 : (void *) (!(P)))) 0)) /* intptr_t if EXPR has a pointer type, or the type of EXPR otherwise. */ -# define __integer_if_pointer_type(expr) \ +# define __integer_if_pointer_type(expr, inttype) \ __integer_if_pointer_type_sub(__typeof__ ((__typeof__ (expr)) 0), \ - __pointer_type (__typeof__ (expr))) + __pointer_type (__typeof__ (expr)), \ + inttype) /* Cast an integer or a pointer VAL to integer with proper type. */ -# define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val)) +# define cast_to_integer(val) \ + ((__integer_if_pointer_type (val, intptr_t)) (val)) + +/* Cast an integer or a pointer VAL to unsigned integer with proper type. */ +# define cast_to_uinteger(val) \ + ((__integer_if_pointer_type (val, uintptr_t)) (val)) /* Align a value by rounding down to closest size. e.g. Using size of 4096, we get this behavior: diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h index 60a144a474..568ca1c959 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h @@ -18,6 +18,19 @@ #ifndef _LINUX_X32_SYSDEP_H #define _LINUX_X32_SYSDEP_H 1 +#ifndef __ASSEMBLER__ +#include +#include + +typedef long long int __syscall_arg_t; + +/* Syscall arguments for x32 follows x86_64 size, however pointers are 32 + bits in size. The idea is to zero extend pointer types while cast to + signed 64 bit default arguments. */ +#define __SSC(__x) ((__syscall_arg_t) cast_to_uinteger (__x)) + +#endif + /* There is some commonality. */ #include #include From patchwork Mon Oct 14 20:56:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176340 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5011856ill; Mon, 14 Oct 2019 13:58:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnqpuyFR/Dc8CanJsNdFlidukIRCcDJE10miWAeEHevQBJI3Gwss40+5SPWwNvyTcBGNi6 X-Received: by 2002:a17:906:470d:: with SMTP id y13mr30661950ejq.241.1571086681951; Mon, 14 Oct 2019 13:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086681; cv=none; d=google.com; s=arc-20160816; b=a7vbCbnhUps6wcbACS5ylZlCGauAF1lE4DPpKXIWTi/FSx4TI7T99CnNnDWbWvuWYo 7mE0ofDPybzXLavShjVHx0u63fxwGmdp5vkZLUJ0y6DQP2uEvEEZ7VsTZoqJh9OTtEgn 5ot4IBxSri6o19Jg+kUV4i+rXHRz/vASOegU7AuuUPUabWyiics/cwKBVNwNk0JPKUmG 5gpeIF309lkqi38EnwA9NOgU3vvbbro/wsU7zZWg4StQQrQG47pJyzqM0yzWNqB+59B4 Vcw/NaBIZdGv255WooolnqTg5Z1t8lG0Zm45GZxn/AiSZpf0nxhcc5hWTGnDz4kwHw// rXGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=bv3HGD5sMtMH6meOlXVPd/EuZwt1B0r43f/0HZSpKUk=; b=wIMhkXKrHMlb3qilZkdN5FmA8LTTuSSB3J+GduUlvNpWhCmn62fZl9wsKj6knrGcjo mxHA8gSWpM41Cwj7YfBiFe1q2AgeKgN0yEwRI4lmZvj9IAzWFf1ETNk+vWpQ/nV1xIh+ yjyjF4wFyYD7+VOf4z4oDDAVC65GDfpz6hJzQ6IYsFXgyyXx/UxOmG0SECghzYlc0aAF XOVo0zEWQUOWWCaypIiSwZcCvp0Y7DNGhbaOEdRtjvu4kl+hRmWtnbCdoG011p6oim2V KuhSQQ2dDoJ+6RzguUVLHYs00+/G30REr5MKozfF1CHfsCYs1Z//qHbu+I7/vbid7Vij mFZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ZwsNWvWr; dkim=pass header.i=@linaro.org header.s=google header.b=N5Rw02zQ; spf=pass (google.com: domain of libc-alpha-return-105931-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105931-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id gh12si11362980ejb.191.2019.10.14.13.58.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:58:01 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105931-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ZwsNWvWr; dkim=pass header.i=@linaro.org header.s=google header.b=N5Rw02zQ; spf=pass (google.com: domain of libc-alpha-return-105931-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105931-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=nFnVtG/3BgZSH+KfSswqEmJfQMrIy1u Gm8Jmx1FZm7F/2cwBB1CCoHVFS9FXGI/Jh4Jz1Lqyd9HJXjl7xGtTaGN9AMXIc8s 3iP9BxfIMYa64lBE5njYGtJQtazJPX8no7BAocDM79iI9vrbpiLzOpC7NdWZ9ymc oVIYPdTmoLUI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=MVg+ySpRqTnCqX9lTsueIwIMirk=; b=ZwsNW vWrm7w7/t+aIoFSI5/ghkz7QcMkjB6I9/ujS+oEMWVOjc3wgBrv8IbGBQhWrdfBE Z29XTtfW8EqpcS9KS84ebzQRfTIzspjxsz8IA6D5vDDRZxCV+ettLltPtjjBB9GV xWjZC9wp0NS3i0SBfkAGhLh9gvbi3EG0hyvycQ= Received: (qmail 114119 invoked by alias); 14 Oct 2019 20:57:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 114023 invoked by uid 89); 14 Oct 2019 20:57:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Due, obtained X-HELO: mail-qt1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=bv3HGD5sMtMH6meOlXVPd/EuZwt1B0r43f/0HZSpKUk=; b=N5Rw02zQg0YjdMc4haWn0gpvxHtMVu1b0EMmZu0t2tXRG8EmPqEsDwUtOubIiW33dw zTzeixCUBcrdNnwrK9JtJmS2rcxDdJliLkW8oQ2ZNqmrY2974ArgsMWOMjGtVMtHjg6n NJcsYtzClU2vWzBLjEgaWcvVPGufyGzbec2VNyVkwLR6X+iY3LYNC4ab9UqAAFYXpkoS Y3wXTAqK4wcMBXj9073u2COhjGYY7X+fSZubniU5WvpuR8QBzhxaM7wmrM0XQcNGPR5X U/L5PUrbYI8w+X1B3PBDxi6PbufIxcoWFvRbS9EMF8gPfSyLY6d0CAF/xkbfXgLh5IBI mWbg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 05/21] nptl: ia64: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:40 -0300 Message-Id: <20191014205656.29834-6-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the ia64 modifications required for the BZ#12683 fix. The syscall bridge uses the old brk 0x10000 instruction because by using the vDSO gate the resulting PC value for an interrupted syscall points to an address outside the expected markers in __syscall_cancel_arch. This is similar to i686 issue. Also the __syscall_cancel_arch issues the 'break 0x100000' on its own bundle, and __syscall_cancel_arch_end points to end of the previous one. It requires an arch-specific ucontext_check_pc_boundary to check for the ri value (embedded in the sc_ip by the kernel) to check if the syscall had any side-effects. Also, ia64 issues a sigcontext as third argument for sigaction handler with SA_SIGINFO which requires an arch-specific ucontext_add_cancel. Checked on ia64-linux-gnu. --- .../sysv/linux/ia64/cancellation-pc-check.h | 48 +++++++++++ .../sysv/linux/ia64/cancellation-sigmask.h | 33 ++++++++ sysdeps/unix/sysv/linux/ia64/syscall_cancel.S | 83 +++++++++++++++++++ 3 files changed, 164 insertions(+) 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 -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/ia64/cancellation-pc-check.h b/sysdeps/unix/sysv/linux/ia64/cancellation-pc-check.h new file mode 100644 index 0000000000..bbd0c99fe1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/ia64/cancellation-pc-check.h @@ -0,0 +1,48 @@ +/* Architecture specific bits for cancellation handling. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _NPTL_CANCELLATION_PC_CHECK +#define _NPTL_CANCELLATION_PC_CHECK 1 + +/* Check if the program counter (PC) from ucontext CTX is within the start and + then end boundary from the __syscall_cancel_arch bridge. Return TRUE if + the PC is within the boundary, meaning the syscall does not have any side + effects; or FALSE otherwise. */ +static bool +ucontext_check_pc_boundary (void *ctx) +{ + /* Both are defined in syscall_cancel.S for each architecture. */ + extern const char __syscall_cancel_arch_start[1]; + extern const char __syscall_cancel_arch_end[1]; + + uintptr_t sc_ip = ((struct sigcontext *) (ctx))->sc_ip; + uintptr_t cr_iip = sc_ip & ~0x3ull; + uintptr_t ri = sc_ip & 0x3ull; + + /* IA64 __syscall_cancel_arch issues the 'break 0x100000' on its own bundle, + and __syscall_cancel_arch_end points to end of the previous bundle. + To check if the syscall had any side-effects we need to check the slot + number. */ + if (cr_iip == (uintptr_t) __syscall_cancel_arch_end) + return ri == 0; + + return cr_iip >= (uintptr_t) __syscall_cancel_arch_start + && cr_iip < (uintptr_t) __syscall_cancel_arch_end; +} + +#endif diff --git a/sysdeps/unix/sysv/linux/ia64/cancellation-sigmask.h b/sysdeps/unix/sysv/linux/ia64/cancellation-sigmask.h new file mode 100644 index 0000000000..300f090a82 --- /dev/null +++ b/sysdeps/unix/sysv/linux/ia64/cancellation-sigmask.h @@ -0,0 +1,33 @@ +/* Architecture specific bits for cancellation handling. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _NPTL_CANCELLATION_SIGMASK_H +#define _NPTL_CANCELLATION_SIGMASK_H 1 + +/* Add the SIGCANCEL signal on sigmask set at the ucontext CTX obtained from + the sigaction handler. */ +static void +ucontext_add_cancel (void *ctx) +{ + /* IA64 issues a sigcontext as third argument for sigaction handler (instead + of usual ucontext_t). */ + struct sigcontext *sctx = (struct sigcontext *) (ctx); + __sigaddset ((sigset_t *) &sctx->sc_mask, SIGCANCEL); +} + +#endif diff --git a/sysdeps/unix/sysv/linux/ia64/syscall_cancel.S b/sysdeps/unix/sysv/linux/ia64/syscall_cancel.S new file mode 100644 index 0000000000..bf6ec105db --- /dev/null +++ b/sysdeps/unix/sysv/linux/ia64/syscall_cancel.S @@ -0,0 +1,83 @@ +/* Cancellable syscall wrapper. Linux/IA64 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#undef ret + +/* long int __syscall_cancel_arch (int *cancelhandling, long int nr, + long int arg1, long int arg2, long int arg3, + long int arg4, long int arg5, long int arg6) +*/ + +ENTRY (__syscall_cancel_arch) + .prologue ASM_UNW_PRLG_RP | ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE (8) + .mmi + .save ar.pfs, r41 + alloc r41=ar.pfs,8,3,8,0 + mov r15=r33 + .save rp, r40 + mov r40=b0 + .body + .mmi + mov r43=r34 + mov r44=r35 + mov r45=r36 + ;; + .mmi + mov r46=r37 + mov r47=r38 + mov r48=r39 + ;; + + .global __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + ;; + .mmi + nop 0 + ld4.acq r14=[r32] + nop 0 + ;; + .mib + nop 0 + tbit.z p6, p7=r14, 2 + .pred.safe_across_calls p1-p63 +(p7) br.call.dpnt.many b0 = __syscall_do_cancel# + .pred.safe_across_calls p1-p5,p16-p63 + ;; + + /* Due instruction bundle ia64 has the end marker before the syscall + instruction. Check IA64 ucontext_check_pc_boundary on how the PC + is checked. */ + .global __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + break 0x100000 + ;; + .mmi + cmp.ne p6, p7=-1, r10 + nop 0 + mov b0=r40 + ;; + .mib +(p7) sub r8=r0, r8 + mov ar.pfs=r41 + br.ret.sptk.many b0 + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176342 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5012146ill; Mon, 14 Oct 2019 13:58:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvTWXVR1DAKHqTYWmLqy7o6vrGNW4e4lOFuSu8llFCL7Kz3jQH0sJ64JEzoJbqcT4hbCva X-Received: by 2002:a50:9f68:: with SMTP id b95mr29729584edf.301.1571086705303; Mon, 14 Oct 2019 13:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086705; cv=none; d=google.com; s=arc-20160816; b=AyI5kE7McactASkWGlYTr6tCszcvX6zMs544P/VTv4gCxerCsy6CVzKdJuHJyQrMh4 OcaqgUybYhic76CqZxlmu/mozWPnM1rhKXVqtcsPx8JS7RqyN3LPKMIT3s6mZnFqC1HM 3gUVl5JPMQkZG+QcRZ60ILmPnzMhSBMdgtVio86Vmvt1M9Lnf2VWPqUhT/uwEnWf6uPV 64WUdgqC/S9yFM6YWxuZ7Swvy6YjSjlOA9bDvarEYZLltamBORt2mGbMr99MWVas8R0c PZTo+cm7Cs/lx0jUX1doZcu0s9XOxV3D9rEDFeext6nZKtvwYN/JL3lmPBLWm3FYkQFJ rkmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=4KsCmTqNl+z5iq1uoRtE7P84zkeDj3WunSqQYWIiWrk=; b=iKC5lLvI9onlx9N0zdvwQSiM6mlEDt5Kc5tF8tGgzx5PJ1QC9Dd+lHD4Kc8n0o/hDQ W3IOfVPwlo3uGXvfurQUxXiKg31+1at9QpeFtcOw1ZH78rLmdkdH53YYJ6JZ5YUumPt8 CpnXaEhcFmZfN8MoQ1ctY3g2+k6zc2BObfEhWGczKQ8l+yVoPLFnDJ1+dQFnhL/keR1i h+JLI/C2uYtbpJxtcRKUX6goai2BEV6q/k8PPwvtMa8EMr3VLxs3ypBDuQxj1uUvzacO V7v3WnlZ/aQu8oi2X2fqJudTeQ6zsoxB2C67Pu70QYziGYvRCYAmQPswz0XYKKYm2wXX vyhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=aNlHOcvb; dkim=pass header.i=@linaro.org header.s=google header.b=W0+fa0l5; spf=pass (google.com: domain of libc-alpha-return-105933-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105933-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y2si11769111eds.98.2019.10.14.13.58.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:58:25 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105933-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=aNlHOcvb; dkim=pass header.i=@linaro.org header.s=google header.b=W0+fa0l5; spf=pass (google.com: domain of libc-alpha-return-105933-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105933-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=QAp2W8te+e1i3Ap0R1BLhF60k2LX8o2 RknGWCTr7wZCi10lIqGlGc+n/gz9Tj/pcih/yyngX2NEbsRbsUgnLVFic0B0268m JgZ3UgqHn3rbMP+V3cfjgw9ZjGkAPlzTQMfPFusa5nsLP1Y6WlIFVoC7aDF8ve+m IxEQOrPxBZQw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=AN1zS3VUQoZkvSGTdW5BqL4zyFg=; b=aNlHO cvb8ZRgy/8UYIQiWFC8bU8d+/MlDRbX9an5rMYrmZ1Ga09bB2+Oo5FdcZ5H/4JVz 1gICE63ulMf3HmLXMQPXJJWvkEPdNz5ndqEUO7APbjNtfHXxDac9q0ushPMfu1HC BWOxJQtEb3M3qnz7NdhW+DSqRij0m7MaGGQdKc= Received: (qmail 114512 invoked by alias); 14 Oct 2019 20:57:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 114389 invoked by uid 89); 14 Oct 2019 20:57:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=4KsCmTqNl+z5iq1uoRtE7P84zkeDj3WunSqQYWIiWrk=; b=W0+fa0l5w1VvAU9owOUsZ78Bu8TLM+cQkFv26k4DFZ8EM2BtdOx92lbukUeLajlRuV zO3VobZh80CNvhLsDgsN4JHkOqOpf1rApDhpEaHmT1/pWh6jzTlHbJH6GF4nDkDWHUoZ lKanhKR8tPeXMFcRlLLSn17iWX/cc4T50JgBsN0l62pyTXSYka7Ttdb0mfxVbSbG/6X1 JgIcErQxOcFfrnehkCfTzHSwTssSxMtZQgNdMwdTHUp6hQnyNTRAEyEyCpONJ5K4GIpq PhgZ/mkoE2Jt+0eL3R4uHG0alAfhk0Hi4hxnQtXG1u4/xubzYrtnYHbsUngM3e6XOZAT 1Y8A== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 06/21] nptl: mips: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:41 -0300 Message-Id: <20191014205656.29834-7-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the mips modifications required for the BZ#12683. It adds the arch-specific cancellation syscall bridge and adjust the cancellable syscall bridge to accept 7 arguments (as required by mips o32). To avoid code pessimization and add a requirement on all architectures to support {INLINE,INTERNAL)_SYSCALL with 7 argument, its support is added through a flag, HAVE_CANCELABLE_SYSCALL_WITH_7_ARGS, which changes the signature and prototype of the requires macros and functions (SYSCALL_CANCEL, __syscall_cancel and __syscall_cancel_arch). As default 6 arguments cancellable syscalls are use. Checked on mips-linux-gnu, mips64-linux-gnu, and mips64-n32-linux-gnu. --- nptl/libc-cancellation.c | 7 +- nptl/pthreadP.h | 3 +- sysdeps/mips/nptl/tls.h | 2 +- sysdeps/unix/sysdep.h | 37 +++-- .../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/syscall_cancel.c | 6 +- 8 files changed, 286 insertions(+), 15 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/mips/mips32/syscall_cancel.S create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/syscall_cancel.S -- 2.17.1 diff --git a/nptl/libc-cancellation.c b/nptl/libc-cancellation.c index 430e0b962e..4dab740b38 100644 --- a/nptl/libc-cancellation.c +++ b/nptl/libc-cancellation.c @@ -23,7 +23,7 @@ long int __syscall_cancel (__syscall_arg_t nr, __syscall_arg_t a1, __syscall_arg_t a2, __syscall_arg_t a3, __syscall_arg_t a4, __syscall_arg_t a5, - __syscall_arg_t a6) + __syscall_arg_t a6 __SYSCALL_CANCEL7_ARG_DEF) { pthread_t self = (pthread_t) THREAD_SELF; struct pthread *pd = (struct pthread *) self; @@ -33,7 +33,8 @@ __syscall_cancel (__syscall_arg_t nr, __syscall_arg_t a1, if (pd->cancelhandling & CANCELSTATE_BITMASK) { INTERNAL_SYSCALL_DECL (err); - result = INTERNAL_SYSCALL_NCS_CALL (nr, err, a1, a2, a3, a4, a5, a6); + result = INTERNAL_SYSCALL_NCS_CALL (nr, err, a1, a2, a3, a4, a5, a6 + __SYSCALL_CANCEL7_ARG7); if (INTERNAL_SYSCALL_ERROR_P (result, err)) return -INTERNAL_SYSCALL_ERRNO (result, err); return result; @@ -42,7 +43,7 @@ __syscall_cancel (__syscall_arg_t nr, __syscall_arg_t a1, /* Call the arch-specific entry points that contains the globals markers to be checked by SIGCANCEL handler. */ result = __syscall_cancel_arch (&pd->cancelhandling, nr, a1, a2, a3, a4, a5, - a6); + a6 __SYSCALL_CANCEL7_ARG7); if ((result == -EINTR) && (pd->cancelhandling & CANCELED_BITMASK) diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index cafd14f5af..ac0ad00745 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -331,7 +331,8 @@ __do_cancel (void) extern long int __syscall_cancel_arch (volatile int *, __syscall_arg_t nr, __syscall_arg_t arg1, __syscall_arg_t arg2, __syscall_arg_t arg3, - __syscall_arg_t arg4, __syscall_arg_t arg5, __syscall_arg_t arg6); + __syscall_arg_t arg4, __syscall_arg_t arg5, __syscall_arg_t arg6 + __SYSCALL_CANCEL7_ARG_DEF); libc_hidden_proto (__syscall_cancel_arch); extern _Noreturn void __syscall_do_cancel (void) diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h index e0364d46a8..3f53e53efb 100644 --- a/sysdeps/mips/nptl/tls.h +++ b/sysdeps/mips/nptl/tls.h @@ -35,7 +35,7 @@ # define READ_THREAD_POINTER() (__builtin_thread_pointer ()) #else /* Note: rd must be $v1 to be ABI-conformant. */ -# if __mips_isa_rev >= 2 +# if defined __mips_isa_rev && __mips_isa_rev >= 2 # define READ_THREAD_POINTER() \ ({ void *__result; \ asm volatile ("rdhwr\t%0, $29" : "=v" (__result)); \ diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h index 04f30b8cbc..d6c75b14a3 100644 --- a/sysdeps/unix/sysdep.h +++ b/sysdeps/unix/sysdep.h @@ -121,29 +121,50 @@ typedef long int __syscall_arg_t; # define __SSC(__x) ((__syscall_arg_t) (__x)) #endif +/* Adjust both the __syscall_cancel and the SYSCALL_CANCEL macro to support + 7 arguments instead of default 6 (curently only mip32). It avoid add + the requirement to each architecture to support 7 argument macros + {INTERNAL,INLINE}_SYSCALL. */ +#ifdef HAVE_CANCELABLE_SYSCALL_WITH_7_ARGS +# define __SYSCALL_CANCEL7_ARG_DEF , __syscall_arg_t arg7 +# define __SYSCALL_CANCEL7_ARG , 0 +# define __SYSCALL_CANCEL7_ARG7 , arg7 +#else +# define __SYSCALL_CANCEL7_ARG_DEF +# define __SYSCALL_CANCEL7_ARG +# define __SYSCALL_CANCEL7_ARG7 +#endif + long int __syscall_cancel (__syscall_arg_t nr, __syscall_arg_t arg1, __syscall_arg_t arg2, __syscall_arg_t arg3, __syscall_arg_t arg4, __syscall_arg_t arg5, - __syscall_arg_t arg6); + __syscall_arg_t arg6 __SYSCALL_CANCEL7_ARG_DEF); libc_hidden_proto (__syscall_cancel); #define __SYSCALL_CANCEL0(name) \ - (__syscall_cancel)(__NR_##name, 0, 0, 0, 0, 0, 0) + (__syscall_cancel)(__NR_##name, 0, 0, 0, 0, 0, 0 \ + __SYSCALL_CANCEL7_ARG) #define __SYSCALL_CANCEL1(name, a1) \ - (__syscall_cancel)(__NR_##name, __SSC(a1), 0, 0, 0, 0, 0) + (__syscall_cancel)(__NR_##name, __SSC(a1), 0, 0, 0, 0, 0 \ + __SYSCALL_CANCEL7_ARG) #define __SYSCALL_CANCEL2(name, a1, a2) \ - (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), 0, 0, 0, 0) + (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), 0, 0, 0, 0 \ + __SYSCALL_CANCEL7_ARG) #define __SYSCALL_CANCEL3(name, a1, a2, a3) \ - (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), __SSC(a3), 0, 0, 0) + (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), __SSC(a3), 0, 0, 0 \ + __SYSCALL_CANCEL7_ARG) #define __SYSCALL_CANCEL4(name, a1, a2, a3, a4) \ (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), __SSC(a3), \ - __SSC(a4), 0, 0) + __SSC(a4), 0, 0 __SYSCALL_CANCEL7_ARG) #define __SYSCALL_CANCEL5(name, a1, a2, a3, a4, a5) \ (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), __SSC(a3), \ - __SSC(a4), __SSC(a5), 0) + __SSC(a4), __SSC(a5), 0 __SYSCALL_CANCEL7_ARG) #define __SYSCALL_CANCEL6(name, a1, a2, a3, a4, a5, a6) \ (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), __SSC(a3), \ - __SSC(a4), __SSC(a5), __SSC(a6)) + __SSC(a4), __SSC(a5), __SSC(a6) __SYSCALL_CANCEL7_ARG) +#define __SYSCALL_CANCEL7(name, a1, a2, a3, a4, a5, a6, a7) \ + (__syscall_cancel)(__NR_##name, __SSC(a1), __SSC(a2), __SSC(a3), \ + __SSC(a4), __SSC(a5), __SSC(a6), __SSC(a7)) #define __SYSCALL_CANCEL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n #define __SYSCALL_CANCEL_NARGS(...) \ diff --git a/sysdeps/unix/sysv/linux/mips/mips32/syscall_cancel.S b/sysdeps/unix/sysv/linux/mips/mips32/syscall_cancel.S new file mode 100644 index 0000000000..a6445efb4f --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/mips32/syscall_cancel.S @@ -0,0 +1,128 @@ +/* Cancellable syscall wrapper. Linux/mips32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + __syscall_arg_t nr, + __syscall_arg_t arg1, + __syscall_arg_t arg2, + __syscall_arg_t arg3, + __syscall_arg_t arg4, + __syscall_arg_t arg5, + __syscall_arg_t arg6, + __syscall_arg_t arg7) */ + +#define FRAME_SIZE 56 + +NESTED (__syscall_cancel_arch, FRAME_SIZE, fp) + .mask 0xc0070000,-SZREG + .fmask 0x00000000,0 + + PTR_ADDIU sp, -FRAME_SIZE + cfi_def_cfa_offset (FRAME_SIZE) + + sw fp,48(sp) + sw ra,52(sp) + sw s2,44(sp) + sw s1,40(sp) + sw s0,36(sp) +#ifdef __PIC__ + .cprestore 16 +#endif + cfi_offset (31, -4) + cfi_offset (30, -8) + cfi_offset (18, -12) + cfi_offset (17, -16) + cfi_offset (16, -20) + move fp,sp + cfi_def_cfa_register (30) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start, @function +__syscall_cancel_arch_start: + + lw v0,0(a0) + andi v0,v0,0x4 + bne v0,zero,2f + + addiu sp,sp,-16 + addiu v0,sp,16 + sw v0,24(fp) + + move s0,a1 + move a0,a2 + move a1,a3 + lw a2,72(fp) + lw a3,76(fp) + lw v0,84(fp) + lw s1,80(fp) + lw s2,88(fp) + + .set noreorder + subu sp, 32 + sw s1, 16(sp) + sw v0, 20(sp) + sw s2, 24(sp) + move v0, $16 + syscall + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end, @function +__syscall_cancel_arch_end: + addiu sp, 32 + .set reorder + + beq a3,zero,1f + subu v0,zero,v0 +1: + move sp,fp + cfi_remember_state + cfi_def_cfa_register (29) + lw ra,52(fp) + lw fp,48(sp) + lw s2,44(sp) + lw s1,40(sp) + lw s0,36(sp) + .set noreorder + .set nomacro + jr ra + addiu sp,sp,FRAME_SIZE + + .set macro + .set reorder + + cfi_def_cfa_offset (0) + cfi_restore (16) + cfi_restore (17) + cfi_restore (18) + cfi_restore (30) + cfi_restore (31) + +2: + cfi_restore_state +#ifdef __PIC__ + PTR_LA t9, __syscall_do_cancel + jalr t9 +#else + jal __syscall_do_cancel +#endif + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h index 86347fe91a..c427146a10 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h @@ -18,6 +18,10 @@ #ifndef _LINUX_MIPS_MIPS32_SYSDEP_H #define _LINUX_MIPS_MIPS32_SYSDEP_H 1 +/* mips32 have cancelable syscalls with 7 arguments (currently only + sync_file_range). */ +#define HAVE_CANCELABLE_SYSCALL_WITH_7_ARGS 1 + /* There is some commonality. */ #include #include diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscall_cancel.S b/sysdeps/unix/sysv/linux/mips/mips64/syscall_cancel.S new file mode 100644 index 0000000000..529209ea2c --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/mips64/syscall_cancel.S @@ -0,0 +1,114 @@ +/* Cancellable syscall wrapper. Linux/mips64 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + __syscall_arg_t nr, + __syscall_arg_t arg1, + __syscall_arg_t arg2, + __syscall_arg_t arg3, + __syscall_arg_t arg4, + __syscall_arg_t arg5, + __syscall_arg_t arg6, + __syscall_arg_t arg7) */ + +#define FRAME_SIZE 32 +#define ADDIU LONG_ADDIU +#define ADDU LONG_ADDU +#define SUBU LONG_SUBU +#define LOAD_L LONG_L + +NESTED (__syscall_cancel_arch, FRAME_SIZE, fp) + .mask 0x90010000, -SZREG + .fmask 0x00000000, 0 + ADDIU sp, sp, -32 + cfi_def_cfa_offset (32) + sd gp, 16(sp) + cfi_offset (gp, -16) + lui gp, %hi(%neg(%gp_rel(__syscall_cancel_arch))) + ADDU gp, gp, t9 + sd ra, 24(sp) + sd s0, 8(sp) + cfi_offset (ra, -8) + cfi_offset (s0, -24) + ADDIU gp, gp, %lo(%neg(%gp_rel(__syscall_cancel_arch))) + + .global __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,%function +__syscall_cancel_arch_start: + + lw v0, 0(a0) + andi v0, v0, 0x4 + .set noreorder + .set nomacro + bne v0, zero, 2f + move s0, a1 + .set macro + .set reorder + + move a0, a2 + move a1, a3 + move a2, a4 + move a3, a5 + move a4, a6 + move a5, a7 + + .set noreorder + move v0, s0 + syscall + .set reorder + + .global __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,%function +__syscall_cancel_arch_end: + + .set noreorder + .set nomacro + bnel a3, zero, 1f + SUBU v0, zero, v0 + .set macro + .set reorder + +1: + ld ra, 24(sp) + ld gp, 16(sp) + ld s0, 8(sp) + + .set noreorder + .set nomacro + jr ra + ADDIU sp, sp, 32 + .set macro + .set reorder + + cfi_remember_state + cfi_def_cfa_offset (0) + cfi_restore (s0) + cfi_restore (gp) + cfi_restore (ra) + + .align 3 +2: + cfi_restore_state + LOAD_L t9, %got_disp(__syscall_do_cancel)(gp) + .reloc 3f, R_MIPS_JALR, __syscall_do_cancel +3: jalr t9 +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) diff --git a/sysdeps/unix/sysv/linux/syscall_cancel.c b/sysdeps/unix/sysv/linux/syscall_cancel.c index 79d66ec4f4..e845f51980 100644 --- a/sysdeps/unix/sysv/linux/syscall_cancel.c +++ b/sysdeps/unix/sysv/linux/syscall_cancel.c @@ -40,7 +40,8 @@ long int __syscall_cancel_arch (volatile int *ch, __syscall_arg_t nr, __syscall_arg_t a1, __syscall_arg_t a2, __syscall_arg_t a3, __syscall_arg_t a4, - __syscall_arg_t a5, __syscall_arg_t a6) + __syscall_arg_t a5, __syscall_arg_t a6 + __SYSCALL_CANCEL7_ARG_DEF) { #define ADD_LABEL(__label) \ asm volatile ( \ @@ -53,7 +54,8 @@ __syscall_cancel_arch (volatile int *ch, __syscall_arg_t nr, __syscall_do_cancel(); INTERNAL_SYSCALL_DECL(err); - long int result = INTERNAL_SYSCALL_NCS (nr, err, 6, a1, a2, a3, a4, a5, a6); + long int result = INTERNAL_SYSCALL_NCS_CALL (nr, err, a1, a2, a3, a4, a5, + a6 __SYSCALL_CANCEL7_ARG7); ADD_LABEL ("__syscall_cancel_arch_end"); if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))) return -INTERNAL_SYSCALL_ERRNO (result, err); From patchwork Mon Oct 14 20:56:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176341 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5011992ill; Mon, 14 Oct 2019 13:58:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOIafbrBxHCAzGfAHrrhP8Hh5UIG+PwcJbDTZep33S+N+5yQk48y+mxu/p9Gu3Rmwzy1DG X-Received: by 2002:a17:906:3c4:: with SMTP id c4mr11106959eja.302.1571086693153; Mon, 14 Oct 2019 13:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086693; cv=none; d=google.com; s=arc-20160816; b=sMo/WX1ZUwd70o1OqeqpFTYiqmiM5lQcRVoiy0maqrsXmlrIh594XTYR57vLqGSoHV pvOC3tIKdsvZ8Ql09aY6R/xQiot1Rph5zGf0IUKjN3oih9vI4LL2HV21MjVVqTqUyMlt fwP/lbCnVbpNwD1hVcSlnYnd6gvtrvuYxXe227+E7sQeRXcDkTNHNU3ls7XZQo6DOAYS QEDvBSmYlwMwNzBr63X9W76tgcNsP1HHlC1f9RK6DdTNzLMqj+tqHDz/w/Cp2c6K/g16 6mJI/sn2KO+tmXdKgEhgBdRHBokO+2QukTT/3e4j1E2azt+5rbCEtKykYPPDJsz3QX9v oKCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=pyXldy314OGfNCQW6cs26lCwSB8A1xaHLx/dTbphUQk=; b=cEbjmCShFR+V9JDu0LR/w6Qcjm4XliotMjt2q6oK3pAaZQXRd39RH4lmLMluoZ/SR2 lvQJPSQTiP5f+yo0n1538GIR6Rxi71yQ76RWrm+9Bptw2BxxOkhATg7HhDw3qFJj8YVC MQlMk9P9LJQf6XE35iR7WBNc3rKV6/cdaCGXFAqyXEPPptYohuYCtxw3/sSkwksG5bCJ V/Y1o0J2iH8LUqGzbT0O2OmX9LDwd9op0oZrKBiKciLcn2nHd+MhKv+pYWUX2CJRd+OI UncAIJarMyODsIJOQZ6DdRVqm5fiY1dbCXsRSqeGK4Oi9XnE6250KiSVKVv0RJZXhCuA Rwyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=nqUHV0ps; dkim=pass header.i=@linaro.org header.s=google header.b=ob+GoW4Q; spf=pass (google.com: domain of libc-alpha-return-105932-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105932-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id k24si12353121ejz.284.2019.10.14.13.58.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105932-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=nqUHV0ps; dkim=pass header.i=@linaro.org header.s=google header.b=ob+GoW4Q; spf=pass (google.com: domain of libc-alpha-return-105932-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105932-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=f92bkYsa1xMbbGyZtxOFRAUYbkp0cH5 G+BGUu247WxWY7NZ67JB+6486E/UrM6YWnfJlVn4DI6nTiAFHpYi0AQUYoD/t4wK dOICE31LiGOfU8BxXkLNgtvxAi50qCD/2svD/YsX0qC2hFpgK7BF4APJyOliU43t XmwlFt+RPWX8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=Wm/2VyhDJnZDUOZ6lHjYPog/aOI=; b=nqUHV 0psIbaOqF/aJ2ROGtKLBMsXlhtN5258HmyjChBIPvH5bVo98VUcefdbzNXkrpTOL Ih7mgQtzCOp2QrWQ9wAlZLAVd6hZ/fuf/MfvZzcXAuIXtP5tcTHCcmWyznfJ9r0v 1d4KvOMKlONmBmtnoCNllZ9mL862cBMDjVuJpY= Received: (qmail 114479 invoked by alias); 14 Oct 2019 20:57:20 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 114364 invoked by uid 89); 14 Oct 2019 20:57:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=marks, accomplish X-HELO: mail-qk1-f196.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=pyXldy314OGfNCQW6cs26lCwSB8A1xaHLx/dTbphUQk=; b=ob+GoW4QhfwC0xFtyRXQdC4cmV9Cu5Ym48Go/e2gn+gi9lcmMXUXb0D/Us9jh/K+x+ byfLbdMfD+9ZQU8FHCEeTk6++XQw1I1g4c+gi9V3mMxZlc6fmfc6ohEZnv3AR9N9WZyq oj/UPY4A7DwrkDi+qLD/ltvnKISMDipskEK5FUcnTJTpDto8086G5FOrbScbmldpsm2k bFaAvpSPIMWWDpbCh07Uz8eZioLnz1Dh9sKUzxNjE0BdnwWaHTTLKUPkUO4Q5aX25AOR 0CmaMv53Jgy3NrK05KRfgQiNZ2KpEXw2jkwvDr4hXDPd2MoQYwBRYIIdLUjmrUYe0Ogg Ovvg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 07/21] nptl: i386: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:42 -0300 Message-Id: <20191014205656.29834-8-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the i386 modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. The syscall bridge uses the old int80 instruction because by using the optimized vDSO symbol the resulting PC value for an interrupted syscall points to an adress outside the expected markers in __syscall_cancel_arch. It has been discussed in LKML [1] on how kernel could help userland to accomplish it, but afaik discussion has stalled. Also, sysenter should not be used directly by libc since its calling convention is set by the kernel depending of the underlying x86 chip (check kernel commit 30bfa7b3488bfb1bb75c9f50a5fcac1832970c60). Checked on i686-linux-gnu. [1] https://lkml.org/lkml/2016/3/8/1105 --- sysdeps/unix/sysv/linux/i386/Makefile | 2 +- sysdeps/unix/sysv/linux/i386/syscall_cancel.S | 105 ++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/i386/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile index da716e2c1b..7928497a35 100644 --- a/sysdeps/unix/sysv/linux/i386/Makefile +++ b/sysdeps/unix/sysv/linux/i386/Makefile @@ -9,7 +9,7 @@ $(objpfx)tst-bz21269: $(shared-thread-library) endif ifeq ($(subdir),elf) -sysdep-dl-routines += libc-do-syscall +sysdep-rtld_routines += libc-do-syscall sysdep-others += lddlibc4 install-bin += lddlibc4 endif diff --git a/sysdeps/unix/sysv/linux/i386/syscall_cancel.S b/sysdeps/unix/sysv/linux/i386/syscall_cancel.S new file mode 100644 index 0000000000..cc8c43f84d --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/syscall_cancel.S @@ -0,0 +1,105 @@ +/* Cancellable syscall wrapper. Linux/i686 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int [eax] __syscall_cancel_arch (int *cancelhandling [SP], + long int nr [SP+4], + long int arg1 [SP+8], + long int arg2 [SP+12], + long int arg3 [SP+16], + long int arg4 [SP+20], + long int arg5 [SP+24], + long int arg6 [SP+28]) */ + +ENTRY (__syscall_cancel_arch) + pushl %ebp + cfi_def_cfa_offset (8) + cfi_offset (ebp, -8) + pushl %edi + cfi_def_cfa_offset (12) + cfi_offset (edi, -12) + pushl %esi + cfi_def_cfa_offset (16) + cfi_offset (esi, -16) + pushl %ebx + cfi_def_cfa_offset (20) + cfi_offset (ebx, -20) + + .global __syscall_cancel_arch_start + .type __syscall_cancel_arch_start, @function +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + testb $4, (%eax) + jne 1f + + /* Issue a 6 argument syscall, the nr [%eax] being the syscall + number. */ + movl 24(%esp), %eax + movl 28(%esp), %ebx + movl 32(%esp), %ecx + movl 36(%esp), %edx + movl 40(%esp), %esi + movl 44(%esp), %edi + movl 48(%esp), %ebp + + /* We can not use the vDSO helper for syscall (__kernel_vsyscall) + because the returned PC from kernel will point to the vDSO page + instead of the expected __syscall_cancel_arch_{start,end} + marks. */ + int $128 + + .global __syscall_cancel_arch_end + .type __syscall_cancel_arch_end, @function +__syscall_cancel_arch_end: + + popl %ebx + cfi_restore (ebx) + cfi_def_cfa_offset (16) + popl %esi + cfi_restore (esi) + cfi_def_cfa_offset (12) + popl %edi + cfi_restore (edi) + cfi_def_cfa_offset (8) + popl %ebp + cfi_restore (ebp) + cfi_def_cfa_offset (4) + ret + +1: + /* Although the __syscall_do_cancel do not return, we need to stack + being set correctly for unwind. */ + popl %ebx + cfi_restore (ebx) + cfi_def_cfa_offset (16) + popl %esi + cfi_restore (esi) + cfi_def_cfa_offset (12) + popl %edi + cfi_restore (edi) + cfi_def_cfa_offset (8) + popl %ebp + cfi_restore (ebp) + cfi_def_cfa_offset (4) + jmp __syscall_do_cancel + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176343 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5012278ill; Mon, 14 Oct 2019 13:58:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqy99jLchg9rRLpGs4bNS6D0fXox+qw6pRQhcEe8ugtHJY1cIfzS7NK6Neo2s7etrnMQZ1Xz X-Received: by 2002:a17:906:64e:: with SMTP id t14mr30767979ejb.75.1571086714951; Mon, 14 Oct 2019 13:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086714; cv=none; d=google.com; s=arc-20160816; b=FtrdpMoQfh6ZK54KhLnfU8iQLMp49ohyP9503Y7/iqFWdkK+IJcaEEToyt6ddp2rE1 e4/N/rm1PAHyrH+nSefrGUHmVLCg0A1v1YyUHeCBsbmuQMvxebafd1MHmMlu1GNPU9Pt wzpfWyWKjzgdNRswZNDTriw6ic/tZJrNktCZn5SxTtlkhoab7i3/JCC0oNUaJEAztYOx ZvKjxsccxBMYy8GwRiN4C1ODerhgBv3b25VFHmLCS7Ci+v9q+3fDfQmP4JBZGwLm8eEH XJVufEHV/FF4TbXsJov5MmgJnHUHiwUUhSrIyNv3NAPy/brRk6lalWohDeZ9cQ+O4NXa 1CUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=jNTVM/O7zU2fP5GI+U15z42qqoqbtQhr3aGg2Ewk7Qk=; b=0PM5+Ifz0lrQLXlxorDNgx6rtkO9EcWwO0KPbUzseyuOLMSrmdZoTpyQKcMMR6Hkd2 TuyT2ZbZyEwNNBkPy3kj/1bUrW4LCZb449gRZy52+naF13e4j1Ri3z5opU+Mzk42UlSd TWFyOvM/M+WiD6zizK1WrGjrY5W71B4u0rw30iZFmToizp1dkSF3CA6YuETG0Vlzmojg 91rfWc977w83NpHuS6qi/wgq+tS8hHmGCOg5NzBkl2q9SyMLoTIItphf9KB7YzwB7loz GSNTRAEcOevhcKeZjkXha4e1r56Bdxew0bTCGzyjePL6At2+MbBR9YWbZnVR2Ak2QEJP suLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="E/7q0Hzh"; dkim=pass header.i=@linaro.org header.s=google header.b=YOpEo91O; spf=pass (google.com: domain of libc-alpha-return-105934-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105934-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w26si13086304edd.305.2019.10.14.13.58.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:58:34 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105934-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="E/7q0Hzh"; dkim=pass header.i=@linaro.org header.s=google header.b=YOpEo91O; spf=pass (google.com: domain of libc-alpha-return-105934-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105934-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=FnHTZbDOtiK0UB1AGhlEyNI3C4tYP1r TcSoDKBjlqlweL9K0QeIUSwvgT8F7eUS6Qp1WEXngsSNXbjJ6tfbx81q+6yBmAlL dMstGw9BdNk8lbjZj1RzB1EwcvsCEsj9osKjtXwTfCQgcJdDFy3Hqk3rfnWUkqjY DgOHPFnLKB9k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=iLEPHG+CilHtfQchvxX0lVb5wSA=; b=E/7q0 HzhX25kFCYna8mlV/taO0ayHlEVHnbE6aUFj3bo+YGI0Cyb4218PYyZqaXrj8LF9 hagMsh57VIAApOrfZmG8yFTIBlf8/B6v2yLYOceyoXcRLB7NK7f4kAUwWpRQThCy saF8jp/7EB/nAFhZ01JoET0qAZCRUZi5CSYm8E= Received: (qmail 114575 invoked by alias); 14 Oct 2019 20:57:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 114475 invoked by uid 89); 14 Oct 2019 20:57:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f196.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=jNTVM/O7zU2fP5GI+U15z42qqoqbtQhr3aGg2Ewk7Qk=; b=YOpEo91OvIRI3yfbxEMKVgRp33ZauSlnCFIfB0OJxY27S1bROTiPFTeKKxXO2rTzUG TIAr9Aw5TklhHOnAdD6Vti/3oGGKK4xyoe0kT2FrWY9rzu8OTmZYNxi/Q+A4m/owqLmc GcQ9Yxw43+WanJiiswncWRDPhfwz1Ur5EgSkgvT16uYA3wP7dgEf7m9ghMdO0HhcyV6f ThGGruIFCCXkyFyuEPTwRsB6Qh6E8EGtypFrH3+E95pzNiQbpG6rcH1m2Vo/iiIm1p3V 6NL2DzmbmidpTZb3TNGXDgyoemNGq7BQSMkOD8yiHfihbwkTy3KNMvte5PZh1Ee37N/1 XthA== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 08/21] nptl: aarch64: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:43 -0300 Message-Id: <20191014205656.29834-9-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the aarch64 modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked on aarch64-linux-gnu. --- .../unix/sysv/linux/aarch64/syscall_cancel.S | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/aarch64/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/aarch64/syscall_cancel.S b/sysdeps/unix/sysv/linux/aarch64/syscall_cancel.S new file mode 100644 index 0000000000..e105480bf3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/aarch64/syscall_cancel.S @@ -0,0 +1,61 @@ +/* Cancellable syscall wrapper. Linux/AArch64 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int [r0] __syscall_cancel_arch (int *cancelhandling [r0], + long int nr [r1], + long int arg1 [r2], + long int arg2 [r3], + long int arg3 [SP], + long int arg4 [SP+4], + long int arg5 [SP+8], + long int arg6 [SP+12]) */ + +ENTRY (__syscall_cancel_arch) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,%function +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + ldr w0, [x0] + tbnz w0, 2, 1f + + /* Issue a 6 argument syscall, the nr [x1] being the syscall + number. */ + mov x8, x1 + mov x0, x2 + mov x1, x3 + mov x2, x4 + mov x3, x5 + mov x4, x6 + mov x5, x7 + svc 0x0 + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,%function +__syscall_cancel_arch_end: + ret + +1: + b __syscall_do_cancel + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176344 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5012408ill; Mon, 14 Oct 2019 13:58:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuS7KoeMcN6O/Kls5iVBX13Dpp3ApE+Wd9fgTsYh4pS6ue50XBKrqiZ5b/deW03a56FnTW X-Received: by 2002:a17:907:365:: with SMTP id rs5mr31241075ejb.121.1571086725207; Mon, 14 Oct 2019 13:58:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086725; cv=none; d=google.com; s=arc-20160816; b=j8asF1AYe8uEIap/eFF8mKwwQRuR+tagY81tmPxNec49sKoijO/d754+tHnzs+s5ya rIjBLs1JHY1PzUymYRAIxCB5CML9qEnXUSL7HP6nWAH+MEV8zGupPaO9Zh6ztAbS737S ef306JBSH8DGToHqaBXiLeDfaIL9VEULP18Z+QG5/C4KNN/UCh7N0HQu2S3e6t3RTq1+ H9JMSCSR6ALhCbTAZ+ujORdvgJQnrO7TyyzIP68CSVFXNM6jAY6/eeg9GDGZnG72aMzj AFsij93CRDBh13FfaG4qff25OzSSSLlMRLG4aT4P+PFPflR/n8wWQHySm5KTdUBIpeHO uPLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=/Tn3fTfJlame1huFejUiVJMQG25cQhfChU4g4LwAzlU=; b=1AZlaztZHiW3c9/SHhpVkiOkcMeGswnIl4jQrWftWOyDL1m/XmAUDCq2izNF3RZRdC jbSqa0YNF1+tZOyvgqM26bVOmcpIRmUvpn9EAr81e9Dfr7LY9vDVgI9FIhhd3WZ/xxBD diOFk114wFiwvL9TVXDFAImrOLZrGYBurg8GVD5CV+Zdi9A8RyxoXa23+TjNaV1IQ24y nuchD44BWJU/DL1/TzFp5eheZey5WNgZPdrlR24KblxIpcPq4fVsNKlNNlpKKY82/Wq1 7+bFMmXX/iN/RtBF/oEUmOfDSOs31nZLgdaxNlC/eqpHQyCdg2xVMzgL7TwjjbFv3Dym 2Cug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=HmqbItlQ; dkim=pass header.i=@linaro.org header.s=google header.b=SrMBv3gV; spf=pass (google.com: domain of libc-alpha-return-105935-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105935-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r8si11035489ejr.33.2019.10.14.13.58.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:58:45 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105935-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=HmqbItlQ; dkim=pass header.i=@linaro.org header.s=google header.b=SrMBv3gV; spf=pass (google.com: domain of libc-alpha-return-105935-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105935-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=yAGcMCouwz7iNLaMhyek3epmjrO1WLd 3hIs07Jp9D9H1/XugMw5juMu5cXEbhPM1Puve2En4TBijSLws3lRBgNMdN5pSTzb O9M68E51nS0CsCbVNfJtpMfmZnwoKoz4tcqNPFltcVv3MN+NjqfrTaR0t598SK3H etdJ1IqbG4kE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=ujGsBnaEdryzxA63eX/GihdzNIs=; b=HmqbI tlQZzEQU+7Smp3zM+tZY/zxlHcpJ/FD/8mkhiO7rtK7A476AUjb7E7bHsct+r6kg zwzFAIeoWvWgTIlDJFz41FEs0ImbSfXYd+GRtskJkzRKBo6+j0C8QMSX4lK63O8D RV2nYgpQTx6GF6ExXRsDlpqSdzoRXepSNYWtsY= Received: (qmail 115109 invoked by alias); 14 Oct 2019 20:57:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 114726 invoked by uid 89); 14 Oct 2019 20:57:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:2845 X-HELO: mail-qt1-f196.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=/Tn3fTfJlame1huFejUiVJMQG25cQhfChU4g4LwAzlU=; b=SrMBv3gVgZXP4DMaqOGshnjfQXx78nPkvnPq3tLvmAVy3umcIPsJmgnNVoeX08WKfw J08rTITR+RZIc0of90SGPN9Qe3npylkz+p38hFdGDmpREZLbl05VenQHzWGveUJxaIW4 M+I8h518OllwL9bJ8VHwU0T7MA2E5fu2ikEHjsTVigqumKYalvzpJdjOThBbNAPfXUHP T+EaOnmHVWzlP0fVFKnZFcCfsNLAYaw7LGgO+1bfOxVZPzoo+VxKALXXQM+T6nII7Zd/ WYSgMMI1URUmLzZ7PKNAAmvofVCP90jeEkNSancaIrYognnS7TUvfc/AIIh1yCK5xyIl 7l4Q== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 09/21] nptl: arm: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:44 -0300 Message-Id: <20191014205656.29834-10-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the arm modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked on arm-linux-gnueabihf. --- sysdeps/unix/sysv/linux/arm/syscall_cancel.S | 80 ++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/arm/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/arm/syscall_cancel.S b/sysdeps/unix/sysv/linux/arm/syscall_cancel.S new file mode 100644 index 0000000000..996334a4bb --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/syscall_cancel.S @@ -0,0 +1,80 @@ +/* Cancellable syscall wrapper. Linux/arm version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int [r0] __syscall_cancel_arch (int *cancelhandling [r0], + long int nr [r1], + long int arg1 [r2], + long int arg2 [r3], + long int arg3 [SP], + long int arg4 [SP+4], + long int arg5 [SP+8], + long int arg6 [SP+12]) */ + + .syntax unified + +ENTRY (__syscall_cancel_arch) + .fnstart + mov ip, sp + stmfd sp!, {r4, r5, r6, r7, lr} + .save {r4, r5, r6, r7, lr} + + cfi_adjust_cfa_offset (20) + cfi_rel_offset (r4, 0) + cfi_rel_offset (r5, 4) + cfi_rel_offset (r6, 8) + cfi_rel_offset (r7, 12) + cfi_rel_offset (lr, 16) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,%function +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + ldr r0, [r0] + tst r0, #4 + bne 1f + + /* Issue a 6 argument syscall, the nr [r1] being the syscall + number. */ + mov r7, r1 + mov r0, r2 + mov r1, r3 + ldmfd ip, {r2, r3, r4, r5, r6} + svc 0x0 + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,%function +__syscall_cancel_arch_end: + ldmfd sp!, {r4, r5, r6, r7, lr} + cfi_adjust_cfa_offset (-20) + cfi_restore (r4) + cfi_restore (r5) + cfi_restore (r6) + cfi_restore (r7) + cfi_restore (lr) + BX (lr) + +1: + ldmfd sp!, {r4, r5, r6, r7, lr} + b __syscall_do_cancel + .fnend +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176346 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5012713ill; Mon, 14 Oct 2019 13:59:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7Pur/7UjQY2Eoku7lZ7f1+iAh4eaHqbqOHvRjqmUJTqDyrqaBRH9ttYm5VDd1yripiC4l X-Received: by 2002:a05:6402:b17:: with SMTP id bm23mr29727676edb.6.1571086750659; Mon, 14 Oct 2019 13:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086750; cv=none; d=google.com; s=arc-20160816; b=HtmHLCAeDJ/yBBJxBWuzGYoIiqtCka41gKDur4tanTyIFEW8/H8t2bIIRb3/5FjWns zwAh26zYYx6SrjQMCBvfvzf9t+0qQSCjnNTd9lsqNpohh4kkp0X+hkwF4bKKiXpo6tpH EQzQRk7N6wMfkPfcdTnJOB2HbSfj3xl/h1g9wc6C5ZfTzN1SXzyd/6C6RB63HIF1XiJ/ +7Nvz118RHZ9QOkD7M5SGLRBqSk0ETE6N+hDPW9cObkICoBWGwpRC4KqnCK3rJLRVM7h a6NAJe+CHim4fNwaNxrxn8++z6b+9XKDcGurKyvF879QK1oprScaFj70FQoteXBmA/Zq TJfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=L48C2S2cuH3wIpZN+1UP2+S+B1Xql7b/cQD2SyE3JK0=; b=M+mROM6agu102efyFSs8t3R2VbQxqNsl9T520ccvjtXVXuHwTmrl9ydktGXrVZq8VU 2EzJrwR9PmRgmNu4Q3wPQekIGhfohSiZGJOKVhqK2AehJ8OPOWorhfzrBHeTStfWvir7 Q5RUlwFx+gpuBqptTa2tfLCwui3tIA+HzHfMEKxk9BwAMGcEciniJbfbBE80JpyTFf7V oNdkx2Urb6IDP8r7PBj7kcMrayapvrqYE0+iFaH75548N3C2qiY4A9DW+WF/0ghlw/CK 93LwWdmnjdIVa3hPeE66YB/AALmIrcDwSNie5x+8v9WVyxvSyl0ViGidF/ES8KwTHUwo yIwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Du7aaz20; dkim=pass header.i=@linaro.org header.s=google header.b="X4+f/XVK"; spf=pass (google.com: domain of libc-alpha-return-105937-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105937-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ca9si12241572edb.79.2019.10.14.13.59.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:59:10 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105937-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Du7aaz20; dkim=pass header.i=@linaro.org header.s=google header.b="X4+f/XVK"; spf=pass (google.com: domain of libc-alpha-return-105937-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105937-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=S3loXNZh8ys4bn0NA8WUg+d5WjvGEhE BBJe2GyHZ0n6tbC87WJcRQ9qilmVUg7pnIic+WOXJLzDZLT4sE4D5VLspRmO2cyw RzttvrgrYkTOlRIkCJxkbUekscxGG1Jc/lYk/ymMsU3yRRTcr7vxVo44fzyT4gsE Af4p8LC0ePRc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=yuaDoSlaZ4g6u0rPGEIL9PtYHw8=; b=Du7aa z20rwsC9eUvBckbPsCHx0z3zvXQDg5OepWV9XkFVTPaRlgQaAzPefpjEvriJh3sr pAzsFB3+/HGekWAK+W+oEtHonMZrdHFQ5u3YB9dw77G7+yU4b60cRvUQO3Ry4zmd OqakNQlITwkMCR/8LQGVpYERpzO+jt/q4nOOTI= Received: (qmail 115169 invoked by alias); 14 Oct 2019 20:57:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 114986 invoked by uid 89); 14 Oct 2019 20:57:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f177.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=L48C2S2cuH3wIpZN+1UP2+S+B1Xql7b/cQD2SyE3JK0=; b=X4+f/XVKLcWTph1unW2Tk2Ggknaj6NXdsUjivcstuHsJ/bljbG/jNp/DIEJn1JehbA ki6i0OdVNKtmxzNTnq3ktlS8M0YMyr2Ar9vrU8VM2+1YEB/czePsbJHzQ/yhbxRB2k8+ sxBJhwbEuWbcbleB11kjAJkYpy1PrygyTzRQ2E8frKF/RFlJvZYClNTeUFmcA+LnxujH Hu9TNzQ241cGMio4QBlshK7mmV8GMEfNUAqSPrq/x88rhxNGQPZZR5ZyXNAcSbT+IHE4 DuFOp8OV6pYU3wAiALuEEj9zR2I0reocqhk7JM00e2P1EsRkpTFw1NLhLid/MrOQf1KC Qa7w== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 10/21] nptl: powerpc: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:45 -0300 Message-Id: <20191014205656.29834-11-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the powerpc modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked on powerpc64le-linux-gnu, powerpc64-linux-gnu and powerpc-linux-gnu. --- sysdeps/powerpc/powerpc32/sysdep.h | 3 + sysdeps/powerpc/powerpc64/sysdep.h | 19 ++++++ .../unix/sysv/linux/powerpc/syscall_cancel.S | 67 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/powerpc/powerpc32/sysdep.h b/sysdeps/powerpc/powerpc32/sysdep.h index c21ea87f5a..689a708740 100644 --- a/sysdeps/powerpc/powerpc32/sysdep.h +++ b/sysdeps/powerpc/powerpc32/sysdep.h @@ -101,6 +101,9 @@ GOT_LABEL: ; \ # define JUMPTARGET(name) name #endif +#define TAIL_CALL_NO_RETURN(__func) \ + b __func@local + #if defined SHARED && defined PIC && !defined NO_HIDDEN # undef HIDDEN_JUMPTARGET # define HIDDEN_JUMPTARGET(name) __GI_##name##@local diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h index db273f3346..fb6ede3e87 100644 --- a/sysdeps/powerpc/powerpc64/sysdep.h +++ b/sysdeps/powerpc/powerpc64/sysdep.h @@ -276,6 +276,25 @@ LT_LABELSUFFIX(name,_name_end): ; \ ENTRY (name); \ DO_CALL (SYS_ify (syscall_name)) +#ifdef SHARED +# define TAIL_CALL_NO_RETURN(__func) \ + b JUMPTARGET(__func) +#else +# define TAIL_CALL_NO_RETURN(__func) \ + .ifdef .Local ## __func; \ + b .Local ## __func; \ + .else; \ +.Local ## __func: \ + mflr 0; \ + std 0,FRAME_LR_SAVE(1); \ + stdu 1,-FRAME_MIN_SIZE(1); \ + cfi_adjust_cfa_offset(FRAME_MIN_SIZE); \ + cfi_offset(lr,FRAME_LR_SAVE); \ + bl JUMPTARGET(__func); \ + nop; \ + .endif +#endif + #ifdef SHARED #define TAIL_CALL_SYSCALL_ERROR \ b JUMPTARGET(__syscall_error) diff --git a/sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S b/sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S new file mode 100644 index 0000000000..66d601da2a --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S @@ -0,0 +1,67 @@ +/* Cancellable syscall wrapper. Linux/powerpc version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int [r3] __syscall_cancel_arch (int *cancelhandling [r3], + long int nr [r4], + long int arg1 [r5], + long int arg2 [r6], + long int arg3 [r7], + long int arg4 [r8], + long int arg5 [r9], + long int arg6 [r10]) */ + +ENTRY (__syscall_cancel_arch) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + lwz r0,0(r3) + andi. r0,r0,0x4 + bne- 1f + + /* Issue a 6 argument syscall, the nr [r4] being the syscall + number. */ + mr r0,r4 + mr r3,r5 + mr r4,r6 + mr r5,r7 + mr r6,r8 + mr r7,r9 + mr r8,r10 + sc + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + + bnslr+ + neg r3,r3 + blr + + /* Although the __syscall_do_cancel do not return, we need to stack + being set correctly for unwind. */ +1: + TAIL_CALL_NO_RETURN (__syscall_do_cancel) + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176347 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5012881ill; Mon, 14 Oct 2019 13:59:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgk22KU4Kc2Bui3e5hUWAnS7s52nVvUb7JCwzCOqFQPRKHXo6GX17XygWVyPksbOVByClB X-Received: by 2002:a17:906:940a:: with SMTP id q10mr31002747ejx.250.1571086762848; Mon, 14 Oct 2019 13:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086762; cv=none; d=google.com; s=arc-20160816; b=Hxu5fyw9SJwz92bxezVsZwD3MXBzYnZmytg55cpxQJ2pSaquDwlFLL0Zbuw1nl0FQL g5ZBTHxhXGxHNkxCirXgWye13m8Fjwm+oXxtuQQo+Sf8oMqZsr7icZaXponp0WjNCcJ2 skqaWyHFMoEHjefVIPWn4ZfjFk+WW9rQqDXJ92EYFLHC/MveEf5zkxKZPF7tPKN8HDkV IhWUqj/1Tn7ZH4abnnfOo5lRi531q1gRY0qwdIdbPxvbtYMNrKdZ91KWzMqoLoJBRYwN +E4Lrsh0GrWeRvCcGk04QkW8Zhw2eLXploJt4SGHgnFOrZmlTB6YzhOSL1I9Y87Q9MSr 7rQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=Wyh4qaSsn8l6HL2qXTK9ltVxaZVr95Wf8WMGcX6oqk0=; b=HW8+0TDj781bBDImKHaD1l/qYvdEwEY1a7UrjrioZG537IlJeza5qPgFs0+WRMNhHj ZOBmyP5LR8IEN1bEyfMCHlHFpCtNxS/jWHennFOtDhDSPn9jvEZqcqcTA5Lf9Q6Uuu+B bhSOPfith8yGCcIVVf6bTC6uLmYdz6eTVS2eAcdrWv2tAg8OZq2hsIl6RtbSHNU4WqqU dTaZl1gcofleAyEh58Qiu7CatSbtHV026bmtjGyHuwu5E+3ot5MISdNQeDZG++PGRJwS mr7NG0ld6270bGh9Md230jcX4uQ1MA6mg/jo5cbKTJV6AI3u4q1l3qP0s6EnX7jkWX/U cNMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=qEQRppoC; dkim=pass header.i=@linaro.org header.s=google header.b=ym4qSSnb; spf=pass (google.com: domain of libc-alpha-return-105938-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105938-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b33si14184137edc.265.2019.10.14.13.59.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:59:22 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105938-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=qEQRppoC; dkim=pass header.i=@linaro.org header.s=google header.b=ym4qSSnb; spf=pass (google.com: domain of libc-alpha-return-105938-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105938-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=OcRcd96r4RQQH4YNv7aJ08roYdBsPxK FJuguNltQgdwz0XNj6niZLIvEN4bdAwYxH7xI+Vh03xqFoAY5C8A+g0xPMnpJlNf QO2sD6x8OLYRZvrzg+n2MnSUxQrobaP+eQnUuum9EJEx2taEYDKGDZnl9OS4GU8y MRRc1tmnDCYA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=eQHio1dSDcbuKNt6JfbBQRtifA4=; b=qEQRp poCyYK9Rf09r8Kvrqh9x5HNwZobn+oQ9DhG53TT8u8tFo3KNBZC8A2t9rJqXMJd9 +X29G57gjj28hzCZoCd+8juZWaHRrJZ0tDxoAHNvAntQ4/zCJPH3rdFYZi7LYuMg nWiNWbpBJ3gP/ajCTtYV8BlzXSHwq2L1qoxLU8= Received: (qmail 115242 invoked by alias); 14 Oct 2019 20:57:26 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 115039 invoked by uid 89); 14 Oct 2019 20:57:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f169.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=Wyh4qaSsn8l6HL2qXTK9ltVxaZVr95Wf8WMGcX6oqk0=; b=ym4qSSnbvYVx+lY82ykS941IjsM0VLOSAroiyDENnT9dMWtWoTkgZO2fnVsPKwOZXT he6Hbw8h5+8lFv5s1LrE7UBXHTFGv35d4foW8d8uvVY2PTjFfHUK6k0XjR0MtKYZnITU yzuL7dZbWpjF3JwpLeSKTgiYD69sYVAu3TFBcgT0WRKAJhSs243g3J+5N4r0ULTTcpes AWzI3CW4Sw8Idkw9s8YHdv7my9CzGil3LLYLQP44ixv19+YQuxOvoxOH/HY2ADLo+pSj vsKl9FTou9Y5HQDDtUDrnQxqhIrURTpf0ryVQsueo4wmmc8rhuMrd0jMqYFSEVGmIdb+ 8fFg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 11/21] nptl: microblaze: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:46 -0300 Message-Id: <20191014205656.29834-12-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the microblaze modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked against a build and make check run-built-tests=no for microblaze-linux-gnu. --- .../sysv/linux/microblaze/syscall_cancel.S | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S b/sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S new file mode 100644 index 0000000000..19f566ba61 --- /dev/null +++ b/sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S @@ -0,0 +1,64 @@ +/* Cancellable syscall wrapper. Linux/microblaze version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + long int nr, + long int arg1, + long int arg2, + long int arg3, + long int arg4, + long int arg5, + long int arg6) */ + +ENTRY (__syscall_cancel_arch) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start, @function +__syscall_cancel_arch_start: + + lwi r3,r5,0 + andi r3,r3,4 #and1 + bneid r3,1f + addk r12,r6,r0 + + addk r5,r7,r0 + addk r6,r8,r0 + addk r7,r9,r0 + addk r8,r10,r0 + lwi r9,r1,56 + lwi r10,r1,60 + brki r14,8 + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end, @function +__syscall_cancel_arch_end: + + nop + lwi r15,r1,0 + rtsd r15,8 + addik r1,r1,28 + +1: + brlid r15, __syscall_do_cancel + nop + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) + From patchwork Mon Oct 14 20:56:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176349 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5013225ill; Mon, 14 Oct 2019 13:59:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdVzhSKTtJAfF41Dw/TpZXiYQ/FGoBjWK4YGK4xYuEWE8Gl4i5d1NXSkfdE44bHKHnrO5H X-Received: by 2002:a17:906:8317:: with SMTP id j23mr30088992ejx.314.1571086784861; Mon, 14 Oct 2019 13:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086784; cv=none; d=google.com; s=arc-20160816; b=Fy7u1WudEYLFPP0kFcA8SqmjmHATHnYEBPWA2hNjACctz3feIYaqdCB4zu36WCsIjK wDwGnG+oyij6w1u4/JTj72verlfYCyKM61Fh1d0xnT8J3mrho4IKB71jouiBrhOO6bHW MjU3FS2FA9K6zXr10IJ5ceMn+co/igWoNBytEGDLqzzuE/v084tYUBFtxJfe+kwEdoLD qAw/AguQFO3clJrrUMWzBxvdq3v90GHyDjfmklpFW1gLDFdrnIw64mTw3ZFtrC+vqAEz 5GNztTF/zac+NgNDEi0ThX5rg6b2fMVQZhCtkPSzQYFLdVs7MkhcyxGVverP92BeWVww t+pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=tY2t0NansyhpvoCU4gDj1rc28nqlOMKFhMruZ7AQUMk=; b=RPaJY8r+ar//9D5TC15Vv135kLzdXLX7J3UrvRCd5C5CTrYoitdkTeGTuu93v2MAmL eIp69ozN0iJQX7X1tq+DR9be7FROm3vAU+GAQd3hxrye9fhOVAB+b8ZG0S1cExJK53hW RTrU0pXd3Xy4p9bITM/BY1qojytt53HHFN4pqXdTecan6YqdOpQalNO4yQBQAE7bnnGy SO55EaUfMOtIl0JsFNpePkWUMypocXWuW7IBR19YHXfGTSbVaxNOnb70YjkVkXWXBowl wKDkHhzstEjrnaBPDGwo1/n4MyzLrzwyaFTEFVUcDSCd1zDw9WQ9EDjdgwmLXgwi8yuQ H6HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=WHIUbWyH; dkim=pass header.i=@linaro.org header.s=google header.b=fPw2cLgq; spf=pass (google.com: domain of libc-alpha-return-105940-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105940-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l23si12061796edr.187.2019.10.14.13.59.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:59:44 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105940-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=WHIUbWyH; dkim=pass header.i=@linaro.org header.s=google header.b=fPw2cLgq; spf=pass (google.com: domain of libc-alpha-return-105940-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105940-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=GCrOdl+FS4Bt+w9QnMW/hpE57UCXv/z PsWCnMP4lJIXBjwVb5+XP8Og5ILmVk4SzoAThjKQGqhmJg8UkSPTxmKYrU+bQ5UY M94PtaG9aS5eC/s+q9oCoX3hgwIv7DRKkwGdwSRq01PFLQJeOlGtZrw7StIJ2vgC zhlx+PgF5GFA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=u12Q6eo5D4o5V3aEm91seDtuF88=; b=WHIUb WyHLmXQ+M9SRDlhFuaV/Yq2WRoF4AHJ2euQgBtXL2/RZ0IWgtOtrQGIufIISDAU3 +A5T3qIMG9UghnqnBuJshlJN7TI83nN0Id68UL7hDhnydikk2DFnfVPcnJWvGpF8 VDAy0AiWJyVGlIS+Qu22xckV5OF2XkwB22MS1g= Received: (qmail 116210 invoked by alias); 14 Oct 2019 20:57:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 115484 invoked by uid 89); 14 Oct 2019 20:57:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f193.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=tY2t0NansyhpvoCU4gDj1rc28nqlOMKFhMruZ7AQUMk=; b=fPw2cLgqEQgAoxmWiptkP9OhpD6A/IsHnwRIgpK24+VIMNpKdmHpSyXsnJFS5DrMJV /rl41hjilcXuvxzEvRNbRE5bchRkHdfSvun9cAtaYYepinzn3CuJ/A0kO0yuPbgKSNan hWNjoaguC+YoTgOCPFspjksurR1mG2tD+PS6hVetxIfss7fhflgRL9QgOQ85qt9CGKtk jihDjJaE8q3G3c95ySnxlHnlx7qxL0bfLv82BDpXIRvQkT0q65+zTGX1Dht6sC6P0duf LkF+tILCHCZ+Rnh7Rlz5Wa4BGHls8uj7o1FIv0hWF2ItxA8E37haMLmqM5CnMbf8m87Q 0jrA== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 12/21] nptl: sparc: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:47 -0300 Message-Id: <20191014205656.29834-13-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the sparc modifications required for the BZ#12683 fix. Different than other architectures, SPARC passes the sigcontext_t struct pointer as third argument in the signal handler set with SA_SIGINFO (some info at [1]) for 64 bits and the pt_regs in 32 bits. >From Linux code: * arch/sparc/kernel/signal_64.c 428 /* 3. signal handler back-trampoline and parameters */ 429 regs->u_regs[UREG_FP] = ((unsigned long) sf) - STACK_BIAS; 430 regs->u_regs[UREG_I0] = ksig->sig; 431 regs->u_regs[UREG_I1] = (unsigned long) &sf->info; 432 433 /* The sigcontext is passed in this way because of how it 434 * is defined in GLIBC's /usr/include/bits/sigcontext.h 435 * for sparc64. It includes the 128 bytes of siginfo_t. 436 */ 437 regs->u_regs[UREG_I2] = (unsigned long) &sf->info; * arch/sparc/kernel/signal_32.c: 392 regs->u_regs[UREG_FP] = (unsigned long) sf; 393 regs->u_regs[UREG_I0] = ksig->sig; 394 regs->u_regs[UREG_I1] = (unsigned long) &sf->info; 395 regs->u_regs[UREG_I2] = (unsigned long) &sf->regs; 396 397 regs->pc = (unsigned long) ksig->ka.sa.sa_handler; 398 regs->npc = (regs->pc + 4); So it requires an arch-specific ucontext_add_cancel. Also on sparc interrupted pause syscall returns with a PC indicating a side-effect and this deviates from other architectures. The sparc64 pause fall back to ppool syscall. Checked on sparc64-linux-gnu and sparcv9-linux-gnu. [1] https://www.spinics.net/lists/sparclinux/msg05037.html --- .../sysv/linux/sparc/cancellation-sigmask.h | 39 ++++++++++ .../sysv/linux/sparc/sparc32/syscall_cancel.S | 76 ++++++++++++++++++ sysdeps/unix/sysv/linux/sparc/sparc64/pause.c | 25 ++++++ .../sysv/linux/sparc/sparc64/syscall_cancel.S | 77 +++++++++++++++++++ 4 files changed, 217 insertions(+) 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 -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/sparc/cancellation-sigmask.h b/sysdeps/unix/sysv/linux/sparc/cancellation-sigmask.h new file mode 100644 index 0000000000..6fd889b1cc --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/cancellation-sigmask.h @@ -0,0 +1,39 @@ +/* Architecture specific bits for cancellation handling. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _NPTL_CANCELLATION_SIGMASK_H +#define _NPTL_CANCELLATION_SIGMASK_H 1 + +/* Add the SIGCANCEL signal on sigmask set at the ucontext CTX obtained from + the sigaction handler. */ +static void +ucontext_add_cancel (void *ctx) +{ + sigset_t *set; +#ifdef __arch64__ + struct pt_regs *regs = (struct pt_regs*) ((siginfo_t *)(ctx) + 1); + __siginfo_fpu_t *f = (__siginfo_fpu_t *)(regs + 1); + set = (sigset_t *) ((stack_t *)(f + 1) + 1); +#else + struct pt_regs32 *ptregs = (struct pt_regs32 *) (ctx); + set = (sigset_t *) (ptregs + 1); +#endif + __sigaddset (set, SIGCANCEL); +} + +#endif diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S b/sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S new file mode 100644 index 0000000000..7c86dee33c --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S @@ -0,0 +1,76 @@ +/* Cancellable syscall wrapper. Linux/sparc32 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + long int nr, + long int arg1, + long int arg2, + long int arg3, + long int arg4, + long int arg5, + long int arg6) */ + +ENTRY (__syscall_cancel_arch) + save %sp, -96, %sp + + cfi_window_save + cfi_register (%o7, %i7) + cfi_def_cfa_register (%fp) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start, @function +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + ld [%i0], %g2 + andcc %g2, 4, %g0 + bne,pn %icc, 2f + + /* Issue a 6 argument syscall. */ + mov %i2, %o0 + mov %i3, %o1 + ld [%fp+92], %o4 + mov %i4, %o2 + mov %i5, %o3 + ld [%fp+96], %o5 + mov %i1, %g1 + ta 0x10 + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end, @function +__syscall_cancel_arch_end: + bcc 1f + mov 0, %g1 + sub %g0, %o0, %o0 + mov 1, %g1 + +1: + mov %o0, %i0 + return %i7+8 + nop + +2: + call __syscall_do_cancel, 0 + nop + nop + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/pause.c b/sysdeps/unix/sysv/linux/sparc/sparc64/pause.c new file mode 100644 index 0000000000..4a0cf4db59 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/pause.c @@ -0,0 +1,25 @@ +/* Linux pause syscall implementation. Linux/sparc64. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* On sparc interrupted pause syscall returns with a PC indicating a + side-effect and this deviates from other architectures. Fall back to + ppool implementation. */ +#undef __NR_pause +#include diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/syscall_cancel.S b/sysdeps/unix/sysv/linux/sparc/sparc64/syscall_cancel.S new file mode 100644 index 0000000000..8a6d5a2fd8 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/syscall_cancel.S @@ -0,0 +1,77 @@ +/* Cancellable syscall wrapper. Linux/sparc64 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + + .register %g2, #scratch + +/* long int __syscall_cancel_arch (int *cancelhandling, + long int nr, + long int arg1, + long int arg2, + long int arg3, + long int arg4, + long int arg5, + long int arg6) */ + +ENTRY (__syscall_cancel_arch) + save %sp, -176, %sp + cfi_window_save + cfi_def_cfa_register (%fp) + cfi_register (%o7, %i7) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start, @function +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + lduw [%i0], %g2 + andcc %g2, 4, %g0 + bne,pn %xcc, 2f + + /* Issue a 6 argument syscall. */ + mov %i2, %o0 + mov %i3, %o1 + mov %i4, %o2 + mov %i5, %o3 + ldx [%fp + STACK_BIAS + 176], %o4 + ldx [%fp + STACK_BIAS + 184], %o5 + mov %i1, %g1 + ta 0x6d + + .global __syscall_cancel_arch_end + .type __syscall_cancel_arch_end, @function +__syscall_cancel_arch_end: + + bcc,pt %xcc, 1f + mov 0, %g1 + sub %g0, %o0, %o0 + mov 1, %g1 +1: + mov %o0, %i0 + return %i7+8 + nop + +2: + call __syscall_do_cancel, 0 + nop + nop + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176348 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5013037ill; Mon, 14 Oct 2019 13:59:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqylMdBNnWTGyhGWKk0beEdHw59Ae2VP2XUJK/WfPdTcveQKArD57jiz3qMWIxRNTGLm856j X-Received: by 2002:a17:906:fca8:: with SMTP id qw8mr31428968ejb.188.1571086773121; Mon, 14 Oct 2019 13:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086773; cv=none; d=google.com; s=arc-20160816; b=Zq1zzamYxD6Of10SW2hZ3yLkJ+yLRzBYZQg1oZhm2Tm/yrQx5uy/HLsMmQEIXdSjvQ 5TJpfFz7TZOjlrj85is/jQglr+C/KvmgospwYo/CW8/aQw5+hRf2GA+LYCJ6eYFgO3nn x/3ux9gAY5x2MvMcbUkRY0muAOKnwJfGoaEj/kTwdOq80pHr1r/sQvcjET1PsWgir+WQ JrnB59DGpkQkfwnGDNS6nDTTtrOnQdlPGziMzjNDK4VRpSd6Omn8Gd2UpAS0qRpEeZCs RoSET3qFakJPAcRz2m8dAfoQXUHB01M6D6YhDJLKr4bYn4dTVWkS8vgTfXi1A0XKAYdo 5S6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=VbF2lTSkRZUsCBxbqkjFrl2/tacZhv5Fk1UMoJNzKVo=; b=co7dgRvPyMYOZTkukAgN+iHiwAXtumXIFOnvy6F5vFJCZfhJcECF586QOsHjZRke2Q PJPVG9g0hg3OLZQMeJb4yzAJPR281/FZHLBg4cnc89OqmxCAjx0AEr2wJpj73V9nej5n F2N9EMdCZX47v1FiH96cIMZD/notYzCbbGpgZhswBA6tNn5SpfzimfOjWaqfQcImz9JL Q8tEvOu/fHaK6ajPkD6eh5ZKjjoJ/JCDbse+nmU01hdaFIvh6sUe/9p5fm7V04XBAtm1 EZ9J4BOLeCql/Wf1JJl2tEJhqM/PWOQ9aYvAi/nQ+IlohYzVXuShDPGcx064aY5HqALB 35Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ysP4XyKL; dkim=pass header.i=@linaro.org header.s=google header.b=wIf8tnGG; spf=pass (google.com: domain of libc-alpha-return-105939-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105939-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g25si11504966eds.210.2019.10.14.13.59.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:59:33 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105939-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ysP4XyKL; dkim=pass header.i=@linaro.org header.s=google header.b=wIf8tnGG; spf=pass (google.com: domain of libc-alpha-return-105939-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105939-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=exf75ep5pr1f7PwPhVWyuZxByEpto5d rP4SOATr/jn8m7ar+A4jERZBbqeqHq91IA1Q8/S2pMk+lKmQ7r8zWCB/tjwF9IFt 3yH7dY/BPM3b+kJKGsCRTVTMZOwWvYnEisK2Sxe2yKx8rncHJmnm6HWGtclt7dlz zNOXif11m/VQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=XbAAgfXDn9PYmE7IqOm9jJVAYhI=; b=ysP4X yKLxiW9CVAYSz7gH5ba3ATKY3uh29eOVy4TJVbj5MW4RBNipxsem2oHkBPBx2L1e 21Ep2G/yqa2VaLxJyYpmERNSpHf2+KfXBHVt/RbFcEeQbiUhvkpQ2myCccbzGIxE IaYho2raz/BSr0Xm5nUN0GKkjKHylVYGrjKteQ= Received: (qmail 116177 invoked by alias); 14 Oct 2019 20:57:32 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 115445 invoked by uid 89); 14 Oct 2019 20:57:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Received:74b X-HELO: mail-qk1-f181.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=VbF2lTSkRZUsCBxbqkjFrl2/tacZhv5Fk1UMoJNzKVo=; b=wIf8tnGGNFkNkZSNbjaSj73ux+S6q3ymk+W+y1DClM5fiQ1mPPkNccC6YYWnzCnjNj tirXHWAsaB3Z9NKeAKtsTHQyu4RhODiyC3YsypVbED8/DvJdLNvBp/IlqK4Sw13mUdvT BZqutT/fosJcK2FJaNuCf7iTDQ7UOj/Ay3g9vycN2SsPY8horauUebP/Yq1DGRTE01ca uSby09F+ENw8LRtZpqUbatgyCxpzxO+8W9BW22vwblxAr2RoWO72/AbDDxOe8MEzL28Q O7qTf5SfxdX4D2lzKvvqYFTIGkDzqbNs0gHE/2/0meQ2psIkQGoyRuS4CUEMdETzdxpJ esqw== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 13/21] nptl: hppa: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:48 -0300 Message-Id: <20191014205656.29834-14-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the hppa modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked on hppa-linux-gnu. --- sysdeps/unix/sysv/linux/hppa/syscall_cancel.S | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/hppa/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/hppa/syscall_cancel.S b/sysdeps/unix/sysv/linux/hppa/syscall_cancel.S new file mode 100644 index 0000000000..14e1f5f0a7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/hppa/syscall_cancel.S @@ -0,0 +1,82 @@ +/* Cancellable syscall wrapper. Linux/hppa version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + long int nr, + long int arg1, + long int arg2, + long int arg3, + long int arg4, + long int arg5, + long int arg6) */ + + .text +ENTRY(__syscall_cancel_arch) + stw %r2,-20(%r30) + ldo 128(%r30),%r30 + cfi_def_cfa_offset (-128) + cfi_offset (2, -20) + ldw -180(%r30),%r28 + copy %r24,%r31 + stw %r28,-104(%r30) + ldw -184(%r30),%r28 + stw %r28,-108(%r30) + ldw -188(%r30),%r28 + stw %r28,-112(%r30) + ldw -192(%r30),%r28 + stw %r4,-100(%r30) + stw %r28,-116(%r30) + copy %r25,%r28 + copy %r23,%r25 + stw %r19,-32(%r30) + cfi_offset (4, 28) + + .global __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + + ldw 0(%r26),%r20 + stw %r20,-120(%r30) + ldw -120(%r30),%r20 + bb,< %r20,29,1f + ldw -116(%r30),%r21 + ldw -112(%r30),%r22 + copy %r31,%r26 + ldw -108(%r30),%r23 + ldw -104(%r30),%r24 + copy %r19, %r4 + ble 0x100(%sr2, %r0) + + .global __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + + copy %r28, %r20 + copy %r4, %r19 + ldw -148(%r30),%r2 + ldw -100(%r30),%r4 + bv %r0(%r2) + ldo -128(%r30),%r30 +1: + bl __syscall_do_cancel,%r2 + nop + nop +END(__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176350 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5013371ill; Mon, 14 Oct 2019 13:59:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBFdVzbF86J8mCZDAjUni3RwbjCZ2uK6b/aQmYiXRaFLiAB2gJiLjwm1gFU6Ly7bJDSYFT X-Received: by 2002:a17:906:e090:: with SMTP id gh16mr30947255ejb.56.1571086794384; Mon, 14 Oct 2019 13:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086794; cv=none; d=google.com; s=arc-20160816; b=S7KLQ+R0cl2vMLCzOEi9bDDeZVcFrfSXw1/xJZlPp6dCt1Lwa/A7yxsTAKa9PoC+CX D4wvw45mCu4XqXuVI3mgsNDzTaMsFxI8ABK/+dnH8CC2HlUWmvK42CPOQsx6XzdZOBsB NNjq1tMrMZQi1UbTMVgjT7Uz7rp+vcWKraq4rwOL7b708g4yakAXTi86NRgXeNs9sU29 62DLK47H26ef6kLCGpuhulVBf1u8AZREFqv7NTiJYn77nCf/XddNrrLfYmn2SinzpBs4 qm2tjTrmG4ICXJ2KVSwC3rnzVgEZ4xy+j/NtfsyTHJlw2C0yzRd0Yp3so/TaJI/IBXI/ Z2eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=L77Ho6IP4TXZCDpPZteqxSHdOU+gdUV6IzPfV6zOrPE=; b=P6qXdhQO0gqLEeaufYxyoOJdN1R7Y/M2xoGBXsXg/Sg8CosZ9R0b50+JvhsEVvxNnN ir0inHNmTo3XLHXBW/ypW28cePNCK3EjHd8CSne413f7lYRY4YBhSmXR/L+h3bFtQ8za 5a8rEDGJJPFNLIeICcZ1w/zTryTKY2KVXiBHEmx1TFjNZ+ZC2W3E6PeZsGGlSozcvHeQ fzTeqiszJZQe8gqqUDUZpMP7HVtyLWlPDXFEZuMxkWBscs0oL82YlHTV5CbXGPR3SwOB NE5O4M4oKcqGn6QJFErTHr1dqCueDwLNkL5JDiGn5ao9wUBEk36RUaEr3M/lXOWVQhlu djdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=GwvGbOnN; dkim=pass header.i=@linaro.org header.s=google header.b=V2H9HmHM; spf=pass (google.com: domain of libc-alpha-return-105941-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105941-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e50si15050371edb.177.2019.10.14.13.59.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:59:54 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105941-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=GwvGbOnN; dkim=pass header.i=@linaro.org header.s=google header.b=V2H9HmHM; spf=pass (google.com: domain of libc-alpha-return-105941-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105941-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=iIK8MVN5Y1bhinjl1Q17td95LbZQjYi 9TEhxlTc3c7QGFJbhXjoVFHVsnQ3KgIwABzACLUUgHmoXiaA1Dnc18z1qL5LQJJW GlMKAvP2CznRqD1d+pQG4WSZOL27dbnr+nYkxQTvE97jt+YHLlsO6r/o94Bt0Ebx h4RaoDLNcOVo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=7uNmeDJxUxJqOdUbDY/TiM+BbMs=; b=GwvGb OnNcBkrlQyQeTHdNqzR7SOYCoPPGlZXabNhK9SKJOmzeylRIRgvmS30irgQoEVws exS/tmsLOnjn7/lTsjH9tyPfh/b0d0v2Krda/H5xr5jh5nh2V6lMTWJAtG+uUHUT HvzhFy5kw8ILMXhwlT1LvL+8wpABzNqeq2VN90= Received: (qmail 116304 invoked by alias); 14 Oct 2019 20:57:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 115809 invoked by uid 89); 14 Oct 2019 20:57:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=L77Ho6IP4TXZCDpPZteqxSHdOU+gdUV6IzPfV6zOrPE=; b=V2H9HmHMBdX6cwkrOckt2NBvoKDk3Licpixe2mf8BRqzSaA3XWFtkyz71cjvjXIE1h LDUZhIgcLJCOHAila4jZWeZ7sMmH3unICL+tCi0Tw16nkq9j89/Wb0EGtFfpXtGNKStF 2fJAb2+nWu7g3NSUg2zGGbnD3VEP9DDiVXJ4bgLqdxPd902rJ8+FyTXN+9uSEcNWhWL7 3SbaFKTMnv8f2oSpj/7Kfzsye7BuRLCrwNDb5sAF19JCQD7H8bzcluVJpQHTI0SVZYrH THF0dfdR1db4+1prZ1GUajaD5So1oZex5egf59eqDibg3kUsK0PjSFNIaAz7hi/HZFco OV5A== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 14/21] nptl: m68k: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:49 -0300 Message-Id: <20191014205656.29834-15-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the hppa modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked on m68k-linux-gnu. --- sysdeps/unix/sysv/linux/m68k/syscall_cancel.S | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/m68k/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/m68k/syscall_cancel.S b/sysdeps/unix/sysv/linux/m68k/syscall_cancel.S new file mode 100644 index 0000000000..4e5223ee7b --- /dev/null +++ b/sysdeps/unix/sysv/linux/m68k/syscall_cancel.S @@ -0,0 +1,87 @@ +/* Cancellable syscall wrapper. Linux/m68k version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + __syscall_arg_t nr, + __syscall_arg_t arg1, + __syscall_arg_t arg2, + __syscall_arg_t arg3, + __syscall_arg_t arg4, + __syscall_arg_t arg5, + __syscall_arg_t arg6, + __syscall_arg_t arg7) */ + + +ENTRY (__syscall_cancel_arch) +#ifdef __mcoldfire__ + lea (-16,%sp),%sp + movem.l #60,(%sp) +#else + movem.l #15360,-(%sp) +#endif + cfi_def_cfa_offset (20) + cfi_offset (2, -20) + cfi_offset (3, -16) + cfi_offset (4, -12) + cfi_offset (5, -8) + + .global __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,%function +__syscall_cancel_arch_start: + + move.l 20(%sp),%a0 + move.l (%a0),%d0 +#ifdef __mcoldfire__ + move.w %d0,%ccr + jeq 1f +#else + btst #2,%d0 + jne 1f +#endif + + move.l 48(%sp),%a0 + move.l 44(%sp),%d5 + move.l 40(%sp),%d4 + move.l 36(%sp),%d3 + move.l 32(%sp),%d2 + move.l 28(%sp),%d1 + move.l 24(%sp),%d0 + trap #0 + + .global __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,%function +__syscall_cancel_arch_end: + +#ifdef __mcoldfire__ + movem.l (%sp),#60 + lea (16,%sp),%sp +#else + movem.l (%sp)+,#60 +#endif + rts + +1: +#ifdef PIC + bsr.l __syscall_do_cancel +#else + jsr __syscall_do_cancel +#endif +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176351 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5013519ill; Mon, 14 Oct 2019 14:00:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwv50IYr2c3mnYNTOcf3REcKNtIcRNIF128DTU6siSLBF4uE8HnuM+tduqfBlUgbUHFJbKd X-Received: by 2002:a05:6402:1686:: with SMTP id a6mr3051242edv.174.1571086803462; Mon, 14 Oct 2019 14:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086803; cv=none; d=google.com; s=arc-20160816; b=sZC2PgWx8qK4WbxiXVoVkCqer40UxZwI3z9QSbRTKLhcfOvYmSAtKCUYVzhRuh0ArC NAC0cLNVbCBGxppA56I1lA/qb3wszsl6467xMbqENWCDQDUAHmV11YMfQfgVrgRmxcqg HIyVJHlb9M0cINAx7UuiIchQzkZUF1FdBQNKzVDOON8ve3RExoJ+owXlRxLG+SfO/2si +l9OlDouV2OqWs6ECg3kaBX534OJgB6tidbZk7m/sus1iI/8saQAtBJDsWTu8+IEK22v N8/TApRUWaWBJZj2ZND4xLqYseH5z0WthS6w9bgz/+jIxNiiDIBfWQjlLvfXB6S2Qmen nz2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=FFphYilTSsp2+i+YPh3T9cur6JXmTyfU5PiRopfWRVk=; b=KLA77hxpXxq9ZSEZD5iYTArjaCSqjmeb5ZnTOZEylbWKbPf61TDixsFbrCE0uJAUKv faptsQaIpGDX7YUC80lTcohfh8z6yxYxCcy2mO7waghi7s2hQGPMEncEtxhNq5HnrwwC Vj3nUQcQqA5+MVJSchBHopGV00lZOVD0ie5DKKnjzhYJXuSdqqAi2Vo7Op7D0jZpb5UV gvCZEKEazyA9hTgwG5MTUSoqxsMQfjGAGAFLeAc7/eB6iVAn03JpgylLsgGrBlx0ZA9p hdXTWTYKESZKEcZS1e7jx89LzL3Bd3aac2CGHmnuZbZnb7x16tPDUXnVzoixPKVo66BF 8Mkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Axcql4m2; dkim=pass header.i=@linaro.org header.s=google header.b=RVfpGPRh; spf=pass (google.com: domain of libc-alpha-return-105942-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105942-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z7si14534038edi.318.2019.10.14.14.00.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 14:00:03 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105942-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Axcql4m2; dkim=pass header.i=@linaro.org header.s=google header.b=RVfpGPRh; spf=pass (google.com: domain of libc-alpha-return-105942-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105942-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=SV9cRdtSKuY92oFcUkuLs9fz5ESQWjo mb1uuhWDE+g79VLQQB8m9ximrk9of9gwAhix/9i5zRJh+7C4Nvd1GalK1hEnZKgP Tjmi3TsJ/pbC+TZIrDfS+wkrsmYEpCOpyga/gPT/pSaHLC3yGnfUoPAzKIBstbQe TSg7KSwd0kFc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=SpCN56X9EByTv6NrlOiSZK9c3+8=; b=Axcql 4m2LuDc//A+A2fJB0KtTOJ5191/6wJlrxSbkV5q5HfETwLfM4NQIrgABQuk2Dz2q ZNhWv0QBhJXVh1RMY7XrV8cIdgzD96401XJYQmYFxGz2M+SB924mJlgyEglu7FNT cORkXq0fujRcoZQszqBV3ogQ/vfQkr2Ell0gxE= Received: (qmail 116351 invoked by alias); 14 Oct 2019 20:57:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116036 invoked by uid 89); 14 Oct 2019 20:57:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=FFphYilTSsp2+i+YPh3T9cur6JXmTyfU5PiRopfWRVk=; b=RVfpGPRhPuLhL+Vw3fj4TYhSGWxBT/o9xvH6oufKzkTb3OpjrEXjxMEEbFHSkpoAHD ZdBZpmCLoQyimdzJZcnex2PHhO7oARS0zXqtqFwjJ7w/lpMFLLiowmkG6DNOk4sWUBD0 KdjMJ3yXoRTWn2GsXLnkKcKy3XrDLGzqOv6OU2D8uwTfB3iR2kGsdpshoyHZoQlaA9fZ c73l6KXalVhj+cLplSji90kfzefRhI4zOt8Lb80w1bT/sOJs2Io2yNcFfCJR0OKtLC5D omv0LVqGmLWl+O4kxscUScPr3h/SBc4cnoiXPzuD9fz2+Edo2fZI99jn4lmrGC3FqBam C4dQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 15/21] nptl: alpha: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:50 -0300 Message-Id: <20191014205656.29834-16-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the hppa modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked on alpha-linux-gnu. --- .../unix/sysv/linux/alpha/syscall_cancel.S | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/alpha/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/alpha/syscall_cancel.S b/sysdeps/unix/sysv/linux/alpha/syscall_cancel.S new file mode 100644 index 0000000000..e497b1c805 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/syscall_cancel.S @@ -0,0 +1,82 @@ +/* Cancellable syscall wrapper. Linux/alpha version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + __syscall_arg_t nr, + __syscall_arg_t arg1, + __syscall_arg_t arg2, + __syscall_arg_t arg3, + __syscall_arg_t arg4, + __syscall_arg_t arg5, + __syscall_arg_t arg6, + __syscall_arg_t arg7) */ + + .set noreorder + .set noat + .set nomacro +ENTRY (__syscall_cancel_arch) + .frame sp, 16, ra, 0 + .mask 0x4000000,-16 + cfi_startproc + ldah gp, 0(t12) + lda gp, 0(gp) + lda sp, -16(sp) + cfi_def_cfa_offset (16) + mov a1, v0 + stq ra, 0(sp) + cfi_offset (26, -16) + .prologue 1 + + .global __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,%function +__syscall_cancel_arch_start: + ldl t0, 0(a0) + addl zero, t0, t0 + and t0, 0x4, t0 /* if (*ch & CANCELED_BITMASK) */ + bne t0, 1f + mov a2, a0 + mov a3, a1 + mov a4, a2 + ldq a4, 16(sp) + mov a5, a3 + ldq a5, 24(sp) + .set macro + callsys + .set nomacro + + .global __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,%function +__syscall_cancel_arch_end: + subq zero, v0, t0 + ldq ra, 0(sp) + cmovne a3, t0, v0 + lda sp, 16(sp) + cfi_remember_state + cfi_restore (26) + cfi_def_cfa_offset (0) + ret zero, (ra), 1 + .align 4 +1: + cfi_restore_state + ldq t12, __syscall_do_cancel(gp) !literal!2 + jsr ra, (t12), __syscall_do_cancel !lituse_jsr!2 + cfi_endproc +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176352 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5013708ill; Mon, 14 Oct 2019 14:00:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDpwbKziAB7eNduEl3DuiEB3tGzqdYpKeZzn+ij0Ed9yzm3L5hSe0j5RCIJ0jloFMB4nvT X-Received: by 2002:a50:d70c:: with SMTP id t12mr30324322edi.252.1571086813691; Mon, 14 Oct 2019 14:00:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086813; cv=none; d=google.com; s=arc-20160816; b=cxlDTnqVO0bSU9gDUQp0mKTd0ugn2L2Kvr5hCick5glYclpV1XZB3v95SXmLvaLBFC fk1lnkA/DP9cPAJEnQorewIo6XBbJBsGfrhSV2T3myvlKZxA5CsUMdCQ7swyNv7loghI b624jv/6lwz6YMAWciWoA/+3OFP5/q0TxVldXsmD5ocV0deA12CUcWTyMDW+mGRtf7FB P9aysg3qFA3QP8Ml1gfiqADs1lH5ljyRBJiocITmZD87gwWglU2eoiNwiLFcGEUfUJ/F TK6shqdtRFl04KDXgeVYgBv6woqjTSLYndQbE2VIYZoEPYlQYF+v77gHfXFyRZKkPuVx Nxqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=Vvhujm+erXu1LL7BSIyLWVlvKpXxbeaOB21RrARVVoc=; b=TNnO2MvZqiKYuWtbafGzM2zfuf9stuXOeOMcJXrYhr5X7wL+cKNV8pIRUFrIFkTdrr d4QymcReTUgQOQkobSSx0Wbrtia2r+pqFhHITJbbvv+SDnAUV6/zR0njUbXlo24f4qnT pjPK9rA3DYIUrXxIsxJZEKMM0suyNZlMizNU8rmgQvOM5MX1wrqJDj/IEqLYECuFcr7O +yOuxR9k7JpFMIJoOyA+tARkxCPLfe3tQV47akoQ7YPEA3pBUX+gCFORJ+S6rYtamKOI m4TGf12MyPBmLW/OXQs+SN+iBhaKYB9+RKbly8CNLvKiBLEZMjbALdWh+0mpFeQ0CKp6 CZRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Viynoi3w; dkim=pass header.i=@linaro.org header.s=google header.b=sDcfbRbp; spf=pass (google.com: domain of libc-alpha-return-105943-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105943-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id qp4si11654612ejb.171.2019.10.14.14.00.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 14:00:13 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105943-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Viynoi3w; dkim=pass header.i=@linaro.org header.s=google header.b=sDcfbRbp; spf=pass (google.com: domain of libc-alpha-return-105943-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105943-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=M/Anjh0jc82Y6ILJaLh2vP6+/YLAcbf ScXvn8jUaATpCU9YL/FVtSC2Zq/9sfvQ8xDikUWonKLXHqCN/RkbVE/PM2WeuR8a Veo2v3GVkYxcUNii/EylTosIeTP/ea5UJU2g5kIrcmos4FvA+MpOsULoyCF9CQRe 8fFC3ueegYFk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=N2SZ5Cup2HQAim3WdZf3Exyukpg=; b=Viyno i3w/jyI0HMZ36PyV6gA0Z62c1OurFdix0PnCvGikVI6JNnMSdNlrCu9zlRnK0UEh CDoqXXSckeaSU1YC1fIG1P10p0E+7YSh3EnY9nuXIgrrPTqlC3vSSS7k+m89mEDR wK/xyt5afQZEZGGQDiuMnDENyKpXGOAy+u/+gU= Received: (qmail 116427 invoked by alias); 14 Oct 2019 20:57:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116070 invoked by uid 89); 14 Oct 2019 20:57:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=eng X-HELO: mail-qt1-f173.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=Vvhujm+erXu1LL7BSIyLWVlvKpXxbeaOB21RrARVVoc=; b=sDcfbRbp6S7FfSr3lqwYxih9XY6TenVEJwIkVbAzuycFZFY7K/4eyn/fKJEsyj9rhd MtvG3Gc3XL3RuCNtEQGe3tvEs3xSKk8kTNUxhl0zqfcoSDmCRuFG8vBfbN3kLNKeeHjT Vtdg6o5rpvnLHyT/eNPbG04guFj0amp9ETT3stP89LRo9HuVBXCo/b/vvFE2Io0SG2ff 2tMrbuFp/EaWmsMUntYh+UwMZFwuQv+Po6AQm6QoNH5LkR+Qh3YcdW5kZfbNcZVxQqSu hw0aYu+0oXuMfZX+aOgoGKQk29S/gg/boEENI1md0QpKe/7hLpnJcFUJjYLjRHgyDn1w /OtA== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 16/21] nptl: sh: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:51 -0300 Message-Id: <20191014205656.29834-17-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the sh modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked against a build and make check run-built-tests=no for sh4-linux-gnu. --- sysdeps/sh/sysdep.h | 1 + sysdeps/unix/sysv/linux/sh/syscall_cancel.S | 128 ++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/sh/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/sh/sysdep.h b/sysdeps/sh/sysdep.h index 2f109b241e..31b7f312cd 100644 --- a/sysdeps/sh/sysdep.h +++ b/sysdeps/sh/sysdep.h @@ -24,6 +24,7 @@ #define ALIGNARG(log2) log2 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name +#define L(label) .L##label #ifdef SHARED #define PLTJMP(_x) _x##@PLT diff --git a/sysdeps/unix/sysv/linux/sh/syscall_cancel.S b/sysdeps/unix/sysv/linux/sh/syscall_cancel.S new file mode 100644 index 0000000000..3bdb939adb --- /dev/null +++ b/sysdeps/unix/sysv/linux/sh/syscall_cancel.S @@ -0,0 +1,128 @@ +/* Cancellable syscall wrapper. Linux/sh version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + long int nr, + long int arg1, + long int arg2, + long int arg3, + long int arg4, + long int arg5, + long int arg6) */ + +ENTRY (__syscall_cancel_arch) + +#ifdef SHARED + mov.l r12,@-r15 + cfi_def_cfa_offset (4) + cfi_offset (12, -4) + mova L(GT),r0 + mov.l L(GT),r12 + sts.l pr,@-r15 + cfi_def_cfa_offset (8) + cfi_offset (17, -8) + add r0,r12 +#else + sts.l pr,@-r15 + cfi_def_cfa_offset (4) + cfi_offset (17, -4) +#endif + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + mov.l @r4,r0 + tst #4,r0 + bf/s 1f + + /* Issue a 6 argument syscall. */ + mov r5,r3 + mov r6,r4 + mov r7,r5 +#ifdef SHARED + mov.l @(8,r15),r6 + mov.l @(12,r15),r7 + mov.l @(16,r15),r0 + mov.l @(20,r15),r1 +#else + mov.l @(4,r15),r6 + mov.l @(8,r15),r7 + mov.l @(12,r15),r0 + mov.l @(16,r15),r1 +#endif + trapa #0x16 + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + + /* The additional or is a workaround for a hardware issue: + http://documentation.renesas.com/eng/products/mpumcu/tu/tnsh7456ae.pdf + */ + or r0,r0 + or r0,r0 + or r0,r0 + or r0,r0 + or r0,r0 + + lds.l @r15+,pr + cfi_remember_state + cfi_restore (17) +#ifdef SHARED + cfi_def_cfa_offset (4) + rts + mov.l @r15+,r12 + cfi_def_cfa_offset (0) + cfi_restore (12) + .align 1 +1: + cfi_restore_state + mov.l L(SC),r1 + bsrf r1 +L(M): + nop + + .align 2 +L(GT): + .long _GLOBAL_OFFSET_TABLE_ +L(SC): + .long __syscall_do_cancel-(L(M)+2) +#else + cfi_def_cfa_offset (0) + rts + nop + + .align 1 +1: + cfi_restore_state + mov.l 2f,r1 + jsr @r1 + nop + + .align 2 +2: + .long __syscall_do_cancel +#endif + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176353 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5013969ill; Mon, 14 Oct 2019 14:00:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEfMbMyUgHry9Pa6yXbIbvJQvhHMV9lpt76nnKpdEciA4cstCk+COWNdIE68PIGF+byBZl X-Received: by 2002:a17:906:6882:: with SMTP id n2mr31512153ejr.48.1571086825992; Mon, 14 Oct 2019 14:00:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086825; cv=none; d=google.com; s=arc-20160816; b=pGKGGED+9J3Cod0s1ak+SrsI+SUYiKUeE1qFWW4NfPin4mgIp92Fh0LlYK+62Rh38I 5VH5yiWyDwwD9qw12JOJ3LEiv3pODsuujUVEjoocT77yIHkfVti/jd5PkH8e+9E/bVec V0Bw7T771gTy6UVmK7DzjzglUUzrQiepJ2ODasKQX9FTsPcV4SQeCaxkkZkcGXolV4p1 sf7Fpy8xl+cXEopN5KiXWl3O9cEGMOsAF7x4vw07LCYk5A9kO311fhOBsGPYGoaAIdxt B+kehyQjkDHHuLyryqkodA3Oipy5+vLmbgkept8AFFhnQssoxeEDKGgVm9EM1iYbICzT 0GtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=Bb3XFwgEFpIZHXL6UhnYqGlJqOnVvYI1EdHMRoQjGFs=; b=r8fuPq8QeWuStwdqNPQLFpMjiaQzke1Sxf2OVRP9sJAE5h3p6Y5C3DHgrdrW5OvpW0 KO8nL96Ts3fD+3BJODH/9z4hvxc1HbMUk8xcQ+Ij2h1cEzNDYOr/REnQ/I0073O+wXT8 Ts5kKXecoVpOAzIGswVcaPSvLUI7X9pwmYSx0YocUIA6j2uRWkAK4SChoKdUhtOeZ6Oz bAcXgA25tBj9Jbl/Wuzi4u6DTpchDol7QBV/7XztkcOnHpe/1VwBInqQmNx6QtrngDE1 6xTV9g4c1eC1sTEN07x99X4y0FqdjsEj01U0ueYgQAp9hLvkgqz/Ewc5XGioYK66uhx1 FePQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=u0v2R1S+; dkim=pass header.i=@linaro.org header.s=google header.b=tU0Vfkdo; spf=pass (google.com: domain of libc-alpha-return-105944-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105944-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b11si11679385eja.38.2019.10.14.14.00.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 14:00:25 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105944-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=u0v2R1S+; dkim=pass header.i=@linaro.org header.s=google header.b=tU0Vfkdo; spf=pass (google.com: domain of libc-alpha-return-105944-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105944-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=SZYQL0UYxXxnBeKlHeXf5sDHd+sHMkV AujFLVwFDd8JbKb98f8pmDbfTpvKX68LjMlgj3BS1lt9AITesn1ZssO6UWllT79g hoffoixegypMSKbllVZFWmRUctlR4IIrZQgglQqrWv6+IA+Cup8Fafayjum7fSVA SALwuDiYGlfE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=HGMDK3EgUOFDiX3clxlpKlm+7LE=; b=u0v2R 1S+yBJT0f6ULZJwmszWrhhhI24TUS1jiw1/Zk5itvqN8yPtqNt86j7UnxBFVlKVl pTEdgNfWxPYuZ0yC/XVbVZaDrimyq+L6wgGK/ulNVEYad9O/z/IzCg8cy902zZqQ izUThDsujGozIuyGIuDlPrKrtqJ4KN8+X9fqL8= Received: (qmail 116801 invoked by alias); 14 Oct 2019 20:57:37 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116223 invoked by uid 89); 14 Oct 2019 20:57:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f193.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=Bb3XFwgEFpIZHXL6UhnYqGlJqOnVvYI1EdHMRoQjGFs=; b=tU0VfkdoKSFibeDsKcD93aI0u77YfRL0mTT6ZKJZAky8kNj/B/RhbMSCE9Y+rMn44c c65Uew4FvagH76hpvokv8qN/4jXGL81nr7QH1uwxPgef5ozMz3hKJ44fzdh0DVMLD9CA INt2OAC7ec495OEWVRe6ULUAAamVdS/HWwoOMtavJj2e9uMP5VugoYcCVphqFa9E/tmD moOCT8QDy9IedFvQGtvntsMTf3wB4oxYqtnEx15MsIgEtdEjo91bUihROIghXfnLoNFe dUGOlSq7uBEfnTwsAVO31wNPT6MG0NTjuBDsiT6nFV1JlweNi75rbcMTlVchVg1Xt85W rp2g== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 17/21] nptl: riscv: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:52 -0300 Message-Id: <20191014205656.29834-18-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the riscv modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. --- .../unix/sysv/linux/riscv/syscall_cancel.S | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/riscv/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/riscv/syscall_cancel.S b/sysdeps/unix/sysv/linux/riscv/syscall_cancel.S new file mode 100644 index 0000000000..38fd630c6d --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/syscall_cancel.S @@ -0,0 +1,68 @@ +/* Cancellable syscall wrapper. Linux/riscv version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + __syscall_arg_t nr, + __syscall_arg_t arg1, + __syscall_arg_t arg2, + __syscall_arg_t arg3, + __syscall_arg_t arg4, + __syscall_arg_t arg5, + __syscall_arg_t arg6) */ + +#ifdef SHARED + .option pic +#else + .option nopic +#endif + +ENTRY (__syscall_cancel_arch) + mv t1, a7 + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + lw a7, 0(a0) + andi a7, a7, 4 /* if (*ch & CANCELED_BITMASK) */ + bnez a7, 1f + + mv a7,a1 + mv a0,a2 + mv a1,a3 + mv a2,a4 + mv a3,a5 + mv a4,a6 + mv a5,t1 + scall + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + ret + +1: + addi sp, sp, -16 + cfi_def_cfa_offset (16) + sd ra, 8(sp) + cfi_offset (ra, -8) + call __syscall_do_cancel + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176355 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5014356ill; Mon, 14 Oct 2019 14:00:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyCt3goFXi8w1aj8jMHi3++7CPjq4+CvzABi0ZA9RLfUjHQkvCA03CyLY+KIsrv6+NgSbD X-Received: by 2002:a17:906:2cd2:: with SMTP id r18mr30685469ejr.282.1571086845281; Mon, 14 Oct 2019 14:00:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086845; cv=none; d=google.com; s=arc-20160816; b=vF8Nv9RMoC31HhlOuO8byfMgKRqInCqS29WW15tGYORGIhDtsRYpwjNiFputMDtMqo 8BeXKiE/FPQ//S3W20ewkQ20SonwhbgU+n18TjDFGiQNISPzcmNupIDRBARE5exUR3N/ mhWuIDjI+2sRkK4jq6QUxuaIDnRHkDDgo9B2IyAQXkhE2VX00R4/5c4VFLqzmAQvhK15 ozYDjKCSXvhAIY/AssYl3NYEm7sNpZxfQdYnJr7twGVanjyYTEVzGwAIJei6SIh+tTGW tGcamSZQo/9SEnKLG1vcdD3L724dBf/GYTjIpD+kObEUtdxpqNe8qwnKPH4G7AyyayrH IiVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=TNBrHVKeYr+VRM8bQm1LuG5EotRzgiUu1U5GCEg7VCY=; b=xS9y/Q8Zqu1sKpvnRIpf2gdy90yHDLPr4yjeOzMkAf9SSamEXTazgcDhl/vkYc1FEf UOSwd7qH733qVcRCn2jRzaCPjZoZrVa6HvrIlV3z/WDgIaxV7ha4IZMeps82qJDsW1yQ tZQYqPgXHEv23G7EecArovCmEMOtjTwC8od1X5IkOJWPHDgWLD/tmBeRJviyIOgn0pPT HhnK8oOIcfNhTshKxoyJ8tPyDli2D/fjeI6WsMwy5HZhVeZnR322iQgxVPj34mRwCscm 46a64N15I2xqR/GNrc4JKY8qMng/zRRkklqbL/dEo+nauui/7wVnv6uBhs5uGavjLWVl dmxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=n9Ds9RCX; dkim=pass header.i=@linaro.org header.s=google header.b=iXdVaDgz; spf=pass (google.com: domain of libc-alpha-return-105946-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105946-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w20si12850587edc.202.2019.10.14.14.00.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 14:00:45 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105946-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=n9Ds9RCX; dkim=pass header.i=@linaro.org header.s=google header.b=iXdVaDgz; spf=pass (google.com: domain of libc-alpha-return-105946-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105946-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=jQVDr/5SRy1jgXA77IGEqGKCBcrBwEC 6C5kIrD9B6I+Yk39RYkMepwV6Ae1rldQeFE0PzHjwJJbcjx2zzvXEnTgle9g4ehR hWrZbeCWvirFpw1xAFqCNbT67OmFmDg5vEwbGyTAheQov8PE56y5lTB+USGiUvfi qGZXyj6Jnc7M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=sEMBRgCcPdVPsZGuby+gnxKEyXo=; b=n9Ds9 RCX5ZuNzJTjLj+AwxuVZjlFzpAMv2c1ePrTcSC7RxT4g+E3FN6Ohj6SWYZgO/KtM fH/ap3qh+LUD+eURRiDl3oKDbfy8+FBD0Ip5BXFGRH5bbWSwv1Ppcu0o2TxYlc2T nnwDMScj0x56H/U9pIkAdEK0KHyo3qdZcJXMb0= Received: (qmail 117901 invoked by alias); 14 Oct 2019 20:57:45 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116436 invoked by uid 89); 14 Oct 2019 20:57:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=TNBrHVKeYr+VRM8bQm1LuG5EotRzgiUu1U5GCEg7VCY=; b=iXdVaDgzz4mRhaBhRc1fxWYhGsaALmgzl20rVYBqqwg1NkKb89biBSrqEvaPL+Td1q q1yfRCvDBV2S+a/evNsDUPdGoo6xcXsfdlxnnJHasMrTdl7qWJZ0RcKxrkhnEqzrO731 7D2aRH6rG7e/gw2KUf3J2zO14y95VI9RtKpj56IwA68tGs1uboVwpeZ1tqrLNI/LwVwF 336wfCK15FhCbOvjdxkkGYgYF5/kCmnKXfjj8U9h7SD4Wi7z3nhJxlCT5YwXcpRp/2fn 6jzmZxbIV1G/uCqChGAFiXR5Eu35IbuXTitf7/S66JticD1G4GSP1ZDkebDiAFI74FJR 4gEg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 18/21] nptl: s390: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:53 -0300 Message-Id: <20191014205656.29834-19-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the s390 modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked on s390-linux-gnu and s390x-linux-gnu. --- .../sysv/linux/s390/s390-32/syscall_cancel.S | 83 +++++++++++++++++++ .../sysv/linux/s390/s390-64/syscall_cancel.S | 83 +++++++++++++++++++ 2 files changed, 166 insertions(+) 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 -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscall_cancel.S b/sysdeps/unix/sysv/linux/s390/s390-32/syscall_cancel.S new file mode 100644 index 0000000000..3c934addbd --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscall_cancel.S @@ -0,0 +1,83 @@ +/* Cancellable syscall wrapper. Linux/s390 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + __syscall_arg_t nr, + __syscall_arg_t arg1, + __syscall_arg_t arg2, + __syscall_arg_t arg3, + __syscall_arg_t arg4, + __syscall_arg_t arg5, + __syscall_arg_t arg6) */ + +ENTRY (__syscall_cancel_arch) + stm %r6,%r15,24(%r15) + cfi_offset (6, -72) + cfi_offset (7, -68) + cfi_offset (8, -64) + cfi_offset (9, -60) + cfi_offset (10, -56) + cfi_offset (11, -52) + cfi_offset (12, -48) + cfi_offset (13, -44) + cfi_offset (14, -40) + cfi_offset (15, -36) + ahi %r15, -96 + cfi_def_cfa_offset (192) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + l %r0, 0(%r2) + tml %r0, 4 + jne 1f + lr %r1, %r3 + lr %r2, %r4 + lr %r3, %r5 + lr %r4, %r6 + l %r5, 192(%r15) + l %r6, 196(%r15) + l %r7, 200(%r15) + svc 0 + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + l %r4, 152(%r15) + lm %r6, %r15, 120(%r15) + cfi_remember_state + cfi_restore (15) + cfi_restore (14) + cfi_restore (13) + cfi_restore (12) + cfi_restore (11) + cfi_restore (10) + cfi_restore (9) + cfi_restore (8) + cfi_restore (7) + cfi_restore (6) + cfi_def_cfa_offset (96) + br %r4 + +1: + cfi_restore_state + brasl %r14, __syscall_do_cancel +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscall_cancel.S b/sysdeps/unix/sysv/linux/s390/s390-64/syscall_cancel.S new file mode 100644 index 0000000000..3480020fbb --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscall_cancel.S @@ -0,0 +1,83 @@ +/* Cancellable syscall wrapper. Linux/s390x version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + __syscall_arg_t nr, + __syscall_arg_t arg1, + __syscall_arg_t arg2, + __syscall_arg_t arg3, + __syscall_arg_t arg4, + __syscall_arg_t arg5, + __syscall_arg_t arg6) */ + +ENTRY (__syscall_cancel_arch) + stmg %r6, %r15, 48(%r15) + cfi_offset (6, -112) + cfi_offset (7, -104) + cfi_offset (8, -96) + cfi_offset (9, -88) + cfi_offset (10, -80) + cfi_offset (11, -72) + cfi_offset (12, -64) + cfi_offset (13, -56) + cfi_offset (14, -48) + cfi_offset (15, -40) + aghi %r15,-160 + cfi_def_cfa_offset (320) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + l %r0,0(%r2) + tmll %r0,4 + jne 1f + lgr %r1,%r3 + lgr %r2,%r4 + lgr %r3,%r5 + lgr %r4,%r6 + lg %r5,320(%r15) + lg %r6,328(%r15) + lg %r7,336(%r15) + svc 0 + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + lg %r4,272(%r15) + lmg %r6,%r15,208(%r15) + cfi_remember_state + cfi_restore (15) + cfi_restore (14) + cfi_restore (13) + cfi_restore (12) + cfi_restore (11) + cfi_restore (10) + cfi_restore (9) + cfi_restore (8) + cfi_restore (7) + cfi_restore (6) + cfi_def_cfa_offset (160) + br %r4 + +1: + cfi_restore_state + brasl %r14, __syscall_do_cancel +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176354 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5014153ill; Mon, 14 Oct 2019 14:00:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8j4Yv3Q9ihfx+MRtH/WX7pny8oU2PP0ClzvXNfxJ1/Q24rV1ojE8lkYMuXNJBUJdF6m5v X-Received: by 2002:aa7:df07:: with SMTP id c7mr29605135edy.110.1571086834980; Mon, 14 Oct 2019 14:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086834; cv=none; d=google.com; s=arc-20160816; b=QJVDUrZorlrXwdW7LY7a1S66oETo915GnwmcDdWDoCjkh2irNTZDsWzl9WyDfw3Tcv bqwn5v1nzlLRW/iHrjZvqwPhWVCHpfTtdBJSe7W5mBO2BOBPuAmFRm5bAOmaMp8ndJ9A Vx4/q+P8uqUfsX5KN4wStPvMMo2OI0TTVVS2KB8iA3DRU/vw0ajU80IBh9NxfuS/riyC v5Ocq3caQcSR5P/DN2LCFgh+uQdbpPODLhd2NCimaTwGtsGJpIaHE2fLL0xG2hDRy1Dr HW9uyoJ1BOWd9/oovwMGWRGHTYoL618mrg/tZI9mTwaiHCsmw2A0s6bSfAixBlGSyr+I Hraw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=nHS0DuGabUSi8Li/+DZSxyInhQ/EdztOmlDkW2Nz7mg=; b=Ke+GAlTi2QewZPoAXw5K42CLMXgOANW24TUgHEMz+1fSFjgkII4UvhusnjzWDVQHwj sCfgAMQw3hjizheXqF0v3P2ndBPdD+OTGTB5bpqCb93cL51OeYws7tSRukYFNNXZUShy n9PyuWa/FejzSpgTDrt8KGHthbKGjxcjyZ9tQ4jqN0v0wk/B9+7t4oH8fpftxXnrSiSR Ngi9VjDEciLLs9PMAc/lSMJYlQWbe9VrQi6e1rm5pUCVtbU7EUkgPdIZKZvHqmLlEvFw 1odrHQpAlYniFskGg4O7Dyxm5ju4qM3ShY1w20YJ7HOX4uEjeb7lVaWnL3/kNUzVkrLg BGww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=qnXKXjwV; dkim=pass header.i=@linaro.org header.s=google header.b=qY4ZdXSl; spf=pass (google.com: domain of libc-alpha-return-105945-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105945-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id um16si11703335ejb.12.2019.10.14.14.00.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 14:00:34 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105945-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=qnXKXjwV; dkim=pass header.i=@linaro.org header.s=google header.b=qY4ZdXSl; spf=pass (google.com: domain of libc-alpha-return-105945-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105945-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=ARvAu5kZjY+VPUp8HyG/qDzxQXklfMn Ij7eLy1YopKojOqMjjFp99tWZoiMMBA5kubOTsMmMD32u5k2oK8M9y+seWLADrTi wyrVRRYRYt1cW292qARxUKgpJgY8mxZKdLQMdDEF95G4hDmSOWbpQITtfi6aX/bY wATNKS2iSGDg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=JIu4b8a3YFti8TR+W7CQkoeIQtc=; b=qnXKX jwVoFXJIQ2X16oQvMJ6XjFV3Fx2/Iqpj0OwllemBTJMr0Tar2+c00jcxOpUlxHlU 6JVFw7zC1tNwfmg8egMTSbSQSLm7RKggtZwkg2VVazgcOxGMoFssay5xl3I/ISju 3bJDQ+aWe4lp5IizuIDWZka/CYW4kDPsZq2eRw= Received: (qmail 117741 invoked by alias); 14 Oct 2019 20:57:44 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116538 invoked by uid 89); 14 Oct 2019 20:57:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=nHS0DuGabUSi8Li/+DZSxyInhQ/EdztOmlDkW2Nz7mg=; b=qY4ZdXSlbgReuJZAvIy40VHH15k11xXVsn8oYk6YtLnpmfMHe4uPb97VbgCtUPWirS IxmAeGDCJ7yOOrR9YwpmaTqd/ImwuBR/cF4yd2GPp7LG1esyPKinyHXzrE/6rMqquWMP R4g6MfhQKipXxAt9Zs6YZJ/oPHWxyYt8VDZ3HUoC5ZUDF01CPxxDLMrU3tMVDRQ4cH7C zySQFEQ8cEY+aFPgDvxJAIfl6U88lcLIkFeY1f/m0v64SIoXaNwGRte0oiEC084dIiZp xOJlxjEWodKXE3AWJZICCS0I9PGNPB2yzfNMpPMbxTkf6BUgubPcPHx0sIzaWJqWy3mP A4DQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 19/21] nptl: nios2: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:54 -0300 Message-Id: <20191014205656.29834-20-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the nios2 modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. --- .../unix/sysv/linux/nios2/syscall_cancel.S | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/nios2/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/nios2/syscall_cancel.S b/sysdeps/unix/sysv/linux/nios2/syscall_cancel.S new file mode 100644 index 0000000000..cc19c4525e --- /dev/null +++ b/sysdeps/unix/sysv/linux/nios2/syscall_cancel.S @@ -0,0 +1,97 @@ +/* Cancellable syscall wrapper. Linux/nios2 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + __syscall_arg_t nr, + __syscall_arg_t arg1, + __syscall_arg_t arg2, + __syscall_arg_t arg3, + __syscall_arg_t arg4, + __syscall_arg_t arg5, + __syscall_arg_t arg6) */ + +ENTRY (__syscall_cancel_arch) +#ifdef SHARED + addi sp, sp, -8 + stw r22, 0(sp) + nextpc r22 +1: + movhi r8, %hiadj(_gp_got - 1b) + addi r8, r8, %lo(_gp_got - 1b) + stw ra, 4(sp) + add r22, r22, r8 +#else + addi sp, sp, -4 + cfi_def_cfa_offset (4) + stw ra, 0(sp) + cfi_offset (31, -4) +#endif + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + ldw r3, 0(r4) + andi r3, r3, 4 + bne r3, zero, 3f + mov r10, r6 + mov r2, r5 +#ifdef SHARED +# define STACK_ADJ 4 +#else +# define STACK_ADJ 0 +#endif + ldw r9, (16 + STACK_ADJ)(sp) + mov r5, r7 + ldw r8, (12 + STACK_ADJ)(sp) + ldw r7, (8 + STACK_ADJ)(sp) + ldw r6, (4 + STACK_ADJ)(sp) + mov r4, r10 + trap + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + beq r7, zero, 2f + sub r2, zero, r2 +2: +#ifdef SHARED + ldw ra, 4(sp) + ldw r22, 0(sp) + addi sp, sp, 8 +#else + ldw ra, (0 + STACK_ADJ)(sp) + cfi_remember_state + cfi_restore (31) + addi sp, sp, 4 + cfi_def_cfa_offset (0) +#endif + ret + +3: +#ifdef SHARED + ldw r2, %call(__syscall_do_cancel)(r22) + callr r2 +#else + cfi_restore_state + call __syscall_do_cancel +#endif + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176356 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5014543ill; Mon, 14 Oct 2019 14:00:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNooQZkatZ9YH30tfqs80ZOeIanke9cdWqW8SPlE+9bvwZKLudbV/hdkGeamZ0p9ZsyjaR X-Received: by 2002:a17:906:6a8e:: with SMTP id p14mr30585214ejr.137.1571086855058; Mon, 14 Oct 2019 14:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086855; cv=none; d=google.com; s=arc-20160816; b=fM6S2UUSvj8EARgb/T/uKGopyhHUZ7VkcQfNC568cNRXOhYQDkFYGsYJ5ronLk0+/a nBhF+pSTfPPhDzUcaL+UuKzjRPswnDed4+44aRkFbxwcQZQsi6KOYjjxNC2Xm3G9royl m0HsFuBi7FtmVhTKVxTCpC8DLrbxTIWfAB5O+EkttSt1bAC0+IHD5ZL2ZXflcEW9UYaJ EHpiGeAsO5mjSSvEIJRvkIL97T/AsnoJbVufJIfp/qSTTV8Yc99VqZSXR8rT5EUzFj6A wyBVYd6YqmfkhqfX485xoAdfafFCakg8qPaT3dc669o2zdhm8XEYFIRX9PX60HxL+37/ dfdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=lXdbsQkWWDACSEjAuFKh3QeGElgNCcNc/y8sme5xdGw=; b=wPXeTRnf1HDfO3hppGcurXDQTb/Ptn3xnnZjLLHBZi+/3c+9jINZCjoPJNr9C6R52j JCpATxJRyigYsI+KmT20ottM5BwiVEq6nWQaAByL4fF6hkCUeNmIi10f0I4LPaXVow7l 1QvG7Zz2XGbQA01uUNxW/0cXOOO+B1NxE3XDE68aERQQXrY0jdPNA8/1CfsOWzM5x5kQ pM/AlIeEAn6YYoFuHM5FjQqN76A8TfuWbv3nLiZcMT/ebBEn9UnhyX5Fy3kfoLkFLvb3 1hhT2TFc8tFH3llLoW10s3h/M92vxQUF88WkS+pKu7e6PImrbbIkDMdv6YtUs6VOQ5Te 2xmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=RLF6ZnMq; dkim=pass header.i=@linaro.org header.s=google header.b=CbIO5f6U; spf=pass (google.com: domain of libc-alpha-return-105947-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105947-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ng7si11915674ejb.91.2019.10.14.14.00.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 14:00:55 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105947-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=RLF6ZnMq; dkim=pass header.i=@linaro.org header.s=google header.b=CbIO5f6U; spf=pass (google.com: domain of libc-alpha-return-105947-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105947-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Z4mF9NWwydSmmt3rOTThknqhmf+oPNG qxxU/1nN3bIKN/mGZ/Yjular6swsxuWnOyWlKO8s8K5QHli2CwHxn4Cr95qPNE0B q1M0DVxxS0/PrcMAri3mSvHpGnqh+2Sy3Ofu1Nhdxjmuz/Gl/yweAkH2XK+q7LhO IArUk4dK+sW4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=x3CgRLqtbCIlWARgE2YflvD6dkc=; b=RLF6Z nMqsBUr/V8tCvqXo5uGK6KV7tdFGayuqFh9kMwLW5nTqt0w6P2hAtO1V7bPzkskz dW6mgHZ1X+ZVWaaHJKrjNjGLs4Mt7zMRQg+yWimLBGnUf1V7uosBt7AN2ixDlijr M832+emfOar/hHGO1DUzCnLBvAyV3fGh0LznUg= Received: (qmail 118282 invoked by alias); 14 Oct 2019 20:57:49 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116696 invoked by uid 89); 14 Oct 2019 20:57:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=lXdbsQkWWDACSEjAuFKh3QeGElgNCcNc/y8sme5xdGw=; b=CbIO5f6UWyvknVGlSpsLrGyi1QkErt2UTt9Enr4mhWYoqQ3HrvpXzHYzhpCsmq+/2y +62RxmedITWQEIVaHtrK73XSMP9ot/jqa0rkF45E8EpcrFV7JNJ0JrS7BCkebxSl8jtA czdTJzgmRr8waYtZ9uKtOnhtXVQJogLMl92dsdLxqmE+GYuhOcpxbhngmm9sKP1ngOK2 WrVvsBcrzxKG3YlvIhrAtSzTkdZ5Gy4kRg42nnWg/xkVqd8wGtcpDvA1djkmAaCU90qg JXtI3ufUSUd2qqJriW6XAAwKck1WlNaXt8xG2sMeIttpiHHn6U3pXmRZ9B9m/4KWQPBC bVkw== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 20/21] nptl: csky: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:55 -0300 Message-Id: <20191014205656.29834-21-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the csky modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. --- sysdeps/unix/sysv/linux/csky/syscall_cancel.S | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/csky/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/csky/syscall_cancel.S b/sysdeps/unix/sysv/linux/csky/syscall_cancel.S new file mode 100644 index 0000000000..938f86a569 --- /dev/null +++ b/sysdeps/unix/sysv/linux/csky/syscall_cancel.S @@ -0,0 +1,116 @@ +/* Cancellable syscall wrapper. Linux/csky version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + __syscall_arg_t nr, + __syscall_arg_t arg1, + __syscall_arg_t arg2, + __syscall_arg_t arg3, + __syscall_arg_t arg4, + __syscall_arg_t arg5, + __syscall_arg_t arg6) */ + +#ifdef SHARED +# define STACK_ADJ 4 +#else +# define STACK_ADJ 0 +#endif + +ENTRY (__syscall_cancel_arch) + subi sp, sp, 16 + STACK_ADJ + cfi_def_cfa_offset (16 + STACK_ADJ) +#ifdef SHARED + st.w gb, (sp, 16) + lrw t1, 1f@GOTPC + cfi_offset (gb, -4) + grs gb, 1f +1: +#endif + st.w lr, (sp, 12) + st.w l3, (sp, 8) + st.w l1, (sp, 4) + st.w l0, (sp, 0) +#ifdef SHARED + addu gb, gb, t1 +#endif + subi sp, sp, 16 + cfi_def_cfa_offset (32 + STACK_ADJ) + cfi_offset (lr, -( 4 + STACK_ADJ)) + cfi_offset (l3, -( 8 + STACK_ADJ)) + cfi_offset (l1, -(12 + STACK_ADJ)) + cfi_offset (l0, -(16 + STACK_ADJ)) + + mov l3, a1 + mov a1, a3 + ld.w a3, (sp, 32 + STACK_ADJ) + st.w a3, (sp, 0) + ld.w a3, (sp, 36 + STACK_ADJ) + st.w a3, (sp, 4) + ld.w a3, (sp, 40 + STACK_ADJ) + st.w a3, (sp, 8) + ld.w a3, (sp, 44 + STACK_ADJ) + st.w a3, (sp, 12) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + ld.w t0, (a0, 0) + andi t0, t0, 4 + jbnez t0, 2f + mov a0, a2 + ld.w a3, (sp, 4) + ld.w a2, (sp, 0) + ld.w l0, (sp, 8) + ld.w l1, (sp, 12) + trap 0 + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + addi sp, sp, 16 + cfi_remember_state + cfi_def_cfa_offset (16 + STACK_ADJ) +#ifdef SHARED + ld.w gb, (sp, 16) + cfi_restore (gb) +#endif + ld.w lr, (sp, 12) + cfi_restore (lr) + ld.w l3, (sp, 8) + cfi_restore (l3) + ld.w l1, (sp, 4) + cfi_restore (l1) + ld.w l0, (sp, 0) + cfi_restore (l0) + addi sp, sp, 16 + cfi_def_cfa_offset (0) + rts + +2: + cfi_restore_state +#ifdef SHARED + lrw a3, __syscall_do_cancel@GOTOFF + addu a3, a3, gb + jsr a3 +#else + jbsr __syscall_do_cancel +#endif +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) From patchwork Mon Oct 14 20:56:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176357 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5014926ill; Mon, 14 Oct 2019 14:01:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyw8b5C4QgtQtErXdYWPfwr3bxFUSdM68VBGgO6SQy1ZP2FlMuapDqkOvq/7b5oznQPcFth X-Received: by 2002:a17:906:6ad7:: with SMTP id q23mr29738456ejs.214.1571086872330; Mon, 14 Oct 2019 14:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086872; cv=none; d=google.com; s=arc-20160816; b=PrqzEK7C1mHkL5FiWVUUlIWJbcsLuhLBwyLm2/KHnueKLX/4kMCe1ylW+WDEchM2Gh ZdYJ0H25KcuK8JogPW/D7mjIh6Lc9HVT6r0IK6IvZ/r+iAcWbGiTj6qjsrcpaua6tkyF OvGyESpx6e5sW7pjbQqAicwIpXIG/jz+R1LZWlTWvHKp2WlWwSd3I+Lldg+EPkPI1Ccc +kaW9f5luSGLP1j4q/XF+axRq1nZrAL0bdrccp9ZHOGzlOLk0uafNYVs/KT5ydLkbgyO /9m1heKHfCg30zSB8qduGyZMU5y+phIfdFqKACQqTIMJkA2f43MoVakS4jlLNXupV43Y xHbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=YdTL973BcQ6w73Gw6eb5G26lOlTYR2SWBwFYEf73zjQ=; b=ui+QkP+Yjsn4cKVUn6LENoz2cmz52FtrLNxWtOaRpZk+fF14CQsqmOo/FFXc64XA/M KSzm1uWWPa3GFr5Wl76k3BoQ+QRtUJF+cs4osEAevJXZTEg2ebkWoIfqDV0/tXRYoa7D OV1QNeNDK0tb33cBfSKww9exWsru3Dd81ffd0XwxW0SLpyjL0JHMM5r50VOWcJQcxJh/ stdoBCYLGlZLQuEuJ1fs4fuep2NgZwTdPP0kvGpkM5pVrFzujTBIHXRqlCSTTj49DSyc Xx34nw/R+o9dKLc/znWFgH+A+z0aH9OhalqTO6K9qvSMjIZzHtcHQsasbsisALp0wgOh CCFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=t9eKNJEs; dkim=pass header.i=@linaro.org header.s=google header.b=OEYlK+qV; spf=pass (google.com: domain of libc-alpha-return-105948-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105948-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y6si11977977ejj.113.2019.10.14.14.01.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 14:01:12 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105948-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=t9eKNJEs; dkim=pass header.i=@linaro.org header.s=google header.b=OEYlK+qV; spf=pass (google.com: domain of libc-alpha-return-105948-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105948-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=qdxhwz2pjL6hl/8ApU18pkZTnq8iEsh Rr+9C9og0ccboFSrEoHA8YcF0LJJd3K5W85c1OHi5TYMj9sfg2FjNemJZv6gfyYq NbzyK/O+eLEOKecPUocdFYnReENR95xFBhYJkd3rOdMsIQCwK2x0PpSS+ymwDT6a UI56L4b9jG1s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=DOpyJEA1z71k6+TPF2gfR8eEVRE=; b=t9eKN JEsbUF/oNTGNM8HdZzDKDs6ZMvOAYhwmRF25LFhP4sOshKPBFo1/DxPSVxHXkzJk 71Sr0ZcZfla2hMFnA3X4GZXVx4Y9hKmRhBjy8rMzDWBIVT4NcR3Pbme4ryPYXUP/ wgMPbRJqAeq4R4lXT98fHWL7RsUx+/+SrKcHE0= Received: (qmail 119590 invoked by alias); 14 Oct 2019 20:58:00 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 117950 invoked by uid 89); 14 Oct 2019 20:57:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=param.h, paramh, Receive, UD:param.h X-HELO: mail-qk1-f170.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=YdTL973BcQ6w73Gw6eb5G26lOlTYR2SWBwFYEf73zjQ=; b=OEYlK+qVgs4lKUbsuwKf95WfO9g4+BBrlUGLmOdpMyWmrReX80xY2pWzBdGD+Aqfiw RUnioof7jwAWnn1jpjyWqoCOKFae66M/JiQPEIzI7m7nHDmJeDMScVKangCxMxvzc0P7 wDndJre9kltk9DzX/G3cXFhSVKlrZR2X9YeIFoiw1uC4NWWzc49uwZEGyf5EvsDctASi gaupUOj9+CbEmWjmTml9OQNBcFfmrWKI9wYFz4MhPDMNVB4R4GiWK9UNePUh0HHz1FXU 48zp7Rn0/Z0RvVyUi91B9VJW4d74S2aQVHM+iH8jF++lbo1IXK5Wi/kSuSTHOOZX8uo/ 7ORQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 21/21] Remove sysdep-cancel header Date: Mon, 14 Oct 2019 17:56:56 -0300 Message-Id: <20191014205656.29834-22-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> Now that single-thread optimization is provided by single-thread.h header and the enable/disable asynchronous cancellation functions are no longer used on cancellable syscalls, the header can be removed. Checked with a build for all major Linux architectures and for hurd. --- 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 | 1 - malloc/malloc.c | 3 - misc/pselect.c | 1 - nptl/thrd_sleep.c | 1 - sysdeps/generic/sysdep-cancel.h | 5 -- sysdeps/mach/hurd/sysdep-cancel.h | 8 --- sysdeps/mips/dl-trampoline.c | 1 - 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/unix/clock_nanosleep.c | 1 - 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 - 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/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 | 1 - sysdeps/unix/sysv/linux/getrandom.c | 1 - sysdeps/unix/sysv/linux/lowlevellock-futex.h | 1 - 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 - 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 - 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 - 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 - 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/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 | 2 + sysdeps/unix/sysv/linux/splice.c | 2 +- sysdeps/unix/sysv/linux/sync_file_range.c | 2 +- sysdeps/unix/sysv/linux/sysdep-cancel.h | 67 -------------------- 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 +- 106 files changed, 38 insertions(+), 192 deletions(-) delete mode 100644 sysdeps/generic/sysdep-cancel.h delete mode 100644 sysdeps/mach/hurd/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/sysdep-cancel.h -- 2.17.1 diff --git a/elf/dl-close.c b/elf/dl-close.c index de91c28f72..dfe2bc9be4 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index fd44cd4101..ff5c811550 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/elf/dl-open.c b/elf/dl-open.c index a9fd4cbced..2b35209dfd 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c index 342b794f54..9dedd193de 100644 --- a/elf/dl-runtime.c +++ b/elf/dl-runtime.c @@ -23,7 +23,6 @@ #include #include #include -#include #include "dynamic-link.h" #include #include diff --git a/elf/dl-scope.c b/elf/dl-scope.c index f4ba0898df..dff4b1b51b 100644 --- a/elf/dl-scope.c +++ b/elf/dl-scope.c @@ -18,7 +18,6 @@ #include #include -#include int diff --git a/elf/dl-sym.c b/elf/dl-sym.c index 8209342b13..af1f8549a3 100644 --- a/elf/dl-sym.c +++ b/elf/dl-sym.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/io/creat.c b/io/creat.c index 8e4f0cf2c4..3a93b0947f 100644 --- a/io/creat.c +++ b/io/creat.c @@ -17,7 +17,6 @@ #include #include -#include #undef creat diff --git a/io/ppoll.c b/io/ppoll.c index a387924eeb..f66913f7c7 100644 --- a/io/ppoll.c +++ b/io/ppoll.c @@ -21,7 +21,6 @@ #include #include /* For NULL. */ #include -#include int diff --git a/malloc/malloc.c b/malloc/malloc.c index 5d3e82a8f6..69dac97f28 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -244,9 +244,6 @@ #include -/* For SINGLE_THREAD_P. */ -#include - /* Debugging: diff --git a/misc/pselect.c b/misc/pselect.c index 76ded850a5..f3939c91a2 100644 --- a/misc/pselect.c +++ b/misc/pselect.c @@ -21,7 +21,6 @@ #include /* For NULL. */ #include #include -#include /* Check the first NFDS descriptors each in READFDS (if not NULL) for read diff --git a/nptl/thrd_sleep.c b/nptl/thrd_sleep.c index 75c0d53f3e..cfae149bf5 100644 --- a/nptl/thrd_sleep.c +++ b/nptl/thrd_sleep.c @@ -17,7 +17,6 @@ . */ #include -#include #include "thrd_priv.h" diff --git a/sysdeps/generic/sysdep-cancel.h b/sysdeps/generic/sysdep-cancel.h deleted file mode 100644 index 5c84b4499a..0000000000 --- a/sysdeps/generic/sysdep-cancel.h +++ /dev/null @@ -1,5 +0,0 @@ -#include - -/* No multi-thread handling enabled. */ -#define SINGLE_THREAD_P (1) -#define RTLD_SINGLE_THREAD_P (1) diff --git a/sysdeps/mach/hurd/sysdep-cancel.h b/sysdeps/mach/hurd/sysdep-cancel.h deleted file mode 100644 index f686a39024..0000000000 --- a/sysdeps/mach/hurd/sysdep-cancel.h +++ /dev/null @@ -1,8 +0,0 @@ -#include - -/* Always multi-thread (since there's at least the sig handler), but no - handling enabled. */ -#define SINGLE_THREAD_P (0) -#define RTLD_SINGLE_THREAD_P (0) -#define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */ -#define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */ diff --git a/sysdeps/mips/dl-trampoline.c b/sysdeps/mips/dl-trampoline.c index 74a2bffdc3..9655ec6de1 100644 --- a/sysdeps/mips/dl-trampoline.c +++ b/sysdeps/mips/dl-trampoline.c @@ -24,7 +24,6 @@ #include #include #include -#include /* Get link map for callers object containing STUB_PC. */ static inline struct link_map * diff --git a/sysdeps/posix/open64.c b/sysdeps/posix/open64.c index d163b590bc..34b78a65ae 100644 --- a/sysdeps/posix/open64.c +++ b/sysdeps/posix/open64.c @@ -17,7 +17,6 @@ #include #include -#include /* Open FILE with access OFLAG. If O_CREAT or O_TMPFILE is in OFLAG, a third argument is the file protection. */ diff --git a/sysdeps/posix/pause.c b/sysdeps/posix/pause.c index a3c050dc77..601a596b79 100644 --- a/sysdeps/posix/pause.c +++ b/sysdeps/posix/pause.c @@ -18,7 +18,6 @@ #include #include -#include #include /* Suspend the process until a signal arrives. diff --git a/sysdeps/posix/sigpause.c b/sysdeps/posix/sigpause.c index 2d11e011fa..a9e1576c46 100644 --- a/sysdeps/posix/sigpause.c +++ b/sysdeps/posix/sigpause.c @@ -22,7 +22,6 @@ #undef sigpause #include -#include int __sigpause (int sig_or_mask, int is_sig) diff --git a/sysdeps/posix/sigwait.c b/sysdeps/posix/sigwait.c index 675e59fd7a..886fbab66f 100644 --- a/sysdeps/posix/sigwait.c +++ b/sysdeps/posix/sigwait.c @@ -20,7 +20,6 @@ #include #include #include /* For NULL. */ -#include /* This is our dummy signal handler we use here. */ static void ignore_signal (int sig); diff --git a/sysdeps/posix/waitid.c b/sysdeps/posix/waitid.c index 0942623553..3dc0a7cb57 100644 --- a/sysdeps/posix/waitid.c +++ b/sysdeps/posix/waitid.c @@ -24,7 +24,6 @@ #include #include #include -#include #ifdef DO_WAITID diff --git a/sysdeps/unix/clock_nanosleep.c b/sysdeps/unix/clock_nanosleep.c index 95b4956b12..014a24ab14 100644 --- a/sysdeps/unix/clock_nanosleep.c +++ b/sysdeps/unix/clock_nanosleep.c @@ -19,7 +19,6 @@ #include #include #include -#include #include /* This implementation assumes that these is only a `nanosleep' system diff --git a/sysdeps/unix/sysv/linux/accept.c b/sysdeps/unix/sysv/linux/accept.c index 9fb6966dff..6dc00deb97 100644 --- a/sysdeps/unix/sysv/linux/accept.c +++ b/sysdeps/unix/sysv/linux/accept.c @@ -16,7 +16,6 @@ . */ #include -#include #include int diff --git a/sysdeps/unix/sysv/linux/accept4.c b/sysdeps/unix/sysv/linux/accept4.c index 963be98d43..e305ef42ad 100644 --- a/sysdeps/unix/sysv/linux/accept4.c +++ b/sysdeps/unix/sysv/linux/accept4.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/sysdeps/unix/sysv/linux/access.c b/sysdeps/unix/sysv/linux/access.c index 690c99a856..ef34824fb1 100644 --- a/sysdeps/unix/sysv/linux/access.c +++ b/sysdeps/unix/sysv/linux/access.c @@ -18,7 +18,7 @@ #include #include -#include +#include int __access (const char *file, int type) diff --git a/sysdeps/unix/sysv/linux/alpha/select.c b/sysdeps/unix/sysv/linux/alpha/select.c index 2c4fc4c160..e4ed853df9 100644 --- a/sysdeps/unix/sysv/linux/alpha/select.c +++ b/sysdeps/unix/sysv/linux/alpha/select.c @@ -20,7 +20,6 @@ #include #include #include -#include #include int diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index ddcdddcd5d..0146bc6a37 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -18,7 +18,6 @@ #include #include -#include #include "kernel-posix-cpu-timers.h" #include diff --git a/sysdeps/unix/sysv/linux/close.c b/sysdeps/unix/sysv/linux/close.c index 0e387a340a..58818eadfd 100644 --- a/sysdeps/unix/sysv/linux/close.c +++ b/sysdeps/unix/sysv/linux/close.c @@ -17,7 +17,6 @@ . */ #include -#include #include /* Close the file descriptor FD. */ diff --git a/sysdeps/unix/sysv/linux/close_nocancel.c b/sysdeps/unix/sysv/linux/close_nocancel.c index bb288199e6..171dfc315a 100644 --- a/sysdeps/unix/sysv/linux/close_nocancel.c +++ b/sysdeps/unix/sysv/linux/close_nocancel.c @@ -17,7 +17,6 @@ . */ #include -#include #include int diff --git a/sysdeps/unix/sysv/linux/connect.c b/sysdeps/unix/sysv/linux/connect.c index 4ada43037d..ec95e4a444 100644 --- a/sysdeps/unix/sysv/linux/connect.c +++ b/sysdeps/unix/sysv/linux/connect.c @@ -16,7 +16,6 @@ . */ #include -#include #include int diff --git a/sysdeps/unix/sysv/linux/copy_file_range.c b/sysdeps/unix/sysv/linux/copy_file_range.c index 9bbed6bd9e..9361b8e8e3 100644 --- a/sysdeps/unix/sysv/linux/copy_file_range.c +++ b/sysdeps/unix/sysv/linux/copy_file_range.c @@ -17,7 +17,6 @@ . */ #include -#include #include ssize_t diff --git a/sysdeps/unix/sysv/linux/creat.c b/sysdeps/unix/sysv/linux/creat.c index e55514999e..35ad07594d 100644 --- a/sysdeps/unix/sysv/linux/creat.c +++ b/sysdeps/unix/sysv/linux/creat.c @@ -19,7 +19,6 @@ #include #include -#include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/creat64.c b/sysdeps/unix/sysv/linux/creat64.c index 6b95e7e6de..721ae13632 100644 --- a/sysdeps/unix/sysv/linux/creat64.c +++ b/sysdeps/unix/sysv/linux/creat64.c @@ -18,7 +18,6 @@ #include #include -#include /* Create FILE with protections MODE. */ int diff --git a/sysdeps/unix/sysv/linux/epoll_pwait.c b/sysdeps/unix/sysv/linux/epoll_pwait.c index 74d845f436..ab7edb4b69 100644 --- a/sysdeps/unix/sysv/linux/epoll_pwait.c +++ b/sysdeps/unix/sysv/linux/epoll_pwait.c @@ -20,7 +20,6 @@ #include #include -#include #include #ifdef __NR_epoll_pwait diff --git a/sysdeps/unix/sysv/linux/epoll_wait.c b/sysdeps/unix/sysv/linux/epoll_wait.c index 32406d4c3d..59729904e2 100644 --- a/sysdeps/unix/sysv/linux/epoll_wait.c +++ b/sysdeps/unix/sysv/linux/epoll_wait.c @@ -21,7 +21,6 @@ #include #include -#include int epoll_wait (int epfd, struct epoll_event *events, int maxevents, int timeout) diff --git a/sysdeps/unix/sysv/linux/fallocate.c b/sysdeps/unix/sysv/linux/fallocate.c index bf1eefbd53..784fb09d62 100644 --- a/sysdeps/unix/sysv/linux/fallocate.c +++ b/sysdeps/unix/sysv/linux/fallocate.c @@ -17,7 +17,6 @@ #include #include -#include #ifndef __OFF_T_MATCHES_OFF64_T /* Reserve storage for the data of the file associated with FD. */ diff --git a/sysdeps/unix/sysv/linux/fallocate64.c b/sysdeps/unix/sysv/linux/fallocate64.c index 3ffc4bcdda..b803b28508 100644 --- a/sysdeps/unix/sysv/linux/fallocate64.c +++ b/sysdeps/unix/sysv/linux/fallocate64.c @@ -17,7 +17,6 @@ #include #include -#include /* Reserve storage for the data of the file associated with FD. */ diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c index 48bda0db4e..19d688bed7 100644 --- a/sysdeps/unix/sysv/linux/fcntl.c +++ b/sysdeps/unix/sysv/linux/fcntl.c @@ -19,7 +19,6 @@ #include #include #include -#include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c index c66f1c4ca1..42f0379308 100644 --- a/sysdeps/unix/sysv/linux/fcntl64.c +++ b/sysdeps/unix/sysv/linux/fcntl64.c @@ -23,7 +23,6 @@ #undef __fcntl #include #include -#include #ifndef __NR_fcntl64 # define __NR_fcntl64 __NR_fcntl diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c index d2f5c4fe93..187d27fdb1 100644 --- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c +++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #ifndef __NR_fcntl64 diff --git a/sysdeps/unix/sysv/linux/fdatasync.c b/sysdeps/unix/sysv/linux/fdatasync.c index c6a02f24e9..afd45005d1 100644 --- a/sysdeps/unix/sysv/linux/fdatasync.c +++ b/sysdeps/unix/sysv/linux/fdatasync.c @@ -18,7 +18,7 @@ . */ #include -#include +#include /* Synchronize at least the data part of a file with the underlying media. */ diff --git a/sysdeps/unix/sysv/linux/fsync.c b/sysdeps/unix/sysv/linux/fsync.c index e4b6ee72ee..24789e2c24 100644 --- a/sysdeps/unix/sysv/linux/fsync.c +++ b/sysdeps/unix/sysv/linux/fsync.c @@ -18,7 +18,7 @@ . */ #include -#include +#include /* Make all changes done to FD actually appear on disk. */ int diff --git a/sysdeps/unix/sysv/linux/futex-internal.h b/sysdeps/unix/sysv/linux/futex-internal.h index b41a4d9919..8b7ad1f0df 100644 --- a/sysdeps/unix/sysv/linux/futex-internal.h +++ b/sysdeps/unix/sysv/linux/futex-internal.h @@ -22,7 +22,6 @@ #include #include #include -#include /* See sysdeps/nptl/futex-internal.h for documentation; this file only contains Linux-specific comments. diff --git a/sysdeps/unix/sysv/linux/getrandom.c b/sysdeps/unix/sysv/linux/getrandom.c index 122c695a3e..c69a4c190f 100644 --- a/sysdeps/unix/sysv/linux/getrandom.c +++ b/sysdeps/unix/sysv/linux/getrandom.c @@ -19,7 +19,6 @@ #include #include #include -#include #ifdef __NR_getrandom /* Write up to LENGTH bytes of randomness starting at BUFFER. diff --git a/sysdeps/unix/sysv/linux/lowlevellock-futex.h b/sysdeps/unix/sysv/linux/lowlevellock-futex.h index bd6d3b7cf7..e43400d070 100644 --- a/sysdeps/unix/sysv/linux/lowlevellock-futex.h +++ b/sysdeps/unix/sysv/linux/lowlevellock-futex.h @@ -21,7 +21,6 @@ #ifndef __ASSEMBLER__ #include -#include #include #endif diff --git a/sysdeps/unix/sysv/linux/mq_timedreceive.c b/sysdeps/unix/sysv/linux/mq_timedreceive.c index 9957de44f7..4417d36ced 100644 --- a/sysdeps/unix/sysv/linux/mq_timedreceive.c +++ b/sysdeps/unix/sysv/linux/mq_timedreceive.c @@ -17,7 +17,7 @@ . */ #include -#include +#include /* Receive the oldest from highest priority messages in message queue MQDES, stop waiting if ABS_TIMEOUT expires. */ diff --git a/sysdeps/unix/sysv/linux/mq_timedsend.c b/sysdeps/unix/sysv/linux/mq_timedsend.c index cd8f77d03f..1befb6b99e 100644 --- a/sysdeps/unix/sysv/linux/mq_timedsend.c +++ b/sysdeps/unix/sysv/linux/mq_timedsend.c @@ -17,7 +17,7 @@ . */ #include -#include +#include /* Add message pointed by MSG_PTR to message queue MQDES, stop blocking on full message queue if ABS_TIMEOUT expires. */ diff --git a/sysdeps/unix/sysv/linux/msgrcv.c b/sysdeps/unix/sysv/linux/msgrcv.c index 1b06bd6d60..277c26d2d1 100644 --- a/sysdeps/unix/sysv/linux/msgrcv.c +++ b/sysdeps/unix/sysv/linux/msgrcv.c @@ -18,7 +18,7 @@ #include #include -#include +#include ssize_t __libc_msgrcv (int msqid, void *msgp, size_t msgsz, long int msgtyp, diff --git a/sysdeps/unix/sysv/linux/msgsnd.c b/sysdeps/unix/sysv/linux/msgsnd.c index 28d46bda25..2a4603ff1e 100644 --- a/sysdeps/unix/sysv/linux/msgsnd.c +++ b/sysdeps/unix/sysv/linux/msgsnd.c @@ -18,7 +18,7 @@ #include #include -#include +#include int __libc_msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg) diff --git a/sysdeps/unix/sysv/linux/msync.c b/sysdeps/unix/sysv/linux/msync.c index 7a597b1fd9..33a007a64b 100644 --- a/sysdeps/unix/sysv/linux/msync.c +++ b/sysdeps/unix/sysv/linux/msync.c @@ -17,7 +17,7 @@ . */ #include -#include +#include int msync (void *addr, size_t length, int flags) diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c index 6787909248..4e08c675f8 100644 --- a/sysdeps/unix/sysv/linux/nanosleep.c +++ b/sysdeps/unix/sysv/linux/nanosleep.c @@ -17,8 +17,7 @@ . */ #include -#include -#include +#include /* Pause execution for a number of nanoseconds. */ int diff --git a/sysdeps/unix/sysv/linux/nanosleep_nocancel.c b/sysdeps/unix/sysv/linux/nanosleep_nocancel.c index d6442bf4f7..74c999281a 100644 --- a/sysdeps/unix/sysv/linux/nanosleep_nocancel.c +++ b/sysdeps/unix/sysv/linux/nanosleep_nocancel.c @@ -17,7 +17,6 @@ . */ #include -#include #include int diff --git a/sysdeps/unix/sysv/linux/open.c b/sysdeps/unix/sysv/linux/open.c index a65aec457d..0e14aa0abe 100644 --- a/sysdeps/unix/sysv/linux/open.c +++ b/sysdeps/unix/sysv/linux/open.c @@ -21,8 +21,7 @@ #include #include #include - -#include +#include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/open64.c b/sysdeps/unix/sysv/linux/open64.c index d6cefb09d1..d10609d3c0 100644 --- a/sysdeps/unix/sysv/linux/open64.c +++ b/sysdeps/unix/sysv/linux/open64.c @@ -20,9 +20,7 @@ #include #include #include - -#include - +#include #ifdef __OFF_T_MATCHES_OFF64_T # define EXTRA_OPEN_FLAGS 0 diff --git a/sysdeps/unix/sysv/linux/open_by_handle_at.c b/sysdeps/unix/sysv/linux/open_by_handle_at.c index 0888157a33..cfb57737b5 100644 --- a/sysdeps/unix/sysv/linux/open_by_handle_at.c +++ b/sysdeps/unix/sysv/linux/open_by_handle_at.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include int open_by_handle_at (int mount_fd, struct file_handle *handle, int flags) diff --git a/sysdeps/unix/sysv/linux/open_nocancel.c b/sysdeps/unix/sysv/linux/open_nocancel.c index 9926218cca..232423bf0d 100644 --- a/sysdeps/unix/sysv/linux/open_nocancel.c +++ b/sysdeps/unix/sysv/linux/open_nocancel.c @@ -21,7 +21,6 @@ #include #include -#include #include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/openat.c b/sysdeps/unix/sysv/linux/openat.c index a4450445da..0983ed9de2 100644 --- a/sysdeps/unix/sysv/linux/openat.c +++ b/sysdeps/unix/sysv/linux/openat.c @@ -18,8 +18,7 @@ #include #include - -#include +#include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/openat64.c b/sysdeps/unix/sysv/linux/openat64.c index dbd893ea9d..96d96080f4 100644 --- a/sysdeps/unix/sysv/linux/openat64.c +++ b/sysdeps/unix/sysv/linux/openat64.c @@ -18,8 +18,7 @@ #include #include - -#include +#include #ifdef __OFF_T_MATCHES_OFF64_T # define EXTRA_OPEN_FLAGS 0 diff --git a/sysdeps/unix/sysv/linux/openat64_nocancel.c b/sysdeps/unix/sysv/linux/openat64_nocancel.c index cd077f28cd..97f4af4c23 100644 --- a/sysdeps/unix/sysv/linux/openat64_nocancel.c +++ b/sysdeps/unix/sysv/linux/openat64_nocancel.c @@ -19,7 +19,6 @@ #include #include -#include #include #ifdef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/openat_nocancel.c b/sysdeps/unix/sysv/linux/openat_nocancel.c index 25db90ce8e..17c8d29084 100644 --- a/sysdeps/unix/sysv/linux/openat_nocancel.c +++ b/sysdeps/unix/sysv/linux/openat_nocancel.c @@ -19,7 +19,6 @@ #include #include -#include #include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/pause.c b/sysdeps/unix/sysv/linux/pause.c index c2b9f4fb66..2f5861fbab 100644 --- a/sysdeps/unix/sysv/linux/pause.c +++ b/sysdeps/unix/sysv/linux/pause.c @@ -18,7 +18,7 @@ #include #include -#include +#include /* Suspend the process until a signal arrives. This always returns -1 and sets errno to EINTR. */ diff --git a/sysdeps/unix/sysv/linux/pause_nocancel.c b/sysdeps/unix/sysv/linux/pause_nocancel.c index 04f6fcf5e3..dffb07500f 100644 --- a/sysdeps/unix/sysv/linux/pause_nocancel.c +++ b/sysdeps/unix/sysv/linux/pause_nocancel.c @@ -18,7 +18,6 @@ #include #include -#include #include int diff --git a/sysdeps/unix/sysv/linux/poll.c b/sysdeps/unix/sysv/linux/poll.c index 8ea00563a4..8f66655cf1 100644 --- a/sysdeps/unix/sysv/linux/poll.c +++ b/sysdeps/unix/sysv/linux/poll.c @@ -19,7 +19,6 @@ #include #include -#include #include int diff --git a/sysdeps/unix/sysv/linux/ppoll.c b/sysdeps/unix/sysv/linux/ppoll.c index 8a6ccd1dcc..e9ffd51636 100644 --- a/sysdeps/unix/sysv/linux/ppoll.c +++ b/sysdeps/unix/sysv/linux/ppoll.c @@ -20,8 +20,6 @@ #include #include #include -#include - int ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, diff --git a/sysdeps/unix/sysv/linux/pread.c b/sysdeps/unix/sysv/linux/pread.c index d9faf3cee2..cfc6859892 100644 --- a/sysdeps/unix/sysv/linux/pread.c +++ b/sysdeps/unix/sysv/linux/pread.c @@ -17,7 +17,7 @@ . */ #include -#include +#include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/pread64.c b/sysdeps/unix/sysv/linux/pread64.c index 36410292ee..db452ba3e5 100644 --- a/sysdeps/unix/sysv/linux/pread64.c +++ b/sysdeps/unix/sysv/linux/pread64.c @@ -17,7 +17,7 @@ . */ #include -#include +#include #ifndef __NR_pread64 # define __NR_pread64 __NR_pread diff --git a/sysdeps/unix/sysv/linux/preadv.c b/sysdeps/unix/sysv/linux/preadv.c index 61007df357..8794c2b677 100644 --- a/sysdeps/unix/sysv/linux/preadv.c +++ b/sysdeps/unix/sysv/linux/preadv.c @@ -16,7 +16,7 @@ . */ #include -#include +#include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/preadv2.c b/sysdeps/unix/sysv/linux/preadv2.c index 9e3205b8ef..5c2c3752ca 100644 --- a/sysdeps/unix/sysv/linux/preadv2.c +++ b/sysdeps/unix/sysv/linux/preadv2.c @@ -17,7 +17,7 @@ . */ #include -#include +#include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/preadv64.c b/sysdeps/unix/sysv/linux/preadv64.c index 4b0a66f583..3f99ed2203 100644 --- a/sysdeps/unix/sysv/linux/preadv64.c +++ b/sysdeps/unix/sysv/linux/preadv64.c @@ -16,7 +16,7 @@ . */ #include -#include +#include #ifdef __ASSUME_PREADV diff --git a/sysdeps/unix/sysv/linux/preadv64v2.c b/sysdeps/unix/sysv/linux/preadv64v2.c index 724f03d0ef..44cd74e177 100644 --- a/sysdeps/unix/sysv/linux/preadv64v2.c +++ b/sysdeps/unix/sysv/linux/preadv64v2.c @@ -17,7 +17,7 @@ . */ #include -#include +#include #if !defined(__NR_preadv64v2) && defined(__NR_preadv2) # define __NR_preadv64v2 __NR_preadv2 diff --git a/sysdeps/unix/sysv/linux/pselect.c b/sysdeps/unix/sysv/linux/pselect.c index d07d64114d..f929ff23a8 100644 --- a/sysdeps/unix/sysv/linux/pselect.c +++ b/sysdeps/unix/sysv/linux/pselect.c @@ -21,8 +21,6 @@ #include #include #include -#include - #ifdef __NR_pselect6 # ifndef __ASSUME_PSELECT diff --git a/sysdeps/unix/sysv/linux/pwrite.c b/sysdeps/unix/sysv/linux/pwrite.c index ddfbdef9c1..c59290d12d 100644 --- a/sysdeps/unix/sysv/linux/pwrite.c +++ b/sysdeps/unix/sysv/linux/pwrite.c @@ -17,7 +17,7 @@ . */ #include -#include +#include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/pwrite64.c b/sysdeps/unix/sysv/linux/pwrite64.c index db8661c054..d5ba7786c6 100644 --- a/sysdeps/unix/sysv/linux/pwrite64.c +++ b/sysdeps/unix/sysv/linux/pwrite64.c @@ -17,7 +17,7 @@ . */ #include -#include +#include #ifndef __NR_pwrite64 # define __NR_pwrite64 __NR_pwrite diff --git a/sysdeps/unix/sysv/linux/pwritev.c b/sysdeps/unix/sysv/linux/pwritev.c index ed25289984..45a801806c 100644 --- a/sysdeps/unix/sysv/linux/pwritev.c +++ b/sysdeps/unix/sysv/linux/pwritev.c @@ -16,7 +16,7 @@ . */ #include -#include +#include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/pwritev2.c b/sysdeps/unix/sysv/linux/pwritev2.c index a415b2fa89..ccd099a021 100644 --- a/sysdeps/unix/sysv/linux/pwritev2.c +++ b/sysdeps/unix/sysv/linux/pwritev2.c @@ -17,7 +17,7 @@ . */ #include -#include +#include #ifndef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/pwritev64.c b/sysdeps/unix/sysv/linux/pwritev64.c index ec9987fefc..50f7774e3c 100644 --- a/sysdeps/unix/sysv/linux/pwritev64.c +++ b/sysdeps/unix/sysv/linux/pwritev64.c @@ -16,7 +16,7 @@ . */ #include -#include +#include #ifdef __ASSUME_PWRITEV diff --git a/sysdeps/unix/sysv/linux/pwritev64v2.c b/sysdeps/unix/sysv/linux/pwritev64v2.c index 5683220466..329bb820f4 100644 --- a/sysdeps/unix/sysv/linux/pwritev64v2.c +++ b/sysdeps/unix/sysv/linux/pwritev64v2.c @@ -17,7 +17,7 @@ . */ #include -#include +#include #if !defined(__NR_pwritev64v2) && defined(__NR_pwritev2) # define __NR_pwritev64v2 __NR_pwritev2 diff --git a/sysdeps/unix/sysv/linux/read.c b/sysdeps/unix/sysv/linux/read.c index 147d45f242..4d49efa439 100644 --- a/sysdeps/unix/sysv/linux/read.c +++ b/sysdeps/unix/sysv/linux/read.c @@ -17,7 +17,7 @@ . */ #include -#include +#include /* Read NBYTES into BUF from FD. Return the number read or -1. */ ssize_t diff --git a/sysdeps/unix/sysv/linux/read_nocancel.c b/sysdeps/unix/sysv/linux/read_nocancel.c index 9d2a5eedb6..71f7b8776d 100644 --- a/sysdeps/unix/sysv/linux/read_nocancel.c +++ b/sysdeps/unix/sysv/linux/read_nocancel.c @@ -17,7 +17,6 @@ . */ #include -#include #include ssize_t diff --git a/sysdeps/unix/sysv/linux/readv.c b/sysdeps/unix/sysv/linux/readv.c index c0bd1ed6d8..0ed6d91e9a 100644 --- a/sysdeps/unix/sysv/linux/readv.c +++ b/sysdeps/unix/sysv/linux/readv.c @@ -18,7 +18,7 @@ #include #include -#include +#include ssize_t __readv (int fd, const struct iovec *iov, int iovcnt) diff --git a/sysdeps/unix/sysv/linux/recv.c b/sysdeps/unix/sysv/linux/recv.c index 5b28449299..de4dbc4f08 100644 --- a/sysdeps/unix/sysv/linux/recv.c +++ b/sysdeps/unix/sysv/linux/recv.c @@ -16,7 +16,6 @@ . */ #include -#include #include ssize_t diff --git a/sysdeps/unix/sysv/linux/recvfrom.c b/sysdeps/unix/sysv/linux/recvfrom.c index 59115ecea7..6fabaea9c0 100644 --- a/sysdeps/unix/sysv/linux/recvfrom.c +++ b/sysdeps/unix/sysv/linux/recvfrom.c @@ -16,7 +16,6 @@ . */ #include -#include #include ssize_t diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c index bcb5a97f06..157899cfba 100644 --- a/sysdeps/unix/sysv/linux/recvmmsg.c +++ b/sysdeps/unix/sysv/linux/recvmmsg.c @@ -19,7 +19,6 @@ #include #include -#include #include #include #include diff --git a/sysdeps/unix/sysv/linux/recvmsg.c b/sysdeps/unix/sysv/linux/recvmsg.c index f7ae2b9599..a0c17b5468 100644 --- a/sysdeps/unix/sysv/linux/recvmsg.c +++ b/sysdeps/unix/sysv/linux/recvmsg.c @@ -17,7 +17,6 @@ . */ #include -#include #include #include diff --git a/sysdeps/unix/sysv/linux/select.c b/sysdeps/unix/sysv/linux/select.c index 0498970c47..ef1928871b 100644 --- a/sysdeps/unix/sysv/linux/select.c +++ b/sysdeps/unix/sysv/linux/select.c @@ -20,7 +20,6 @@ #include #include #include -#include /* Check the first NFDS descriptors each in READFDS (if not NULL) for read readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS diff --git a/sysdeps/unix/sysv/linux/send.c b/sysdeps/unix/sysv/linux/send.c index 0eaca763c3..bee607dbc8 100644 --- a/sysdeps/unix/sysv/linux/send.c +++ b/sysdeps/unix/sysv/linux/send.c @@ -16,7 +16,6 @@ . */ #include -#include #include ssize_t diff --git a/sysdeps/unix/sysv/linux/sendmmsg.c b/sysdeps/unix/sysv/linux/sendmmsg.c index c53c1b280f..94d78501ac 100644 --- a/sysdeps/unix/sysv/linux/sendmmsg.c +++ b/sysdeps/unix/sysv/linux/sendmmsg.c @@ -19,7 +19,6 @@ #include #include -#include #include #include #include diff --git a/sysdeps/unix/sysv/linux/sendmsg.c b/sysdeps/unix/sysv/linux/sendmsg.c index 42c4250749..827418ab37 100644 --- a/sysdeps/unix/sysv/linux/sendmsg.c +++ b/sysdeps/unix/sysv/linux/sendmsg.c @@ -17,7 +17,6 @@ . */ #include -#include #include #include diff --git a/sysdeps/unix/sysv/linux/sendto.c b/sysdeps/unix/sysv/linux/sendto.c index 78e3b6b2a6..8e91187739 100644 --- a/sysdeps/unix/sysv/linux/sendto.c +++ b/sysdeps/unix/sysv/linux/sendto.c @@ -16,7 +16,6 @@ . */ #include -#include #include ssize_t diff --git a/sysdeps/unix/sysv/linux/sigsuspend.c b/sysdeps/unix/sysv/linux/sigsuspend.c index 40e1e25f75..e707099ef2 100644 --- a/sysdeps/unix/sysv/linux/sigsuspend.c +++ b/sysdeps/unix/sysv/linux/sigsuspend.c @@ -16,7 +16,7 @@ . */ #include -#include +#include /* Change the set of blocked signals to SET, wait until a signal arrives, and restore the set of blocked signals. */ diff --git a/sysdeps/unix/sysv/linux/sigtimedwait.c b/sysdeps/unix/sysv/linux/sigtimedwait.c index 30fc82a249..b69705e354 100644 --- a/sysdeps/unix/sysv/linux/sigtimedwait.c +++ b/sysdeps/unix/sysv/linux/sigtimedwait.c @@ -18,7 +18,6 @@ #include #include #include -#include int __sigtimedwait (const sigset_t *set, siginfo_t *info, diff --git a/sysdeps/unix/sysv/linux/sigwait.c b/sysdeps/unix/sysv/linux/sigwait.c index 360a4d0f5b..420642a550 100644 --- a/sysdeps/unix/sysv/linux/sigwait.c +++ b/sysdeps/unix/sysv/linux/sigwait.c @@ -16,7 +16,6 @@ . */ #include -#include #include int diff --git a/sysdeps/unix/sysv/linux/sigwaitinfo.c b/sysdeps/unix/sysv/linux/sigwaitinfo.c index 64735e4a03..8a95b205d5 100644 --- a/sysdeps/unix/sysv/linux/sigwaitinfo.c +++ b/sysdeps/unix/sysv/linux/sigwaitinfo.c @@ -16,7 +16,6 @@ . */ #include -#include /* Return any pending signal or wait for one for the given time. */ int diff --git a/sysdeps/unix/sysv/linux/socketcall.h b/sysdeps/unix/sysv/linux/socketcall.h index 38af55feb4..5d345b654c 100644 --- a/sysdeps/unix/sysv/linux/socketcall.h +++ b/sysdeps/unix/sysv/linux/socketcall.h @@ -19,6 +19,8 @@ #ifndef _SYS_SOCKETCALL_H #define _SYS_SOCKETCALL_H 1 +#include + /* Define unique numbers for the operations permitted on socket. Linux uses a single system call for all these functions. The relevant code file is /usr/include/linux/net.h. diff --git a/sysdeps/unix/sysv/linux/splice.c b/sysdeps/unix/sysv/linux/splice.c index d9be756718..804e91d1ca 100644 --- a/sysdeps/unix/sysv/linux/splice.c +++ b/sysdeps/unix/sysv/linux/splice.c @@ -17,7 +17,7 @@ . */ #include -#include +#include ssize_t splice (int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, diff --git a/sysdeps/unix/sysv/linux/sync_file_range.c b/sysdeps/unix/sysv/linux/sync_file_range.c index 48ef674746..4649afe6b3 100644 --- a/sysdeps/unix/sysv/linux/sync_file_range.c +++ b/sysdeps/unix/sysv/linux/sync_file_range.c @@ -17,7 +17,7 @@ . */ #include -#include +#include int sync_file_range (int fd, __off64_t offset, __off64_t len, unsigned int flags) diff --git a/sysdeps/unix/sysv/linux/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sysdep-cancel.h deleted file mode 100644 index c861303d36..0000000000 --- a/sysdeps/unix/sysv/linux/sysdep-cancel.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Single-thread optimization definitions. Linux version. - Copyright (C) 2017-2019 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#ifndef _SYSDEP_CANCEL_H -#define _SYSDEP_CANCEL_H - -#include -#include -#include - -/* The two functions are in libc.so and not exported. */ -extern int __libc_enable_asynccancel (void) attribute_hidden; -extern void __libc_disable_asynccancel (int oldtype) attribute_hidden; - -/* The two functions are in librt.so and not exported. */ -extern int __librt_enable_asynccancel (void) attribute_hidden; -extern void __librt_disable_asynccancel (int oldtype) attribute_hidden; - -/* The two functions are in libpthread.so and not exported. */ -extern int __pthread_enable_asynccancel (void) attribute_hidden; -extern void __pthread_disable_asynccancel (int oldtype) attribute_hidden; - -/* Set cancellation mode to asynchronous. */ -#define CANCEL_ASYNC() \ - __pthread_enable_asynccancel () -/* Reset to previous cancellation mode. */ -#define CANCEL_RESET(oldtype) \ - __pthread_disable_asynccancel (oldtype) - -#if IS_IN (libc) -/* Same as CANCEL_ASYNC, but for use in libc.so. */ -# define LIBC_CANCEL_ASYNC() \ - __libc_enable_asynccancel () -/* Same as CANCEL_RESET, but for use in libc.so. */ -# define LIBC_CANCEL_RESET(oldtype) \ - __libc_disable_asynccancel (oldtype) -#elif IS_IN (libpthread) -# define LIBC_CANCEL_ASYNC() CANCEL_ASYNC () -# define LIBC_CANCEL_RESET(val) CANCEL_RESET (val) -#elif IS_IN (librt) -# define LIBC_CANCEL_ASYNC() \ - __librt_enable_asynccancel () -# define LIBC_CANCEL_RESET(val) \ - __librt_disable_asynccancel (val) -#else -# define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */ -# define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */ -#endif - - -#endif diff --git a/sysdeps/unix/sysv/linux/tcdrain.c b/sysdeps/unix/sysv/linux/tcdrain.c index b3691d0b12..70519f2fc0 100644 --- a/sysdeps/unix/sysv/linux/tcdrain.c +++ b/sysdeps/unix/sysv/linux/tcdrain.c @@ -18,7 +18,6 @@ #include #include #include -#include /* Wait for pending output to be written on FD. */ int diff --git a/sysdeps/unix/sysv/linux/tee.c b/sysdeps/unix/sysv/linux/tee.c index 97228e344e..4eba39cfc3 100644 --- a/sysdeps/unix/sysv/linux/tee.c +++ b/sysdeps/unix/sysv/linux/tee.c @@ -17,7 +17,7 @@ . */ #include -#include +#include ssize_t tee (int src, int dest, size_t len, unsigned int flags) diff --git a/sysdeps/unix/sysv/linux/timer_routines.c b/sysdeps/unix/sysv/linux/timer_routines.c index d96d963177..40e3460e43 100644 --- a/sysdeps/unix/sysv/linux/timer_routines.c +++ b/sysdeps/unix/sysv/linux/timer_routines.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include "kernel-posix-timers.h" diff --git a/sysdeps/unix/sysv/linux/vmsplice.c b/sysdeps/unix/sysv/linux/vmsplice.c index 706b933807..cff5afff89 100644 --- a/sysdeps/unix/sysv/linux/vmsplice.c +++ b/sysdeps/unix/sysv/linux/vmsplice.c @@ -18,7 +18,7 @@ #include #include -#include +#include ssize_t vmsplice (int fd, const struct iovec *iov, size_t count, unsigned int flags) diff --git a/sysdeps/unix/sysv/linux/wait.c b/sysdeps/unix/sysv/linux/wait.c index c2385c752e..36deddfdcb 100644 --- a/sysdeps/unix/sysv/linux/wait.c +++ b/sysdeps/unix/sysv/linux/wait.c @@ -19,7 +19,6 @@ #include #include #include -#include /* Wait for a child to die. When one does, put its status in *STAT_LOC and return its process ID. For errors, return (pid_t) -1. */ diff --git a/sysdeps/unix/sysv/linux/waitid.c b/sysdeps/unix/sysv/linux/waitid.c index e563d3e264..45b7baf40b 100644 --- a/sysdeps/unix/sysv/linux/waitid.c +++ b/sysdeps/unix/sysv/linux/waitid.c @@ -19,7 +19,6 @@ #include #include #include -#include int __waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options) diff --git a/sysdeps/unix/sysv/linux/waitpid.c b/sysdeps/unix/sysv/linux/waitpid.c index d35aac01bc..dbd816dbbd 100644 --- a/sysdeps/unix/sysv/linux/waitpid.c +++ b/sysdeps/unix/sysv/linux/waitpid.c @@ -17,7 +17,6 @@ . */ #include -#include #include #include diff --git a/sysdeps/unix/sysv/linux/waitpid_nocancel.c b/sysdeps/unix/sysv/linux/waitpid_nocancel.c index 3697c6b938..82e4fc6e1e 100644 --- a/sysdeps/unix/sysv/linux/waitpid_nocancel.c +++ b/sysdeps/unix/sysv/linux/waitpid_nocancel.c @@ -17,7 +17,6 @@ . */ #include -#include #include #include #include diff --git a/sysdeps/unix/sysv/linux/write.c b/sysdeps/unix/sysv/linux/write.c index 1dfb5de8ee..15dc0fd8e2 100644 --- a/sysdeps/unix/sysv/linux/write.c +++ b/sysdeps/unix/sysv/linux/write.c @@ -17,7 +17,7 @@ . */ #include -#include +#include /* Write NBYTES of BUF to FD. Return the number written, or -1. */ ssize_t diff --git a/sysdeps/unix/sysv/linux/write_nocancel.c b/sysdeps/unix/sysv/linux/write_nocancel.c index f57b53e9c9..589ec6d612 100644 --- a/sysdeps/unix/sysv/linux/write_nocancel.c +++ b/sysdeps/unix/sysv/linux/write_nocancel.c @@ -17,7 +17,6 @@ . */ #include -#include #include ssize_t diff --git a/sysdeps/unix/sysv/linux/writev.c b/sysdeps/unix/sysv/linux/writev.c index 77fc9c92e9..e0621c8546 100644 --- a/sysdeps/unix/sysv/linux/writev.c +++ b/sysdeps/unix/sysv/linux/writev.c @@ -18,7 +18,7 @@ #include #include -#include +#include ssize_t __writev (int fd, const struct iovec *iov, int iovcnt)