From patchwork Mon Feb 26 21:03:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 26083 Received: (qmail 76049 invoked by alias); 26 Feb 2018 21:04:02 -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 75884 invoked by uid 89); 26 Feb 2018 21:04:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 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= X-HELO: mail-qt0-f195.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=rAUuEneS+qPytZgXsnbUyy6v3Qv7It8G30fXgEteDVA=; b=EblDODW7SY/a4dlEBiLY1mXQ9FMOuxpBstH7vzcEwrFZ/v7M+571I6Bv9++WIeumhT iP9FfCQmgfTOUmwoukI0uO+vTD+G3LpkB968Q6OUTzHdEE5JFGNWPVmciTWoUcaO6GeZ imaWEJQ8Xywh1wWaO3CHQugafpqgzBCpO26gpmS3Ohcf4nlNusKahWpvo8iCs+Ki4FME jqeuuDoEgmR8xR5qACXVMeSyJhSDsa1MGPboTD7ddEK6JwqboZtsNzNqF0KiFCVhDvtU nVSAjOfodFBx4GDBlqP4Paz1Wbf/ui8VzyUaen6Z/VaX9MbqFayHMc+Ntg2+pPGYZGMp pYZw== X-Gm-Message-State: APf1xPBknFqfKn6mlybWeEpe3L1i/gcgeo51yppy/feij9ZlUJIb21GU yKIII/+uw9p7jF+Sx5gGuBBp7Wf39sA= X-Google-Smtp-Source: AG47ELt/kj6jjpLmZelHgnty0Po8cVuVVwOp77YEAhtsUXMS9u3d826xI7VAPDp5dAA1el7agY+igg== X-Received: by 10.200.49.28 with SMTP id g28mr19193317qtb.279.1519679037602; Mon, 26 Feb 2018 13:03:57 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 09/21] nptl: arm: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 26 Feb 2018 18:03:24 -0300 Message-Id: <1519679016-12241-10-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1519679016-12241-1-git-send-email-adhemerval.zanella@linaro.org> References: <1519679016-12241-1-git-send-email-adhemerval.zanella@linaro.org> 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. [BZ #12683] * sysdeps/unix/sysv/linux/arm/Makefile (CFLAGS-syscall_cancel.c): New rule. * sysdeps/unix/sysv/linux/arm/sigcontextinfo.h (ucontext_get_pc): New function. --- ChangeLog | 6 ++++++ sysdeps/unix/sysv/linux/arm/Makefile | 3 +++ sysdeps/unix/sysv/linux/arm/sigcontextinfo.h | 12 ++++++++++++ 3 files changed, 21 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 daf9bd3..3d4eb2f 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 */