Skip to content

Commit 76ea002

Browse files
committed
x86/cpu: Remove "noexec"
It doesn't make any sense to disable non-executable mappings - security-wise or else. So rip out that switch and move the remaining code into setup.c and delete setup_nx.c Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Lai Jiangshan <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 385d2ae commit 76ea002

File tree

7 files changed

+26
-83
lines changed

7 files changed

+26
-83
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3456,11 +3456,6 @@
34563456

34573457
noexec [IA-64]
34583458

3459-
noexec [X86]
3460-
On X86-32 available only on PAE configured kernels.
3461-
noexec=on: enable non-executable mappings (default)
3462-
noexec=off: disable non-executable mappings
3463-
34643459
nosmap [PPC]
34653460
Disable SMAP (Supervisor Mode Access Prevention)
34663461
even if it is supported by processor.

Documentation/x86/x86_64/boot-options.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,6 @@ Rebooting
157157
newer BIOS, or newer board) using this option will ignore the built-in
158158
quirk table, and use the generic default reboot actions.
159159

160-
Non Executable Mappings
161-
=======================
162-
163-
noexec=on|off
164-
on
165-
Enable(default)
166-
off
167-
Disable
168-
169160
NUMA
170161
====
171162

arch/x86/include/asm/proto.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ void xen_entry_INT80_compat(void);
3535
#endif
3636

3737
void x86_configure_nx(void);
38-
void x86_report_nx(void);
3938

4039
extern int reboot_force;
4140

arch/x86/kernel/setup.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,30 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
756756
return 0;
757757
}
758758

759+
void x86_configure_nx(void)
760+
{
761+
if (boot_cpu_has(X86_FEATURE_NX))
762+
__supported_pte_mask |= _PAGE_NX;
763+
else
764+
__supported_pte_mask &= ~_PAGE_NX;
765+
}
766+
767+
static void __init x86_report_nx(void)
768+
{
769+
if (!boot_cpu_has(X86_FEATURE_NX)) {
770+
printk(KERN_NOTICE "Notice: NX (Execute Disable) protection "
771+
"missing in CPU!\n");
772+
} else {
773+
#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
774+
printk(KERN_INFO "NX (Execute Disable) protection: active\n");
775+
#else
776+
/* 32bit non-PAE kernel, NX cannot be used */
777+
printk(KERN_NOTICE "Notice: NX (Execute Disable) protection "
778+
"cannot be enabled: non-PAE kernel!\n");
779+
#endif
780+
}
781+
}
782+
759783
/*
760784
* Determine if we were loaded by an EFI loader. If so, then we have also been
761785
* passed the efi memmap, systab, etc., so we should use these data structures
@@ -896,9 +920,7 @@ void __init setup_arch(char **cmdline_p)
896920
/*
897921
* x86_configure_nx() is called before parse_early_param() to detect
898922
* whether hardware doesn't support NX (so that the early EHCI debug
899-
* console setup can safely call set_fixmap()). It may then be called
900-
* again from within noexec_setup() during parsing early parameters
901-
* to honor the respective command line option.
923+
* console setup can safely call set_fixmap()).
902924
*/
903925
x86_configure_nx();
904926

arch/x86/mm/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ CFLAGS_REMOVE_mem_encrypt_identity.o = -pg
2020
endif
2121

2222
obj-y := init.o init_$(BITS).o fault.o ioremap.o extable.o mmap.o \
23-
pgtable.o physaddr.o setup_nx.o tlb.o cpu_entry_area.o maccess.o
23+
pgtable.o physaddr.o tlb.o cpu_entry_area.o maccess.o
2424

2525
obj-y += pat/
2626

2727
# Make sure __phys_addr has no stackprotector
2828
CFLAGS_physaddr.o := -fno-stack-protector
29-
CFLAGS_setup_nx.o := -fno-stack-protector
3029
CFLAGS_mem_encrypt_identity.o := -fno-stack-protector
3130

3231
CFLAGS_fault.o := -I $(srctree)/$(src)/../include/asm/trace

arch/x86/mm/init_64.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ int force_personality32;
110110
/*
111111
* noexec32=on|off
112112
* Control non executable heap for 32bit processes.
113-
* To control the stack too use noexec=off
114113
*
115114
* on PROT_READ does not imply PROT_EXEC for 32-bit processes (default)
116115
* off PROT_READ implies PROT_EXEC

arch/x86/mm/setup_nx.c

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)