From patchwork Tue Mar 13 20:59:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10280811 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 912226038F for ; Tue, 13 Mar 2018 21:06:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D3EC21327 for ; Tue, 13 Mar 2018 21:06:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F57D284C3; Tue, 13 Mar 2018 21:06: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.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 9BB2421327 for ; Tue, 13 Mar 2018 21:06:39 +0000 (UTC) Received: (qmail 22283 invoked by uid 550); 13 Mar 2018 21:01:34 -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 21930 invoked from network); 13 Mar 2018 21:01:22 -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=SqWcnckQp9D2CggSkscr4SEbv2FWMjOmI4So6GXEZQ8=; b=kCnNSA+JlEEYet6VfdSt2GfY19ZfBxNgcPqLvCzUd2rK+NSfPcx4rIf5m9uW/2SHIh wEg0cwta67MaXnGN0jqMyo4zc2bzqMpPPb5F9e2gwZuQHEFkAhKmFCmbqHdemiWRaiT+ hMge82ytlUajxOTwgwZg08n/YgsckGGBawZHqf5Por2UQ5sRrW92+mPQq2e6YeKqmHmm zJaGVC6xWR7b1qzlKeWVhPWjbpo0e15Wksw9YI7pZkJBobQgzD976+j6q1sVs1A91AWv AnOSsEShN4+6q1itVq6nnUi87egkBEeW4CwrzGfYW0eldC0AQxhBlkrJICOA5vC6YhRH vrcA== 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=SqWcnckQp9D2CggSkscr4SEbv2FWMjOmI4So6GXEZQ8=; b=ieCuVXEO2lawn20CPjbq9VZTOaGGxs4KxBQ19GZn6EiZ7BnUUHe8qR2FgX6QOu2jaV viJsoODfvAI7qz0n+MP5Pr1PK+1agQDqroDiAiGm5YJjlSElncKdJGpgltaDiTVIjNtK lsrxY3EuwwTfwQJs3qSX9Q8JiDpMlmMhtzTI9jXVAq8Nf7mvV1Tjcsii6B4Mq4CmhAko SvIOXTPy9Nm/e/fQ0lehKjWhpmmIDgAEncqDeXG2FI6FGcXdtiDuIvyJHghwzX8A7/d7 3ddijQSA6ZtcOplEmZLpsDCQDIsQ1F9kyFf/KeDb/8DsaCaL/VTRJ6V6nkK9QxlqFxvp hUFQ== X-Gm-Message-State: AElRT7F8mwY8v0vcGAuk7I8kNx3jSiQrqEYahzgp3L2SK4mLmTpZIguJ Xs3OuAxMT+ofwJzHrZpFJUGJkA== X-Google-Smtp-Source: AG47ELsU/M/zWq/U/SA2gBeW9EDj/KKt9LIKMoXr8yJqN8ym+tVxMTc4yGKGGGLCEERItnPKrKFldQ== X-Received: by 10.101.98.17 with SMTP id d17mr1600387pgv.221.1520974869632; Tue, 13 Mar 2018 14:01:09 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Greg Kroah-Hartman , Kate Stewart , Thomas Garnier , Arnd Bergmann , Philippe Ombredanne , Arnaldo Carvalho de Melo , Andrey Ryabinin , Matthias Kaehlcke , Kees Cook , Tom Lendacky , "Kirill A . Shutemov" , Andy Lutomirski , Dominik Brodowski , Borislav Petkov , Borislav Petkov , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Juergen Gross , Alok Kataria , Steven Rostedt , Tejun Heo , Christoph Lameter , Dennis Zhou , Boris Ostrovsky , David Woodhouse , Alexey Dobriyan , "Paul E . McKenney" , Andrew Morton , Nicolas Pitre , Randy Dunlap , "Luis R . Rodriguez" , Christopher Li , Jason Baron , Ashish Kalra , Kyle McMartin , Dou Liyang , Lukas Wunner , Petr Mladek , Sergey Senozhatsky , Masahiro Yamada , Ingo Molnar , Nicholas Piggin , Cao jin , "H . J . Lu" , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Dave Hansen , Rik van Riel , Jia Zhang , Jiri Slaby , Kyle Huey , Jonathan Corbet , Matthew Wilcox , Michal Hocko , Rob Landley , Baoquan He , Daniel Micay , =?UTF-8?q?Jan=20H=20=2E=20Sch=C3=B6nherr?= 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 24/27] x86/mm: Make the x86 GOT read-only Date: Tue, 13 Mar 2018 13:59:42 -0700 Message-Id: <20180313205945.245105-25-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 The GOT is changed during early boot when relocations are applied. Make it read-only directly. This table exists only for PIE binary. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- include/asm-generic/vmlinux.lds.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 1ab0e520d6fc..89398d042f78 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -295,6 +295,17 @@ VMLINUX_SYMBOL(__end_ro_after_init) = .; #endif +#ifdef CONFIG_X86_PIE +#define RO_GOT_X86 \ + .got : AT(ADDR(.got) - LOAD_OFFSET) { \ + VMLINUX_SYMBOL(__start_got) = .; \ + *(.got); \ + VMLINUX_SYMBOL(__end_got) = .; \ + } +#else +#define RO_GOT_X86 +#endif + /* * Read only Data */ @@ -351,6 +362,7 @@ VMLINUX_SYMBOL(__end_builtin_fw) = .; \ } \ \ + RO_GOT_X86 \ TRACEDATA \ \ /* Kernel symbol table: Normal symbols */ \