From patchwork Tue Jul 18 22:33:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9850023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5D2B760392 for ; Tue, 18 Jul 2017 22:35:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 484861FF15 for ; Tue, 18 Jul 2017 22:35:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A967203C0; Tue, 18 Jul 2017 22:35:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 7071A1FF15 for ; Tue, 18 Jul 2017 22:35:10 +0000 (UTC) Received: (qmail 26085 invoked by uid 550); 18 Jul 2017 22:34:28 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 25992 invoked from network); 18 Jul 2017 22:34:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pYvte0CEMI7S7pZS+4EhVQ2NmcyX9nSjsV1ZTU3E+8U=; b=BMeRn3DBXpZka+qCVcgzApdqysydHXksd9uWGDSzlFywB6y5v+63MriePzL+e0QpKS K2KAackxJw+Fd+m1RmUhLrtjQWiY7MHtbueLbQjYQsRPOpJ9Bk3cPmymgp5c+aDdXiWS YCYCA9q+WfXfbTioAcs31AhKZoMwPUSR2wKtp07arZGy7+KlJK7XB0KU5PnXpvbzCUH6 8uc2fNx9n5wzGgRf+kGBGFQcCWl33a2vsKJG8X1xywZ4Rc0r1aUyzMmp2QqjXg7f/S1p NPxfQsK+JGWtUioksbNWcIJ65Z0MFxEehRY8r+Y6JlcvLxCRvErP2GvxDAwGKIeLXQ48 B33Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pYvte0CEMI7S7pZS+4EhVQ2NmcyX9nSjsV1ZTU3E+8U=; b=A8I9+ln2mIbCfin35tCRtwrrvTYmrAwm+cXrfMWDfAvDQfU5Fr4f+lYRe0+KnvKu7H hir2HTdOuzWtlnSXcJP3iQS1Lj/e6dbLvNfkEeD5oxRbzgX3A+kD33CX4IjczRRtKHwO 020Um+rtoXaUoJcIJ/RK+T7L7aqYVRF2XfVg3Gg/kXn1vszlfMEgG80zbgJjjas++S01 JRdR/iBRo+ZGz5nh0QaPwAQK1J4edyzEI9ksBAkGZjyaDiGILO+JAQUHaAMmFUr6N66J Y2ndgJGabvsEnsAEvyW3/4xBETItvTqrUTZIW4u9lr9RmIEJkAUk7+PwXiVPNypL0+zX Ug0g== X-Gm-Message-State: AIVw111eeUkZpCgenTwzpD22G360+tQacNPI2/bnVMLM4D4p025uNoqK qBTkCSTUsVNQV1Z7 X-Received: by 10.84.231.198 with SMTP id g6mr4128063pln.110.1500417254864; Tue, 18 Jul 2017 15:34:14 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Thomas Garnier , Arnd Bergmann , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Andy Lutomirski , Borislav Petkov , "Kirill A . Shutemov" , Brian Gerst , Borislav Petkov , Christian Borntraeger , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph Lameter , Kees Cook , Paul Gortmaker , Chris Metcalf , "Paul E . McKenney" , Andrew Morton , Christopher Li , Dou Liyang , Masahiro Yamada , Daniel Borkmann , Markus Trippelsdorf , Peter Foley , Steven Rostedt , Tim Chen , Ard Biesheuvel , Catalin Marinas , Matthew Wilcox , Michal Hocko , Rob Landley , Jiri Kosina , "H . J . Lu" , Paul Bolle , Baoquan He , Daniel Micay Cc: x86@kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org, linux-arch@vger.kernel.org, linux-sparse@vger.kernel.org, kernel-hardening@lists.openwall.com Date: Tue, 18 Jul 2017 15:33:15 -0700 Message-Id: <20170718223333.110371-5-thgarnie@google.com> X-Mailer: git-send-email 2.13.2.932.g7449e964c-goog In-Reply-To: <20170718223333.110371-1-thgarnie@google.com> References: <20170718223333.110371-1-thgarnie@google.com> Subject: [kernel-hardening] [RFC 04/22] x86: Add macro to get symbol address for PIE support X-Virus-Scanned: ClamAV using ClamSMTP Add a new _ASM_GET_PTR macro to fetch a symbol address. It will be used to replace "_ASM_MOV $, %dst" code construct that are not compatible with PIE. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/asm.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h index 7a9df3beb89b..bf2842cfb583 100644 --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -55,6 +55,19 @@ # define CC_OUT(c) [_cc_ ## c] "=qm" #endif +/* Macros to get a global variable address with PIE support on 64-bit */ +#ifdef CONFIG_X86_32 +#define __ASM_GET_PTR_PRE(_src) __ASM_FORM_COMMA(movl $##_src) +#else +#ifdef __ASSEMBLY__ +#define __ASM_GET_PTR_PRE(_src) __ASM_FORM_COMMA(leaq (_src)(%rip)) +#else +#define __ASM_GET_PTR_PRE(_src) __ASM_FORM_COMMA(leaq (_src)(%%rip)) +#endif +#endif +#define _ASM_GET_PTR(_src, _dst) \ + __ASM_GET_PTR_PRE(_src) __ASM_FORM(_dst) + /* Exception table entry */ #ifdef __ASSEMBLY__ # define _ASM_EXTABLE_HANDLE(from, to, handler) \