From patchwork Tue Jul 18 22:33:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9850043 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 B1CB860392 for ; Tue, 18 Jul 2017 22:36:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D66F285B7 for ; Tue, 18 Jul 2017 22:36:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91BB3285CD; Tue, 18 Jul 2017 22:36: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 BFC93285B7 for ; Tue, 18 Jul 2017 22:36:41 +0000 (UTC) Received: (qmail 27962 invoked by uid 550); 18 Jul 2017 22:34:44 -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 27830 invoked from network); 18 Jul 2017 22:34:41 -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=wwFPvBOrg+9pqOiUuvpMW6sbi1f/697Y5jk3CxC04XA=; b=hB9v7r8GryWJy8lzS0bsw3I6ezo+AmF1YNhtTAM+hVnstaSnP6xjDmiT4l4PKsPEU3 HqyCnr1ELEW3y+b32hH+c3fVfcw5r+85LKyRn2rObdUTd6VZZB4EG1ey62SHG4vrnCK7 s79WMaKu8YgcVucFzq8+Z1z6IpaWI03jFB8S2fD0xuoePF2Cta92+Rvrp37q7RQA0quw MA20+r56V0j5mZvhSxz8F9zORZWARmYP+EIs2A7x7988/YHh4uQuEiWaAB1j/CwQWz5j z1TPMF8PDu4pQAFUAnbJnHezc0PkJyUQ/4u65Dgzl7DkvH9m5FDqT/+urts0SNmAa/sX 6LaQ== 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=wwFPvBOrg+9pqOiUuvpMW6sbi1f/697Y5jk3CxC04XA=; b=tTmJUTv+za4pfDXRE7y4hY+AmZ53X10iypJ1up9oODL+kFkK1H6shQ0sQ2sJmp6Avx YorOdD56c9WCb1eDEB8J0jGSXjuCaSQ0hT1qcNANTitmeJ9WYKpAPT53rifLAmUOfVSy hGg/4mZkHwA4wfIgjZuXpXEcjphgY4Yz7btxzJSJj70bpy6miOxY1wzmkOpAGN7BOcGk 0BlwzfdtXVWmXayCRO+Q/3mA9sfRbTlfPVffQU1Lc4xVy2G/zZ3ctwk35gERwyUN7HZi YjeYLzUy/UMo7NRuHhTTpOgOs7TVjHCzpGmPo3Kfh0uCmPg5pHqER8BcnBF+KLJt8gqw TaMA== X-Gm-Message-State: AIVw1135KZyxQl8tNFoT/IMKsslyIgnWXmo5t/+sO9EH8LwDsTEjX2Hy aWzfadig2gTFZ6o4 X-Received: by 10.99.56.5 with SMTP id f5mr3924794pga.14.1500417269835; Tue, 18 Jul 2017 15:34:29 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Thomas Garnier , Arnd Bergmann , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Andy Lutomirski , Borislav Petkov , "Kirill A . Shutemov" , Brian Gerst , Borislav Petkov , Christian Borntraeger , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph Lameter , Kees Cook , Paul Gortmaker , Chris Metcalf , "Paul E . McKenney" , Andrew Morton , Christopher Li , Dou Liyang , Masahiro Yamada , Daniel Borkmann , Markus Trippelsdorf , Peter Foley , Steven Rostedt , Tim Chen , Ard Biesheuvel , Catalin Marinas , Matthew Wilcox , Michal Hocko , Rob Landley , Jiri Kosina , "H . J . Lu" , Paul Bolle , 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: Tue, 18 Jul 2017 15:33:24 -0700 Message-Id: <20170718223333.110371-14-thgarnie@google.com> X-Mailer: git-send-email 2.13.2.932.g7449e964c-goog In-Reply-To: <20170718223333.110371-1-thgarnie@google.com> References: <20170718223333.110371-1-thgarnie@google.com> Subject: [kernel-hardening] [RFC 13/22] 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