From patchwork Tue Dec 12 14:02:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 24890 Received: (qmail 104673 invoked by alias); 12 Dec 2017 14:03:08 -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 104632 invoked by uid 89); 12 Dec 2017 14:03:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 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.2 spammy=Hx-languages-length:2933 X-HELO: mail-qt0-f194.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=W96734xKiacu77+tudvQ/rrJCcq0o86x+y6aU32mNss=; b=uNC8e2FU2bQFDpGFcebJ0Wp+CNJKDdY6Z5HuEaIKfmqAuk4Ksqax0DqM725T5RgHth c0i9xLJ07ONIuHP2V7MfR4Lo6D50zpUf+ciBiuGVDU9n9uzZOKybIkdi+KuFYElC0KZe GZVmvBR5+Lvu+DX59xsmRn7DHXE/ThrFM1KjL5EhURY2DXh5bjuE0y6wm4xuSyC77rAG lAQBUBbZlo2O1/IEUjCNFpBSAdeBF46y514VGYED14lf3zLY8UPmxhxW+7QPwTzwPd15 ukdMkQ8DRB39w0gqhvBjohCUQcT3DLC67FawbJmWQ1tCh6OOEkibGC44y8wVep7DJ/q6 1eyg== X-Gm-Message-State: AKGB3mLlY4RESKTIzRq6EZaCH7DSIyZlCATPYcfDktPdQ3GXlw0w+0HV MUb7QU6+Yrp3QmNR/bVXWa5fuE6bmQs= X-Google-Smtp-Source: ACJfBoukjiAfERyvlNpUdxszDq5yfOQxmNTlIfbU1doUmTN2vfwLAjC1x5xVtHL2PyyfiZY6U2+u0A== X-Received: by 10.200.43.24 with SMTP id 24mr5346640qtu.153.1513087382981; Tue, 12 Dec 2017 06:03:02 -0800 (PST) Subject: Re: [PATCH 08/19] nptl: arm: Fix Race conditions in pthread cancellation (BZ#12683) To: Joseph Myers Cc: libc-alpha@sourceware.org References: <1513019223-7603-1-git-send-email-adhemerval.zanella@linaro.org> <1513019223-7603-9-git-send-email-adhemerval.zanella@linaro.org> <3ba66158-2eb1-029c-305f-725a7bebd275@linaro.org> From: Adhemerval Zanella Message-ID: <4cab20d3-fa04-ab73-1275-025ee6d8580c@linaro.org> Date: Tue, 12 Dec 2017 12:02:57 -0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: On 12/12/2017 11:51, Joseph Myers wrote: > On Tue, 12 Dec 2017, Adhemerval Zanella wrote: > >> So I am not sure we need all the CFI directives to enable cancellation work >> on ARM (at least current syscall wrappers which use C version of >> {INLINE,INTERNAL}_SYSCALL are not generating them). > > The cfi_* on ARM are for debugging, not for cancellation (and so to get > corresponding output from the compiler you'd need to compile with -g). > ARM uses ".cfi_sections .debug_frame". > Right, I think we can let the compiler generate the correct info in such cases. Below there is an updated patch that removes the arch specific implementation. I need to adjust the syscall_cancel from 02/19 patch to uses a '%' mark for function symbol declaration (the version I sent uses a '@' which ARM gas interprets as a inline comment). --- This patch adds the ARM modifications required for the BZ#12683. It basically adds the required ucontext_get_pc function and adjust the generic syscall_cancel build. For ARM we need to build syscall_cancel in ARM mode (-marm) to avoid INTERNAL_SYSCALL to issue the syscall through the helper gate __libc_do_syscall (which invalidates the mark checks on SIGCANCEL handler). Checked on arm-linux-gnueabihf. * sysdeps/unix/sysv/linux/arm/Makefile (CFLAGS-syscall_cancel.c): New rule. * sysdeps/unix/sysv/linux/arm/sigcontextinfo.h (ucontext_get_pc): New function. Signed-off-by: Adhemerval Zanella --- ChangeLog | 5 +++++ sysdeps/unix/sysv/linux/arm/Makefile | 3 +++ sysdeps/unix/sysv/linux/arm/sigcontextinfo.h | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/sysdeps/unix/sysv/linux/arm/Makefile b/sysdeps/unix/sysv/linux/arm/Makefile index 4adc35d..8f01b52 100644 --- a/sysdeps/unix/sysv/linux/arm/Makefile +++ b/sysdeps/unix/sysv/linux/arm/Makefile @@ -30,6 +30,9 @@ endif ifeq ($(subdir),nptl) libpthread-sysdep_routines += libc-do-syscall libpthread-shared-only-routines += libc-do-syscall + +# INLINE_SYSCALL uses the helper __libc_do_syscall in thumb mode. +CFLAGS-syscall_cancel.c += -marm endif ifeq ($(subdir),resolv) diff --git a/sysdeps/unix/sysv/linux/arm/sigcontextinfo.h b/sysdeps/unix/sysv/linux/arm/sigcontextinfo.h index d3313af..8132a95 100644 --- a/sysdeps/unix/sysv/linux/arm/sigcontextinfo.h +++ b/sysdeps/unix/sysv/linux/arm/sigcontextinfo.h @@ -16,6 +16,10 @@ License along with the GNU C Library. If not, see . */ +#ifndef _SIGCONTEXTINFO_H +#define _SIGCONTEXTINFO_H + +#include #include #define SIGCONTEXT siginfo_t *_si, ucontext_t * @@ -46,3 +50,11 @@ (act)->sa_flags |= SA_SIGINFO; \ (sigaction) (sig, act, oact); \ }) + +static inline uintptr_t +ucontext_get_pc (const ucontext_t *uc) +{ + return uc->uc_mcontext.arm_pc; +} + +#endif /* _SIGCONTEXTINFO_H */