From patchwork Thu Jan 19 01:29:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9525057 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 59D446020A for ; Thu, 19 Jan 2017 01:29:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 474062861F for ; Thu, 19 Jan 2017 01:29:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39A8E28630; Thu, 19 Jan 2017 01:29:56 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2C10A2861F for ; Thu, 19 Jan 2017 01:29:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cU1Y2-0003AL-Eu; Thu, 19 Jan 2017 01:29:54 +0000 Received: from mail-qt0-f170.google.com ([209.85.216.170]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cU1Xo-0002Rr-3C for linux-arm-kernel@lists.infradead.org; Thu, 19 Jan 2017 01:29:43 +0000 Received: by mail-qt0-f170.google.com with SMTP id k15so42241228qtg.3 for ; Wed, 18 Jan 2017 17:29:19 -0800 (PST) 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=3N81gWBg1zzKcS1Df79Z0eS3YIhk3VwWhJ6jgGkWBWI=; b=B6gkKAup23mHVyVQhQ8WsVd9K6ZA2UFN/mJPg/wz0oA1txwnZ4CjnuwnMv03j+iw5t G1BfwJJUnqFWLiK/AE8WBimMqPMbP/naQKjxeZut0r6Cn/pM+5mEdYVrfuyYMFVxmus1 SyauTcY/1tQR1Xb1YBo4BVxjjyLA9zHwFWjfW7vpOY/L6G15EP4S+XkdLMmNSQud07EM EnMdSwkB9cXjVFSdXLsYDGWbo+BSesDd+KaTxMYgIFfWEdF4cT68ypDOh829lVXlLvD4 X1TUOaKKjg0danL2fj69n+0y4LSMMiKRA44hAS4+0YSmjQ84LHOwTYjAkjPv7nA0HMOz vR/g== X-Gm-Message-State: AIkVDXKbFUBVFKFmMYIoZCaAf6gDLDhXG47rATGrEYbQWBU8WyAM6qOyGw68qJbdcOmy7rJK X-Received: by 10.200.41.153 with SMTP id 25mr3515035qts.108.1484789358705; Wed, 18 Jan 2017 17:29:18 -0800 (PST) Received: from labbott-redhat-machine.redhat.com ([2601:602:9802:a8dc::6b06]) by smtp.gmail.com with ESMTPSA id q62sm1739539qkb.46.2017.01.18.17.29.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jan 2017 17:29:17 -0800 (PST) From: Laura Abbott To: Kees Cook Subject: [PATCH 1/2] security: Change name of CONFIG_DEBUG_RODATA Date: Wed, 18 Jan 2017 17:29:05 -0800 Message-Id: <1484789346-21012-2-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484789346-21012-1-git-send-email-labbott@redhat.com> References: <1484789346-21012-1-git-send-email-labbott@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170118_172940_327131_DAD65B24 X-CRM114-Status: GOOD ( 22.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-doc@vger.kernel.org, Catalin Marinas , Heiko Carstens , "James E.J. Bottomley" , Pavel Machek , "H. Peter Anvin" , kernel-hardening@lists.openwall.com, Rob Herring , Jessica Yu , Jonathan Corbet , Helge Deller , x86@kernel.org, Russell King , Ingo Molnar , Laura Abbott , Len Brown , linux-s390@vger.kernel.org, Will Deacon , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-parisc@vger.kernel.org, linux-pm@vger.kernel.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Jason Wessel , Martin Schwidefsky MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Despite the word 'debug' in CONFIG_DEBUG_RODATA, this kernel option provides key security features that are to be expected on a modern system. Change the name to CONFIG_HARDENED_PAGE_MAPPINGS which more accurately describes what this option is intended to do. Signed-off-by: Laura Abbott --- Documentation/DocBook/kgdb.tmpl | 8 ++++---- Documentation/security/self-protection.txt | 2 +- arch/arm/Kconfig | 1 + arch/arm/configs/aspeed_g4_defconfig | 2 +- arch/arm/configs/aspeed_g5_defconfig | 2 +- arch/arm/include/asm/cacheflush.h | 2 +- arch/arm/kernel/patch.c | 2 +- arch/arm/kernel/vmlinux.lds.S | 8 ++++---- arch/arm/mm/Kconfig | 14 +------------- arch/arm/mm/init.c | 4 ++-- arch/arm64/Kconfig | 4 +--- arch/arm64/Kconfig.debug | 2 +- arch/parisc/Kconfig | 1 + arch/parisc/Kconfig.debug | 11 ----------- arch/parisc/configs/712_defconfig | 2 +- arch/parisc/configs/c3000_defconfig | 2 +- arch/parisc/mm/init.c | 2 +- arch/s390/Kconfig | 4 +--- arch/x86/Kconfig | 4 +--- include/linux/init.h | 4 ++-- init/main.c | 4 ++-- kernel/configs/android-recommended.config | 2 +- kernel/power/hibernate.c | 2 +- kernel/power/power.h | 4 ++-- kernel/power/snapshot.c | 4 ++-- security/Kconfig | 16 ++++++++++++++++ 26 files changed, 51 insertions(+), 62 deletions(-) diff --git a/Documentation/DocBook/kgdb.tmpl b/Documentation/DocBook/kgdb.tmpl index f3abca7..a79b638 100644 --- a/Documentation/DocBook/kgdb.tmpl +++ b/Documentation/DocBook/kgdb.tmpl @@ -115,12 +115,12 @@ If the architecture that you are using supports the kernel option - CONFIG_DEBUG_RODATA, you should consider turning it off. This + CONFIG_HARDENED_PAGE_MAPPINGS, you should consider turning it off. This option will prevent the use of software breakpoints because it marks certain regions of the kernel's memory space as read-only. If kgdb supports it for the architecture you are using, you can use hardware breakpoints if you desire to run with the - CONFIG_DEBUG_RODATA option turned on, else you need to turn off + CONFIG_HARDENED_PAGE_MAPPINGS option turned on, else you need to turn off this option. @@ -135,7 +135,7 @@ Here is an example set of .config symbols to enable or disable for kgdb: - # CONFIG_DEBUG_RODATA is not set + # CONFIG_HARDENED_PAGE_MAPPINGS is not set CONFIG_FRAME_POINTER=y CONFIG_KGDB=y CONFIG_KGDB_SERIAL_CONSOLE=y @@ -166,7 +166,7 @@ Here is an example set of .config symbols to enable/disable kdb: - # CONFIG_DEBUG_RODATA is not set + # CONFIG_HARDENED_PAGE_MAPPINGS is not set CONFIG_FRAME_POINTER=y CONFIG_KGDB=y CONFIG_KGDB_SERIAL_CONSOLE=y diff --git a/Documentation/security/self-protection.txt b/Documentation/security/self-protection.txt index 3010576..da8cb36 100644 --- a/Documentation/security/self-protection.txt +++ b/Documentation/security/self-protection.txt @@ -51,7 +51,7 @@ kernel, they are implemented in a way where the memory is temporarily made writable during the update, and then returned to the original permissions.) -In support of this are (the poorly named) CONFIG_DEBUG_RODATA and +In support of this are CONFIG_HARDENED_PAGE_MAPPINGS and CONFIG_DEBUG_SET_MODULE_RONX, which seek to make sure that code is not writable, data is not executable, and read-only data is neither writable nor executable. diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 186c4c2..09aff28 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -7,6 +7,7 @@ config ARM select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAS_GCOV_PROFILE_ALL + select ARCH_HAS_HARDENED_MAPPINGS if MMU && !XIP_KERNEL select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_USE_BUILTIN_BSWAP diff --git a/arch/arm/configs/aspeed_g4_defconfig b/arch/arm/configs/aspeed_g4_defconfig index ca39c04..8ccc216 100644 --- a/arch/arm/configs/aspeed_g4_defconfig +++ b/arch/arm/configs/aspeed_g4_defconfig @@ -25,7 +25,7 @@ CONFIG_MODULE_UNLOAD=y # CONFIG_ARCH_MULTI_V7 is not set CONFIG_ARCH_ASPEED=y CONFIG_MACH_ASPEED_G4=y -CONFIG_DEBUG_RODATA=y +CONFIG_HARDENED_PAGE_MAPPINGS=y CONFIG_AEABI=y CONFIG_UACCESS_WITH_MEMCPY=y CONFIG_SECCOMP=y diff --git a/arch/arm/configs/aspeed_g5_defconfig b/arch/arm/configs/aspeed_g5_defconfig index 4f366b0..90c5ce4 100644 --- a/arch/arm/configs/aspeed_g5_defconfig +++ b/arch/arm/configs/aspeed_g5_defconfig @@ -26,7 +26,7 @@ CONFIG_ARCH_MULTI_V6=y # CONFIG_ARCH_MULTI_V7 is not set CONFIG_ARCH_ASPEED=y CONFIG_MACH_ASPEED_G5=y -CONFIG_DEBUG_RODATA=y +CONFIG_HARDENED_PAGE_MAPPINGS=y CONFIG_AEABI=y CONFIG_UACCESS_WITH_MEMCPY=y CONFIG_SECCOMP=y diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h index bdd283b..c3a7a72 100644 --- a/arch/arm/include/asm/cacheflush.h +++ b/arch/arm/include/asm/cacheflush.h @@ -490,7 +490,7 @@ static inline int set_memory_x(unsigned long addr, int numpages) { return 0; } static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; } #endif -#ifdef CONFIG_DEBUG_RODATA +#ifdef CONFIG_HARDENED_PAGE_MAPPINGS void set_kernel_text_rw(void); void set_kernel_text_ro(void); #else diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c index 69bda1a..9da1bf5 100644 --- a/arch/arm/kernel/patch.c +++ b/arch/arm/kernel/patch.c @@ -26,7 +26,7 @@ static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags) 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 && IS_ENABLED(CONFIG_HARDENED_PAGE_MAPPINGS)) page = virt_to_page(addr); else return addr; diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index f7f55df..5c6a2e8 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S @@ -97,7 +97,7 @@ SECTIONS HEAD_TEXT } -#ifdef CONFIG_DEBUG_RODATA +#ifdef CONFIG_HARDENED_PAGE_MAPPINGS . = ALIGN(1<