Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ccaf77c authored by Kees Cook's avatar Kees Cook Committed by Ingo Molnar
Browse files

x86/mm: Always enable CONFIG_DEBUG_RODATA and remove the Kconfig option



This removes the CONFIG_DEBUG_RODATA option and makes it always enabled.

This simplifies the code and also makes it clearer that read-only mapped
memory is just as fundamental a security feature in kernel-space as it is
in user-space.

Suggested-by: default avatarIngo Molnar <mingo@kernel.org>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: David Brown <david.brown@linaro.org>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathias Krause <minipli@googlemail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: PaX Team <pageexec@freemail.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: kernel-hardening@lists.openwall.com
Cc: linux-arch <linux-arch@vger.kernel.org>
Link: http://lkml.kernel.org/r/1455748879-21872-4-git-send-email-keescook@chromium.org


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent d2aa1aca
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -303,6 +303,9 @@ config ARCH_SUPPORTS_UPROBES
config FIX_EARLYCON_MEM
	def_bool y

config DEBUG_RODATA
	def_bool y

config PGTABLE_LEVELS
	int
	default 4 if X86_64
+3 −15
Original line number Diff line number Diff line
@@ -74,28 +74,16 @@ config EFI_PGT_DUMP
	  issues with the mapping of the EFI runtime regions into that
	  table.

config DEBUG_RODATA
	bool "Write protect kernel read-only data structures"
	default y
	depends on DEBUG_KERNEL
	---help---
	  Mark the kernel read-only data as write-protected in the pagetables,
	  in order to catch accidental (and incorrect) writes to such const
	  data. This is recommended so that we can catch kernel bugs sooner.
	  If in doubt, say "Y".

config DEBUG_RODATA_TEST
	bool "Testcase for the DEBUG_RODATA feature"
	depends on DEBUG_RODATA
	bool "Testcase for the marking rodata read-only"
	default y
	---help---
	  This option enables a testcase for the DEBUG_RODATA
	  feature as well as for the change_page_attr() infrastructure.
	  This option enables a testcase for the setting rodata read-only
	  as well as for the change_page_attr() infrastructure.
	  If in doubt, say "N"

config DEBUG_WX
	bool "Warn on W+X mappings at boot"
	depends on DEBUG_RODATA
	select X86_PTDUMP_CORE
	---help---
	  Generate a warning if any W+X mappings are found at boot.
+0 −5
Original line number Diff line number Diff line
@@ -91,15 +91,10 @@ void clflush_cache_range(void *addr, unsigned int size);

#define mmio_flush_range(addr, size) clflush_cache_range(addr, size)

#ifdef CONFIG_DEBUG_RODATA
extern const int rodata_test_data;
extern int kernel_set_to_readonly;
void set_kernel_text_rw(void);
void set_kernel_text_ro(void);
#else
static inline void set_kernel_text_rw(void) { }
static inline void set_kernel_text_ro(void) { }
#endif

#ifdef CONFIG_DEBUG_RODATA_TEST
int rodata_test(void);
+0 −7
Original line number Diff line number Diff line
@@ -17,15 +17,8 @@ static inline bool kvm_check_and_clear_guest_paused(void)
}
#endif /* CONFIG_KVM_GUEST */

#ifdef CONFIG_DEBUG_RODATA
#define KVM_HYPERCALL \
        ALTERNATIVE(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9", X86_FEATURE_VMMCALL)
#else
/* On AMD processors, vmcall will generate a trap that we will
 * then rewrite to the appropriate instruction.
 */
#define KVM_HYPERCALL ".byte 0x0f,0x01,0xc1"
#endif

/* For KVM hypercalls, a three-byte sequence of either the vmcall or the vmmcall
 * instruction.  The hypervisor may replace it with something else but only the
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
extern char __brk_base[], __brk_limit[];
extern struct exception_table_entry __stop___ex_table[];

#if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
#if defined(CONFIG_X86_64)
extern char __end_rodata_hpage_align[];
#endif

Loading