From patchwork Wed Oct 4 21:19:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9985501 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 EA4E0605A8 for ; Wed, 4 Oct 2017 21:22:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB37128450 for ; Wed, 4 Oct 2017 21:22:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEB8C28C2E; Wed, 4 Oct 2017 21:22:29 +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 0E6B928450 for ; Wed, 4 Oct 2017 21:22:28 +0000 (UTC) Received: (qmail 15385 invoked by uid 550); 4 Oct 2017 21:21:07 -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 14277 invoked from network); 4 Oct 2017 21:21:04 -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=qxhzPZTaFBGRNDu496VGfa1SIWBE4kU/BDtdTQ/8vJs=; b=Btk2aGJZ5MXZ3HOaxiZRPBlIclNCAZXSrRk59++dXHKKRFuNzfpdgc5/5pTEtUlSl+ 0r4uks+iuIh7q2bPWrW9vcmKj996M4GHoZ29+YczdfbK6iSK3Lv9IcyWGkHhrqwQ770m JT77qqV5ZfUK9MbTMPx+9ezez9KFaInQE+H4KXjijlgwPoXk8Sg8Sr0HacsdUSllV2ob 4PwYrBt+5obTfSZoh/JvzgXBFxB9KqidWvy3Vp3IG+lRMZGB9b2lp8Gm+Kbywb4ov3EU 9Vr+Tq76LGQKDn6UAkX1PHO7NFF9+TXkRJf/unHolbVkqWFKKwsint/PHg/UEyvVYDZs Dd8A== 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=qxhzPZTaFBGRNDu496VGfa1SIWBE4kU/BDtdTQ/8vJs=; b=oWjFAYy6se0GrPk4yLqTzvxZkFg16PjlNqlV9ktEmxsBez4WuNNbYjDENYPrHiWZm8 m4us6TNfn77GErmYQzDGu3x5o9EhZ7RtlPrIU19k0BKThzfcpF2kVLJ/OCDQ2N1MzVEK H16bRbTbDjyOJFZYOOvIeZ/stqWwtMik8almvB/5lVc8ku6trwuL3zuNrUHGFI/TL4y9 RCthGrZ0T0jFEQRgpw19Id//Ol1fpiP3/HeKt5qq3tcX4NA9pkaCZ4SUaUzG91FBCMn2 fb1uk/51Zre0RSYxtl/Z92H3cEelJ71jRIjw/EngP2FL+FWw9Vsmv4BtS5WuEWyGVHxj 71lw== X-Gm-Message-State: AHPjjUhohvuGL5WUrhwvCO6iInj18GC+w3IXGd0sFYx61BdbfnZPVBRF /sCurnpBLPP1Km3tbvobSv9VXw== X-Google-Smtp-Source: AOwi7QACX+MswoQzYUyCakWmL6YSnJQmJ2kxeAXNBoqsyxDcVrXwRWqptSovjUmm47d1NNCXFulcmg== X-Received: by 10.84.174.129 with SMTP id r1mr20631987plb.390.1507152052102; Wed, 04 Oct 2017 14:20:52 -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 , Kees Cook , Matthias Kaehlcke , Tom Lendacky , Andy Lutomirski , "Kirill A . Shutemov" , Borislav Petkov , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Juergen Gross , Chris Wright , Alok Kataria , Rusty Russell , Tejun Heo , Christoph Lameter , Boris Ostrovsky , Alexey Dobriyan , Andrew Morton , Paul Gortmaker , Chris Metcalf , "Paul E . McKenney" , Nicolas Pitre , Borislav Petkov , "Luis R . Rodriguez" , Greg Kroah-Hartman , Christopher Li , Steven Rostedt , Jason Baron , Dou Liyang , "Rafael J . Wysocki" , Mika Westerberg , Lukas Wunner , Masahiro Yamada , Alexei Starovoitov , Daniel Borkmann , Markus Trippelsdorf , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Rik van Riel , David Howells , Ard Biesheuvel , Waiman Long , Kyle Huey , Andrey Ryabinin , Jonathan Corbet , Matthew Wilcox , Michal Hocko , Peter Foley , Paul Bolle , Jiri Kosina , Rob Landley , "H . J . Lu" , Baoquan He , =?UTF-8?q?Jan=20H=20=2E=20Sch=C3=B6nherr?= , Daniel Micay Cc: x86@kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, virtualization@lists.linux-foundation.org, xen-devel@lists.xenproject.org, linux-arch@vger.kernel.org, linux-sparse@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, kernel-hardening@lists.openwall.com Date: Wed, 4 Oct 2017 14:19:40 -0700 Message-Id: <20171004212003.28296-5-thgarnie@google.com> X-Mailer: git-send-email 2.14.2.920.gcf0c67979c-goog In-Reply-To: <20171004212003.28296-1-thgarnie@google.com> References: <20171004212003.28296-1-thgarnie@google.com> Subject: [kernel-hardening] [RFC v3 04/27] 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 c1eadbaf1115..dddcb8a3b777 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) \