From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68315 invoked by alias); 30 Jan 2018 19:31:39 -0000 Mailing-List: contact libc-stable-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: List-Archive: Sender: libc-stable-owner@sourceware.org Received: (qmail 68304 invoked by uid 89); 30 Jan 2018 19:31:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KAM_SHORT,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-Spam-Status: No, score=-24.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KAM_SHORT,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: mo19.mail-out.ovh.net Received: from mo19.mail-out.ovh.net (HELO mo19.mail-out.ovh.net) (178.32.228.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 30 Jan 2018 19:31:37 +0000 Received: from EX2.emp.local (gw1.pro1.mail.ovh.net [79.137.0.65]) by mo19.mail-out.ovh.net (Postfix) with ESMTPS id 1384528CC3 for ; Tue, 30 Jan 2018 20:31:35 +0100 (CET) Received: from localhost (32.104.18.202) by EX2.emp.local (172.16.2.2) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1261.35; Tue, 30 Jan 2018 20:31:34 +0100 From: "Gabriel F. T. Gomes" To: Subject: [2.25 2/2] powerpc: Fix syscalls during early process initialization [BZ #22685] Date: Mon, 01 Jan 2018 00:00:00 -0000 Message-ID: <20180130193123.527-3-gabriel@inconstante.eti.br> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180130193123.527-1-gabriel@inconstante.eti.br> References: <20180130193123.527-1-gabriel@inconstante.eti.br> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [32.104.18.202] X-ClientProxiedBy: EX3.emp.local (172.16.2.3) To EX2.emp.local (172.16.2.2) X-Ovh-Tracer-Id: 14417992732939439800 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtfedrtddtgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenuc X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00061.txt.bz2 From: Tulio Magno Quites Machado Filho The tunables framework needs to execute syscall early in process initialization, before the TCB is available for consumption. This behavior conflicts with powerpc{|64|64le}'s lock elision code, that checks the TCB before trying to abort transactions immediately before executing a syscall. This patch adds a powerpc-specific implementation of __access_noerrno that does not abort transactions before the executing syscall. Tested on powerpc{|64|64le}. [BZ #22685] * sysdeps/powerpc/powerpc32/sysdep.h (ABORT_TRANSACTION_IMPL): Renamed from ABORT_TRANSACTION. (ABORT_TRANSACTION): Redirect to ABORT_TRANSACTION_IMPL. * sysdeps/powerpc/powerpc64/sysdep.h (ABORT_TRANSACTION, ABORT_TRANSACTION_IMPL): Likewise. * sysdeps/unix/sysv/linux/powerpc/not-errno.h: New file. Reuse Linux code, but remove the code that aborts transactions. Signed-off-by: Tulio Magno Quites Machado Filho Tested-by: Aurelien Jarno (cherry picked from commit 4612268a0ad8e3409d8ce2314dd2dd8ee0af5269) --- ChangeLog | 11 +++++++++++ NEWS | 1 + sysdeps/powerpc/powerpc32/sysdep.h | 5 +++-- sysdeps/powerpc/powerpc64/sysdep.h | 5 +++-- sysdeps/unix/sysv/linux/powerpc/not-errno.h | 30 +++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/powerpc/not-errno.h diff --git a/ChangeLog b/ChangeLog index ea0a24adf9..a198edd947 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2018-01-19 Tulio Magno Quites Machado Filho + + [BZ #22685] + * sysdeps/powerpc/powerpc32/sysdep.h (ABORT_TRANSACTION_IMPL): Renamed + from ABORT_TRANSACTION. + (ABORT_TRANSACTION): Redirect to ABORT_TRANSACTION_IMPL. + * sysdeps/powerpc/powerpc64/sysdep.h (ABORT_TRANSACTION, + ABORT_TRANSACTION_IMPL): Likewise. + * sysdeps/unix/sysv/linux/powerpc/not-errno.h: New file. Reuse + Linux code, but remove the code that aborts transactions. + 2017-07-24 Adhemerval Zanella H.J. Lu diff --git a/NEWS b/NEWS index 4c4eb834a1..40eded2158 100644 --- a/NEWS +++ b/NEWS @@ -72,6 +72,7 @@ The following bugs are resolved with this release: [22637] nptl: Fix stack guard size accounting [22679] getcwd(3) can succeed without returning an absolute path (CVE-2018-1000001) + [22685] powerpc: Fix syscalls during early process initialization [22715] x86-64: Properly align La_x86_64_retval to VEC_SIZE Version 2.25 diff --git a/sysdeps/powerpc/powerpc32/sysdep.h b/sysdeps/powerpc/powerpc32/sysdep.h index f92ab2cded..2ece0e0686 100644 --- a/sysdeps/powerpc/powerpc32/sysdep.h +++ b/sysdeps/powerpc/powerpc32/sysdep.h @@ -89,7 +89,7 @@ GOT_LABEL: ; \ ASM_SIZE_DIRECTIVE(name) #if ! IS_IN(rtld) && defined (ENABLE_LOCK_ELISION) -# define ABORT_TRANSACTION \ +# define ABORT_TRANSACTION_IMPL \ cmpwi 2,0; \ beq 1f; \ lwz 0,TM_CAPABLE(2); \ @@ -100,8 +100,9 @@ GOT_LABEL: ; \ .align 4; \ 1: #else -# define ABORT_TRANSACTION +# define ABORT_TRANSACTION_IMPL #endif +#define ABORT_TRANSACTION ABORT_TRANSACTION_IMPL #define DO_CALL(syscall) \ ABORT_TRANSACTION \ diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h index db7c1d78b5..8133156031 100644 --- a/sysdeps/powerpc/powerpc64/sysdep.h +++ b/sysdeps/powerpc/powerpc64/sysdep.h @@ -273,7 +273,7 @@ LT_LABELSUFFIX(name,_name_end): ; \ END_2(name) #if !IS_IN(rtld) && defined (ENABLE_LOCK_ELISION) -# define ABORT_TRANSACTION \ +# define ABORT_TRANSACTION_IMPL \ cmpdi 13,0; \ beq 1f; \ lwz 0,TM_CAPABLE(13); \ @@ -284,8 +284,9 @@ LT_LABELSUFFIX(name,_name_end): ; \ .align 4; \ 1: #else -# define ABORT_TRANSACTION +# define ABORT_TRANSACTION_IMPL #endif +#define ABORT_TRANSACTION ABORT_TRANSACTION_IMPL #define DO_CALL(syscall) \ ABORT_TRANSACTION \ diff --git a/sysdeps/unix/sysv/linux/powerpc/not-errno.h b/sysdeps/unix/sysv/linux/powerpc/not-errno.h new file mode 100644 index 0000000000..27da21bdf1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/not-errno.h @@ -0,0 +1,30 @@ +/* Syscall wrapper that do not set errno. Linux powerpc version. + Copyright (C) 2018 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 + . */ + +/* __access_noerrno is used during process initialization in elf/dl-tunables.c + before the TCB is initialized, prohibiting the usage of + ABORT_TRANSACTION. */ +#undef ABORT_TRANSACTION +#define ABORT_TRANSACTION + +#include "sysdeps/unix/sysv/linux/not-errno.h" + +/* Recover ABORT_TRANSACTION's previous value, in order to not affect + other syscalls. */ +#undef ABORT_TRANSACTION +#define ABORT_TRANSACTION ABORT_TRANSACTION_IMPL -- 2.13.6