From patchwork Thu Jan 28 00:09:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brown X-Patchwork-Id: 8145261 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9C8339F440 for ; Thu, 28 Jan 2016 00:11:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB6E42026F for ; Thu, 28 Jan 2016 00:11:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF81E20117 for ; Thu, 28 Jan 2016 00:10:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOa9E-0004T8-3K; Thu, 28 Jan 2016 00:09:16 +0000 Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOa9A-0004PU-Bc for linux-arm-kernel@lists.infradead.org; Thu, 28 Jan 2016 00:09:13 +0000 Received: by mail-oi0-x236.google.com with SMTP id o124so16607326oia.3 for ; Wed, 27 Jan 2016 16:08:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=u5RiEqiARx487pER9ixzf6V+8xPmjQODbMLKI3yggW0=; b=I+20uo2nLs66kqZd0B4pzmTq5TMymwLphJxTC0tEDLUzGym/4BR0+UbV2P6+E3SlJm 7e5uM+A43eReGbljPP9XK/dfzOwko3S2PL0QcSfAv+AMlY+NBfqVSC6lkNgP0vf34kN3 zjAX96CzBVrjBJ72wcoVh1itr1myXpGlns0GI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=u5RiEqiARx487pER9ixzf6V+8xPmjQODbMLKI3yggW0=; b=GsAemOAb3guAKqDQ702+hYVLXUnZ5j2HmpGYIXEzVxIoswfmyxcBCfO8+MlQo2VH4m 5DUIIH/umXc+vglnO54tGM/QM1UjWR8SAYPFkN3yjXlXoy5CP9SKxTyyoOT3X7IUm/RD k7qnMhWC9nKh+lktboPo44IsG2Ufv67Bf8zZ7ijBt0zsupxBuh9dltPBlZ61IZ125Szd 79LNdHigq55OPJdESjIPiTnp0zsHjdHgBlKPW4BZFTZOINjgJ1Kk+Mu/3xTaGumwx3uk 8w36geJ2E9uni5u9JVcoqtqM0oFJZC95O5SKDU4b7+Axj0umUTF41tvq4yHTQtUZlL+m HiAQ== X-Gm-Message-State: AG10YORfR5+t0BNJwXmaw3M/EbGA0ITLL7mGxix6YqFmUygH7FJCpapq55nZXFPyKAlkJT5n X-Received: by 10.202.218.138 with SMTP id r132mr21127oig.55.1453939730837; Wed, 27 Jan 2016 16:08:50 -0800 (PST) Received: from davidb.org (c-73-217-22-149.hsd1.co.comcast.net. [73.217.22.149]) by smtp.gmail.com with ESMTPSA id i4sm4137301oel.12.2016.01.27.16.08.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jan 2016 16:08:50 -0800 (PST) Date: Wed, 27 Jan 2016 17:09:06 -0700 From: David Brown To: Kees Cook Subject: [PATCH] arm64: make CONFIG_DEBUG_RODATA non-optional Message-ID: <20160128000906.GA42530@davidb.org> References: <1453226922-16831-1-git-send-email-keescook@chromium.org> <1453226922-16831-4-git-send-email-keescook@chromium.org> <20160127211105.GA41450@davidb.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160127_160912_500423_31E3D926 X-CRM114-Status: GOOD ( 18.49 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "kernel-hardening@lists.openwall.com" , Catalin Marinas , Will Deacon , yalin wang , "H. Peter Anvin" , Steve Capper , linux-arch , Michael Ellerman , "x86@kernel.org" , Ingo Molnar , Zi Shen Lim , PaX Team , Emese Revfy , Mathias Krause , Yang Shi , Laura Abbott , Arnd Bergmann , "Suzuki K. Poulose" , Marc Zyngier , Mark Salter , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , LKML , Jeremy Linton , Andy Lutomirski Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From 2efef8aa0f8f7f6277ffebe4ea6744fc93d54644 Mon Sep 17 00:00:00 2001 From: David Brown Date: Wed, 27 Jan 2016 13:58:44 -0800 This removes the CONFIG_DEBUG_RODATA option and makes it always enabled. Signed-off-by: David Brown Reviewed-by: Kees Cook --- v1: This is in the same spirit as the x86 patch, removing allowing this option to be config selected. The associated patch series adds a runtime option for the same thing. However, it does affect the way some things are mapped, and could possibly result in either increased memory usage, or a performance hit (due to TLB misses from 4K pages). I've tested this on a Hikey 96board (hi6220-hikey.dtb), both with and without 'rodata=off' on the command line. arch/arm64/Kconfig | 3 +++ arch/arm64/Kconfig.debug | 10 ---------- arch/arm64/kernel/insn.c | 2 +- arch/arm64/kernel/vmlinux.lds.S | 5 +---- arch/arm64/mm/mmu.c | 12 ------------ 5 files changed, 5 insertions(+), 27 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 8cc6228..ffa617a 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -201,6 +201,9 @@ config KERNEL_MODE_NEON config FIX_EARLYCON_MEM def_bool y +config DEBUG_RODATA + def_bool y + config PGTABLE_LEVELS int default 2 if ARM64_16K_PAGES && ARM64_VA_BITS_36 diff --git a/arch/arm64/Kconfig.debug b/arch/arm64/Kconfig.debug index e13c4bf..db994ec 100644 --- a/arch/arm64/Kconfig.debug +++ b/arch/arm64/Kconfig.debug @@ -48,16 +48,6 @@ config DEBUG_SET_MODULE_RONX against certain classes of kernel exploits. If in doubt, say "N". -config DEBUG_RODATA - bool "Make kernel text and rodata read-only" - help - If this is set, kernel text and rodata will be made read-only. This - is to help catch accidental or malicious attempts to change the - kernel's executable code. Additionally splits rodata from kernel - text so it can be made explicitly non-executable. - - If in doubt, say Y - config DEBUG_ALIGN_RODATA depends on DEBUG_RODATA && ARM64_4K_PAGES bool "Align linker sections up to SECTION_SIZE" diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c index 7371455..a04bdef 100644 --- a/arch/arm64/kernel/insn.c +++ b/arch/arm64/kernel/insn.c @@ -95,7 +95,7 @@ static void __kprobes *patch_map(void *addr, int fixmap) if (module && IS_ENABLED(CONFIG_DEBUG_SET_MODULE_RONX)) page = vmalloc_to_page(addr); - else if (!module && IS_ENABLED(CONFIG_DEBUG_RODATA)) + else if (!module) page = virt_to_page(addr); else return addr; diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index e3928f5..f80903c 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -65,12 +65,9 @@ PECOFF_FILE_ALIGNMENT = 0x200; #if defined(CONFIG_DEBUG_ALIGN_RODATA) #define ALIGN_DEBUG_RO . = ALIGN(1<