From patchwork Wed Oct 11 20:30:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10000525 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 E973F6037F for ; Wed, 11 Oct 2017 20:32:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDDCF28B37 for ; Wed, 11 Oct 2017 20:32:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D16CE28B6A; Wed, 11 Oct 2017 20:32:40 +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 0072828B37 for ; Wed, 11 Oct 2017 20:32:39 +0000 (UTC) Received: (qmail 14048 invoked by uid 550); 11 Oct 2017 20:31:24 -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 13793 invoked from network); 11 Oct 2017 20:31:21 -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=WgaGdBoEdCmGHH5J4C4gfBypM6FH+TSGQCxawak1NRc=; b=t1B+7bXu2FL1QpNAt/xEtTxO/h486gi5jBo/pQaMfEouXX8J5aVG5GPoB1M0aqtG0f B5/SrSSqf6e6uEprFbIrmslnB902kNyygzrNBfn6bGkZUqvGbvIYCkAGpEPABNJIvv8h Fy/XXfnCN2uC3ovISDLNOrca0MqSBSzHLYM+su34+YiLIozBImDVZ+xuqij4ngrOLKcD 7VLiYQ3IJbc6vSz3BSKIo3vL+qTeA5RYSmZgd+jybL3T2/1gxm9OL2mq/j2mRnkyJl5x 6AoNs2hxqm6B40oT1qUc8mF22oxmqNfey3nfGyF9bCGUInljIWPLBDKiDzzQhKxL8b+L Rt9A== 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=WgaGdBoEdCmGHH5J4C4gfBypM6FH+TSGQCxawak1NRc=; b=dMiqxbPaOHw1gRKWUiWbGGvxWfE647D8370IqSD69N7uzuFbt3DlA7Xc52g3AnpJ2T lkaaxllt7cSne6ti1xLt7FOTv31WZWp9U87F4Da1eIbBSjlZwN4BOHpZzIgBOPSXQwGI LCR+8ALgp+1psiQ5d9bVheVQAYiEt2T/6R03p5HdUGGDsAfFMwZWXAupj/5YGUxKw9F5 0kXInmDl8JDdWflbz4UeJCB8AqEd37CwO1Ea9mGTpVV7a4iLlyp1/dcbBj0N6nz1InsN 84kIfznjtrYP0r8rSfoXEI+9xZjxAkXqbuqwqr/NqZRL2xpGLNVlmL8ax2w2NxI3s//N a6oA== X-Gm-Message-State: AMCzsaWXbhqEPTVE2l2jvhL+j9xnAWYEBi/6kf1Rw2tX2tx1gJgexaNW 4s8B1pDIwQRWZF457Nc2n891oA== X-Google-Smtp-Source: AOwi7QCKZm0HwtbIZu8EWfa/SWmfGwSza5oq8N9XCpm/WKOm1yW17s6XltiZcHr4dGp1hmaKtDrlGQ== X-Received: by 10.101.68.133 with SMTP id l5mr181973pgq.332.1507753869433; Wed, 11 Oct 2017 13:31:09 -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 , Kees Cook , Andrey Ryabinin , 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 , Paul Gortmaker , Andrew Morton , Alexey Dobriyan , "Paul E . McKenney" , Nicolas Pitre , Borislav Petkov , "Luis R . Rodriguez" , Greg Kroah-Hartman , Christopher Li , Steven Rostedt , Jason Baron , Mika Westerberg , Dou Liyang , "Rafael J . Wysocki" , 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 , Jonathan Corbet , Michal Hocko , Peter Foley , Paul Bolle , Jiri Kosina , "H . J . Lu" , Rob Landley , 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, 11 Oct 2017 13:30:04 -0700 Message-Id: <20171011203027.11248-5-thgarnie@google.com> X-Mailer: git-send-email 2.15.0.rc0.271.g36b669edcc-goog In-Reply-To: <20171011203027.11248-1-thgarnie@google.com> References: <20171011203027.11248-1-thgarnie@google.com> Subject: [kernel-hardening] [PATCH v1 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 b0dc91f4bedc..6de365b8e3fd 100644 --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -57,6 +57,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) \