From patchwork Thu Aug 10 17:26:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9894363 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 3B00360236 for ; Thu, 10 Aug 2017 17:30:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20B5528AE2 for ; Thu, 10 Aug 2017 17:30:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DF9B28A92; Thu, 10 Aug 2017 17:30:42 +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 402AD28AE2 for ; Thu, 10 Aug 2017 17:30:40 +0000 (UTC) Received: (qmail 1747 invoked by uid 550); 10 Aug 2017 17:27:25 -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 1335 invoked from network); 10 Aug 2017 17:27:14 -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=b0fcYsbNXGzh+lAqdO+baN7EXWCsgWP+gawHCo4/DDk=; b=geQxQD7hWZpd9vUSMEohWCkI3qmasSo9kzniYnAve8VUoBA3q5yPMyczgCg78nHOWH ndQTx9U7Q7B8E9Ski0Wue7WgCYxAu+8S5Q/RcbLgwDkxziPqpEWjyz07TOIwMtbEZV3P YbbbBjWjz45Sorr4TFbxcdKJgUVxzKWNpD4NKnwCfNISxA1pZ0oDcMKIUzqlccgvojwv phZPrw0feMMLHgbONOhitG/C+KS4Km8kOITXvr/yFe7K/1htd3Vbs9cnI9JK7CLRl7Qz DgSYHFvlYFdhFiC/AIa2WLCB73XJ93EdMGCnqoRMiFTSxjpPvo+IL3tzT79EeTnVd2Fc Ylrw== 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=b0fcYsbNXGzh+lAqdO+baN7EXWCsgWP+gawHCo4/DDk=; b=oI8LeWzf1lT8R43Gp8m9uJFQmrpB2msP9VY7GnIqx9s1Wmew0xb5dnlSuFFlf9S+Dt xIDYyklwNwjLq7Fi8WQq2Mn68CL/XsE5tSM1bmEkDNwz0fTn2n2G3LjA7d9oV13ex+Iz b3H+QhmgvqcVCCvEtNP7ibduFUgSxrpq/ZcS0hzCE8pOPyPv7jSAjhgcFe5IbRjStb6/ K6axdbtGZSQegcjEo3UDLCwPpAr7SMQgS3G1uW0Ei6aY85b4uQDz/dQYV/B4EaqLIeFd /Sli5j2KMFYCxX1SwHPod47RZ58ZN75LG6P5nEiW/MQlVfqdaiBjSu9hVuDn89qJUec+ TqeQ== X-Gm-Message-State: AHYfb5jnvdBNwAbcfX7keAIVSsfk2MJ/mWe95rcJYQtVHQmTEVv8iH6N 6ZSSynCEYfJe+JXr X-Received: by 10.99.96.74 with SMTP id u71mr12138230pgb.129.1502386022014; Thu, 10 Aug 2017 10:27:02 -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:26:05 -0700 Message-Id: <20170810172615.51965-14-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 13/23] x86/power/64: Adapt assembly for PIE support X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Pavel Machek --- arch/x86/power/hibernate_asm_64.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/power/hibernate_asm_64.S b/arch/x86/power/hibernate_asm_64.S index ce8da3a0412c..6fdd7bbc3c33 100644 --- a/arch/x86/power/hibernate_asm_64.S +++ b/arch/x86/power/hibernate_asm_64.S @@ -24,7 +24,7 @@ #include ENTRY(swsusp_arch_suspend) - movq $saved_context, %rax + leaq saved_context(%rip), %rax movq %rsp, pt_regs_sp(%rax) movq %rbp, pt_regs_bp(%rax) movq %rsi, pt_regs_si(%rax) @@ -115,7 +115,7 @@ ENTRY(restore_registers) movq %rax, %cr4; # turn PGE back on /* We don't restore %rax, it must be 0 anyway */ - movq $saved_context, %rax + leaq saved_context(%rip), %rax movq pt_regs_sp(%rax), %rsp movq pt_regs_bp(%rax), %rbp movq pt_regs_si(%rax), %rsi