Message ID | 20180313205945.245105-6-thgarnie@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <kernel-hardening-return-12528-patchwork-kernel-hardening=patchwork.kernel.org@lists.openwall.com> 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 0E83A6038F for <patchwork-kernel-hardening@patchwork.kernel.org>; Tue, 13 Mar 2018 21:02:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 015562675C for <patchwork-kernel-hardening@patchwork.kernel.org>; Tue, 13 Mar 2018 21:02:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E91A526D05; Tue, 13 Mar 2018 21:02:49 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED 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 24C132675C for <patchwork-kernel-hardening@patchwork.kernel.org>; Tue, 13 Mar 2018 21:02:48 +0000 (UTC) Received: (qmail 20204 invoked by uid 550); 13 Mar 2018 21:00:42 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: <mailto:kernel-hardening@lists.openwall.com> List-Help: <mailto:kernel-hardening-help@lists.openwall.com> List-Unsubscribe: <mailto:kernel-hardening-unsubscribe@lists.openwall.com> List-Subscribe: <mailto:kernel-hardening-subscribe@lists.openwall.com> List-ID: <kernel-hardening.lists.openwall.com> Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 20101 invoked from network); 13 Mar 2018 21:00:33 -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=anq4y8bNxKR1s7622CFUgJbP/owDQD029FmsddOFQgw=; b=QRQEv8yTM+oye05G1vyQkNUsrH555ar4MfJCRvTxKMJTFUkFTk9H6P65ffhltQguXM mSLimsEbRu3hmquc5dHxl2zXHCjDDHLMpLuxuYsFuJ1GcjNBfdMePiqhjIjKs9yfyTvc JMsZ5KSrfAWWC1BWRutI48lecWpZs8DqxY0ti16zzJjjhvldVcv0uGri+vAqKgHVYEVQ eRxn1+scBfKq+qfMXzQLCjIGOK7zdkF+sabymrfYpHsDL21moISO+zWobgV9G+brPrW8 ro+s9Of7FIXe1DtJFNFdP2w+xK6Lg+4BxbRHAtxO7K7QkxQnqdslJ5b7aYEt/Qw8TqP3 FhfQ== 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=anq4y8bNxKR1s7622CFUgJbP/owDQD029FmsddOFQgw=; b=DEukLwt4vO0EKr1/1KXY07kMtbIwTVxjnxWvMgZbfINwFyg4W2bH3ijwTxm3h/PJO4 IbUNLTmjZvlpeJ4bbTUgUbG592ds9Nka9XyY0Om/l6OBlFk6yDAs6DINAaPhyBfM6OwD m84WQIxg6/EJGt+tttx3ulpY7XXq0Jwr8gWoI1G7imJychZTI7hE+KGVYZnfZpRpYCrA 0Hew1alaMAZa8TkkdL/xsv30mgn1TV4nqSZhHaiCKpa8JQyFBCg4KJjqLoyUmakkgMF1 XRV+DxYbTFEJof3BUIdb4TGQ70MYws0GhwnxUnp/Yfd+7S0gejdduGzh7OJW+d5j4ZZH 831Q== X-Gm-Message-State: AElRT7E0z9XRUbe5opD5iYk6TmVkKWZXeLkqVEU92NUHzxa/Jx/GB2L4 ifGDqA+5JJTWzxnH6pOsbh5cpQ== X-Google-Smtp-Source: AG47ELv0Q19u3sURJZASC9scNMYyhWeFnCuLSZ1xreSV8lITsSOeooGfUAo23piLUe1+nIhx9gw/yg== X-Received: by 2002:a17:902:bc41:: with SMTP id t1-v6mr1770578plz.56.1520974821592; Tue, 13 Mar 2018 14:00:21 -0700 (PDT) From: Thomas Garnier <thgarnie@google.com> To: Herbert Xu <herbert@gondor.apana.org.au>, "David S . Miller" <davem@davemloft.net>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>, Peter Zijlstra <peterz@infradead.org>, Josh Poimboeuf <jpoimboe@redhat.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Kate Stewart <kstewart@linuxfoundation.org>, Thomas Garnier <thgarnie@google.com>, Arnd Bergmann <arnd@arndb.de>, Philippe Ombredanne <pombredanne@nexb.com>, Arnaldo Carvalho de Melo <acme@redhat.com>, Andrey Ryabinin <aryabinin@virtuozzo.com>, Matthias Kaehlcke <mka@chromium.org>, Kees Cook <keescook@chromium.org>, Tom Lendacky <thomas.lendacky@amd.com>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, Andy Lutomirski <luto@kernel.org>, Dominik Brodowski <linux@dominikbrodowski.net>, Borislav Petkov <bp@alien8.de>, Borislav Petkov <bp@suse.de>, "Rafael J . Wysocki" <rjw@rjwysocki.net>, Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>, Juergen Gross <jgross@suse.com>, Alok Kataria <akataria@vmware.com>, Steven Rostedt <rostedt@goodmis.org>, Tejun Heo <tj@kernel.org>, Christoph Lameter <cl@linux.com>, Dennis Zhou <dennisszhou@gmail.com>, Boris Ostrovsky <boris.ostrovsky@oracle.com>, David Woodhouse <dwmw@amazon.co.uk>, Alexey Dobriyan <adobriyan@gmail.com>, "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>, Andrew Morton <akpm@linux-foundation.org>, Nicolas Pitre <nicolas.pitre@linaro.org>, Randy Dunlap <rdunlap@infradead.org>, "Luis R . Rodriguez" <mcgrof@kernel.org>, Christopher Li <sparse@chrisli.org>, Jason Baron <jbaron@akamai.com>, Ashish Kalra <ashish@bluestacks.com>, Kyle McMartin <kyle@redhat.com>, Dou Liyang <douly.fnst@cn.fujitsu.com>, Lukas Wunner <lukas@wunner.de>, Petr Mladek <pmladek@suse.com>, Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>, Masahiro Yamada <yamada.masahiro@socionext.com>, Ingo Molnar <mingo@kernel.org>, Nicholas Piggin <npiggin@gmail.com>, Cao jin <caoj.fnst@cn.fujitsu.com>, "H . J . Lu" <hjl.tools@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= <rkrcmar@redhat.com>, Joerg Roedel <joro@8bytes.org>, Dave Hansen <dave.hansen@linux.intel.com>, Rik van Riel <riel@redhat.com>, Jia Zhang <qianyue.zj@alibaba-inc.com>, Jiri Slaby <jslaby@suse.cz>, Kyle Huey <me@kylehuey.com>, Jonathan Corbet <corbet@lwn.net>, Matthew Wilcox <mawilcox@microsoft.com>, Michal Hocko <mhocko@suse.com>, Rob Landley <rob@landley.net>, Baoquan He <bhe@redhat.com>, Daniel Micay <danielmicay@gmail.com>, =?UTF-8?q?Jan=20H=20=2E=20Sch=C3=B6nherr?= <jschoenh@amazon.de> 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 Subject: [PATCH v2 05/27] x86: relocate_kernel - Adapt assembly for PIE support Date: Tue, 13 Mar 2018 13:59:23 -0700 Message-Id: <20180313205945.245105-6-thgarnie@google.com> X-Mailer: git-send-email 2.16.2.660.g709887971b-goog In-Reply-To: <20180313205945.245105-1-thgarnie@google.com> References: <20180313205945.245105-1-thgarnie@google.com> X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S index 11eda21eb697..a7227dfe1a2b 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -208,9 +208,11 @@ identity_mapped: movq %rax, %cr3 lea PAGE_SIZE(%r8), %rsp call swap_pages - movq $virtual_mapped, %rax - pushq %rax - ret + jmp *virtual_mapped_addr(%rip) + + /* Absolute value for PIE support */ +virtual_mapped_addr: + .quad virtual_mapped virtual_mapped: movq RSP(%r8), %rsp
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier <thgarnie@google.com> --- arch/x86/kernel/relocate_kernel_64.S | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)