From patchwork Thu Aug 10 17:25:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9894301 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 0484560236 for ; Thu, 10 Aug 2017 17:28:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF5FA286CF for ; Thu, 10 Aug 2017 17:28:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2AAA288A7; Thu, 10 Aug 2017 17:28:10 +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 13EC0286CF for ; Thu, 10 Aug 2017 17:28:09 +0000 (UTC) Received: (qmail 32431 invoked by uid 550); 10 Aug 2017 17:27:04 -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 32342 invoked from network); 10 Aug 2017 17:27:01 -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=zShWk/QxB3u/M1CGcpB4xl1REyHU8cm3b50pMykwbu8=; b=Nq/LQQzt6OAHjlwwqAOtVS9ml0B2TXplt5aCSWAR/mDUkarININkPeM+aXCvj7sQs9 7Zf84huaZzrdq6Ft6dVaWJrmcY/AlAKOiLyuOfBzUcXzWVOQoTOXCNSR+RsopsApzE2T EzM7/09hsq0i/wGRns7Vv76w+7OPC8QrcyljNys6lQ4HL1ilRv6Zr0VYwTIWx6XrXQbo LwJmI74b+wAUSSa+taCkRawCfczWx1AcF6oI2T86+vF2DOs1jlHnol4+wAbD/JuCg6bE kmnaN3XE6+NdWKkJO9N8FgS4jQ66bVT3bZKzPFfSO4LOr0uHPWtUHl88dm/2BlL0GxNg JdFg== 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=zShWk/QxB3u/M1CGcpB4xl1REyHU8cm3b50pMykwbu8=; b=VeJ5JKLKATpnElv0awnojJCVztHFmAnpUFc8cXnNraUJ9UnTB0UyWd9cbvwPlfvyOa cUGjcwAR8+WSwmJfHVxKjvUy9eilk/noG8YLBxz0C5urqEjOxWuouBLlXU5Z1PFDpqbY 2UEQyfB4/3EPExcTEwnvIPaDdv61Ko6Yw3QEpvQW/jG/splAIVn0nanPU97tw3FU5Xof 9fA4esI4uTSnwEjF7/lWr/NF3nJfYKxUPtOnUNT99UjEmvCGof24N1W+fMaTMZ7Stbss zllU42q3nMBpx7+MtHpi9w/UwElB5uOHbPUKhiULQCMEaOAMdmYt/cc9+5l4FRDFqzUl FCAA== X-Gm-Message-State: AHYfb5grkpMD1KyxFfBId09Gg7+GLhJp42sVEMIuX5Mivpu9KrzEdGJ9 35OtER2zvSW3LePn X-Received: by 10.84.218.4 with SMTP id q4mr14140309pli.202.1502386009257; Thu, 10 Aug 2017 10:26:49 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Arnd Bergmann , Thomas Garnier , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Tom Lendacky , Andy Lutomirski , Borislav Petkov , Brian Gerst , "Kirill A . Shutemov" , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph Lameter , Paul Gortmaker , Chris Metcalf , Andrew Morton , "Paul E . McKenney" , Nicolas Pitre , Christopher Li , "Rafael J . Wysocki" , Lukas Wunner , Mika Westerberg , Dou Liyang , Daniel Borkmann , Alexei Starovoitov , Masahiro Yamada , Markus Trippelsdorf , Steven Rostedt , Kees Cook , Rik van Riel , David Howells , Waiman Long , Kyle Huey , Peter Foley , Tim Chen , Catalin Marinas , Ard Biesheuvel , Michal Hocko , Matthew Wilcox , "H . J . Lu" , Paul Bolle , Rob Landley , 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: Thu, 10 Aug 2017 10:25:56 -0700 Message-Id: <20170810172615.51965-5-thgarnie@google.com> X-Mailer: git-send-email 2.14.0.434.g98096fd7a8-goog In-Reply-To: <20170810172615.51965-1-thgarnie@google.com> References: <20170810172615.51965-1-thgarnie@google.com> Subject: [kernel-hardening] [RFC v2 04/23] 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) \