From patchwork Thu Aug 10 17:25:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9894303 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 D5DE160236 for ; Thu, 10 Aug 2017 17:28:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAE82288A7 for ; Thu, 10 Aug 2017 17:28:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACF7928932; Thu, 10 Aug 2017 17:28:41 +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 D3AEF288A7 for ; Thu, 10 Aug 2017 17:28:40 +0000 (UTC) Received: (qmail 32510 invoked by uid 550); 10 Aug 2017 17:27:06 -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 32399 invoked from network); 10 Aug 2017 17:27:03 -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=hftptOQTc0gbEeEY99+vP2O7D2WGfRgk+0XqGGLB6Kk=; b=vOWa05npzu25sAoYupd9rD5+UUXpjUn3Z1rTs/iXycXDNcbsLSsL5CmZjNpX0dWyAv SOMEAHYcOHUZJ5yYe01sYHo/hf8EgDTVJPSqdDo1B0vwgBs4r+B9nF8KXe8+hNlPj21S wwAuVJiROxCpII64mquqmmX1vcYskFUdu+8w52FTqoOYtcOK0ceT0C2Kkzu8eHQoAJNA yf2u8SWjbIxuE/dWb3BJ66+SOhwpocNx1At8kb4lACr0aCLCPk3g5P8sgRdCUO8c0kJO GFhusnX4XtURdtv4pSZNgmijs1jLgVK+sysm49O+H4o8t9Vb5FT2WX5w3qB9kGwyYOU+ h4XA== 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=hftptOQTc0gbEeEY99+vP2O7D2WGfRgk+0XqGGLB6Kk=; b=kcRBFPzxwG1Uft0sWB9Rsse/rCtgnC7qhn+7zfFG+tjx6H+BNnexfclsLPyPLamvfE Xj+wp+71qoK13I6JVwlItkXKYCppkqC/7noNzZ/WVz4/WWlzVT9QQ52GfPO4skP+gl+C sd7WY4fNstO6/+i0WlsY5P4vgIwE5IDkFpD1Bn/2z7HCmX74xvl8wU2tSQ4KjLuB2ebv Wh2Z/GvdH9SEkIYPmRMBTidp9/CcADF0p7yYBfAeLdk4N1UHkCUhtwqsn314dZACFJlr NUSJ15tPVwanlz8c/LBiWlSHCObJUnE0yEz7wavBUv8zXyuxS1nzzQDKDdQ99bddPfma QPPg== X-Gm-Message-State: AHYfb5jDWzhgb+oOg3KASV3tbNdVgsWe0oUJn8O+lWrjdlioBnUcu6sw idokcJCEbQ3ttQtT X-Received: by 10.98.204.10 with SMTP id a10mr13351936pfg.332.1502386010781; Thu, 10 Aug 2017 10:26:50 -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:57 -0700 Message-Id: <20170810172615.51965-6-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 05/23] xen: Adapt assembly for PIE support X-Virus-Scanned: ClamAV using ClamSMTP Change the assembly code to use the new _ASM_GET_PTR macro which get a symbol reference while being PIE compatible. Modify the RELOC macro that was using an assignment generating a non-relative reference. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/xen/xen-asm.h | 3 ++- arch/x86/xen/xen-head.S | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/xen/xen-asm.h b/arch/x86/xen/xen-asm.h index 465276467a47..3b1c8a2e77d8 100644 --- a/arch/x86/xen/xen-asm.h +++ b/arch/x86/xen/xen-asm.h @@ -2,8 +2,9 @@ #define _XEN_XEN_ASM_H #include +#include -#define RELOC(x, v) .globl x##_reloc; x##_reloc=v +#define RELOC(x, v) .globl x##_reloc; x##_reloc: _ASM_PTR v #define ENDPATCH(x) .globl x##_end; x##_end=. /* Pseudo-flag used for virtual NMI, which we don't implement yet */ diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S index a7525e95d53f..a98cd42b9832 100644 --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -23,14 +23,15 @@ ENTRY(startup_xen) /* Clear .bss */ xor %eax,%eax - mov $__bss_start, %_ASM_DI - mov $__bss_stop, %_ASM_CX + _ASM_GET_PTR(__bss_start, %_ASM_DI) + _ASM_GET_PTR(__bss_stop, %_ASM_CX) sub %_ASM_DI, %_ASM_CX shr $__ASM_SEL(2, 3), %_ASM_CX rep __ASM_SIZE(stos) - mov %_ASM_SI, xen_start_info - mov $init_thread_union+THREAD_SIZE, %_ASM_SP + _ASM_GET_PTR(xen_start_info, %_ASM_AX) + mov %_ASM_SI, (%_ASM_AX) + _ASM_GET_PTR(init_thread_union+THREAD_SIZE, %_ASM_SP) jmp xen_start_kernel