x86/mm: Use strtobool for noexec parsing
PATCH 1/1 x86/mm: Use strtobool for noexec parsing
Use strtobool to parse the 'noexec' parameter rather than open coding it.
'disable_nx' is changed to a bool and flipped to 'enable_nx' so it's meaning follows the command line option.
There's no change in behaviour for noexec=on/off. noexec=junk will now warn
strtobool allows 0/1 and y/n (etc) as well as the on/off.
--- arch/x86/mm/setup_nx.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
arch/x86/mm/setup_nx.c +5 -11
@@ -7,7 +7,7 @@#include <asm/proto.h> #include <asm/cpufeature.h> -static int disable_nx; +static bool enable_nx = true;/* * noexec = on|off
@@ -19,21 +19,15 @@ static int disable_nx;*/ static int __init noexec_setup (char *str) { -if (!str) -return -EINVAL ; -if (!strncmp (str,"on" ,2 )) { - disable_nx =0 ; - }else if (!strncmp (str,"off" ,3 )) { - disable_nx =1 ; - } +int ret =strtobool (str, &enable_nx);x86_configure_nx (); -return 0 ; +return ret; }early_param ("noexec" , noexec_setup);void x86_configure_nx (void ) { -if (boot_cpu_has (X86_FEATURE_NX ) && !disable_nx) +if (boot_cpu_has (X86_FEATURE_NX ) && enable_nx) __supported_pte_mask |= _PAGE_NX;else __supported_pte_mask &= ~_PAGE_NX;
@@ -46,7 +40,7 @@ void __init x86_report_nx(void) "missing in CPU!\n"); }else {#if defined(CONFIG_X86_64 ) || defined(CONFIG_X86_PAE ) -if (disable_nx) { +if (!enable_nx) {printk (KERN_INFO "NX (Execute Disable) protection: " "disabled by kernel command line option\n" ); }else {
Signature · 1 line
2.35.1
Borislav Petkov
maintainerQuoted 5 lines · Dr. David Alan Gilbert
Use strtobool to parse the 'noexec' parameter rather than open coding it.
'disable_nx' is changed to a bool and flipped to 'enable_nx' so it's meaning follows the command line option.
Quoted 8 lines
There's no change in behaviour for noexec=on/off. noexec=junk will now warn
strtobool allows 0/1 and y/n (etc) as well as the on/off.Signed-off-by Dr. David Alan Gilbert <[email protected]>--- arch/x86/mm/setup_nx.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
https://lkml.kernel.org/r/[email protected]
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 10 lines · * Borislav Petkov ([email protected]) wrote:
Quoted 9 lines · Dr. David Alan Gilbert
Use strtobool to parse the 'noexec' parameter rather than open coding it.
'disable_nx' is changed to a bool and flipped to 'enable_nx' so it's meaning follows the command line option.There's no change in behaviour for noexec=on/off. noexec=junk will now warn
strtobool allows 0/1 and y/n (etc) as well as the on/off.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Dr. David Alan Gilbert <[email protected]>--- arch/x86/mm/setup_nx.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
Oh well; good.
Thanks for the pointer.
Dave
Quoted 5 lines
Signature · 4 lines
Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette
Signature · 4 lines
-----Open up your eyes, open up your mind, open up your code ------- / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ \ dave @ treblig.org | | In Hex / \ _________________________|_____ http://www.treblig.org |_______/