arm64: always enable DEBUG_RODATA and remove the Kconfig option
Mark Rutland
reviewerPATCH 1/1 arm64: always enable DEBUG_RODATA and remove the Kconfig option
Follow the example set by x86 in commit 9ccaf77cf05915f5 ("x86/mm:
Always enable CONFIG_DEBUG_RODATA and remove the Kconfig option"), and make these protections a fundamental security feature rather than an opt-in. This also results in a minor code simplification.
For those rare cases when users wish to disable this protection (e.g. for debugging), this can be done by passing 'rodata=off' on the command line.
As DEBUG_RODATA_ALIGN is only intended to address a performance/memory tradeoff, and does not affect correctness, this is left user-selectable. DEBUG_MODULE_RONX is also left user-selectable until the core code provides a boot-time option to disable the protection for debugging use-cases.
--- arch/arm64/Kconfig | 3 +++ arch/arm64/Kconfig.debug | 10 ---------- arch/arm64/kernel/insn.c | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-)
arch/arm64/Kconfig +3 -0
@@ -122,6 +122,9 @@ config ARCH_PHYS_ADDR_T_64BIT config MMU def_bool y +config DEBUG_RODATA + def_bool y + config ARM64_PAGE_SHIFT int default 16 if ARM64_64K_PAGES
arch/arm64/Kconfig.debug +0 -10
@@ -49,16 +49,6 @@ config DEBUG_SET_MODULE_RONX If in doubt, say Y. -config DEBUG_RODATA - bool "Make kernel text and rodata read-only" - default y - 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. - - If in doubt, say Y. - config DEBUG_ALIGN_RODATA depends on DEBUG_RODATA bool "Align linker sections up to SECTION_SIZE"
arch/arm64/kernel/insn.c +1 -1
@@ -96,7 +96,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 =pfn_to_page (PHYS_PFN (__pa (addr)));else return addr;
Signature · 1 line
2.7.4
PATCH 1/1 arm64: always enable DEBUG_RODATA and remove the Kconfig option
Quoted 9 lines · Mark Rutland
Follow the example set by x86 in commit
9ccaf77cf05915f5("x86/mm:
Always enableCONFIG_DEBUG_RODATAand remove theKconfigoption"), and make these protections a fundamental security feature rather than an opt-in. This also results in a minor code simplification.For those rare cases when users wish to disable this protection (e.g. for debugging), this can be done by passing 'rodata=off' on the command line.
Quoted 7 lines
As
DEBUG_RODATA_ALIGNis only intended to address a performance/memory tradeoff, and does not affect correctness, this is left user-selectable.DEBUG_MODULE_RONXis also left user-selectable until the core code provides a boot-time option to disable the protection for debugging use-cases.Signed-off-by Mark Rutland <[email protected]>
About time!
Quoted 62 lines
Cc Ard Biesheuvel <[email protected]>Cc Catalin Marinas <[email protected]>Cc Kees Cook <[email protected]>Cc Laura Abbott <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/Kconfig | 3 +++ arch/arm64/Kconfig.debug | 10 ---------- arch/arm64/kernel/insn.c | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-)arch/arm64/Kconfig +3
-0@@ -122,6 +122,9 @@ config ARCH_PHYS_ADDR_T_64BIT config MMU def_bool y +config DEBUG_RODATA + def_bool y + config ARM64_PAGE_SHIFT int default 16 if ARM64_64K_PAGESarch/arm64/Kconfig.debug +0
-10@@ -49,16 +49,6 @@ config DEBUG_SET_MODULE_RONX If in doubt, say Y. -config DEBUG_RODATA - bool "Make kernel text and rodata read-only" - default y - 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. - - If in doubt, say Y. - config DEBUG_ALIGN_RODATA depends on DEBUG_RODATA bool "Align linker sections up to SECTION_SIZE"arch/arm64/kernel/insn.c +1
-2@@ -96,7 +96,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 =pfn_to_page (PHYS_PFN (__pa (addr)));else return addr; --2.7.4
PATCH 1/1 arm64: always enable DEBUG_RODATA and remove the Kconfig option
In reply to Mark RutlandQuoted 15 lines · Mark Rutland
Follow the example set by x86 in commit
9ccaf77cf05915f5("x86/mm:
Always enableCONFIG_DEBUG_RODATAand remove theKconfigoption"), and make these protections a fundamental security feature rather than an opt-in. This also results in a minor code simplification.For those rare cases when users wish to disable this protection (e.g. for debugging), this can be done by passing 'rodata=off' on the command line.
As
DEBUG_RODATA_ALIGNis only intended to address a performance/memory tradeoff, and does not affect correctness, this is left user-selectable.DEBUG_MODULE_RONXis also left user-selectable until the core code provides a boot-time option to disable the protection for debugging use-cases.
Quoted 6 lines
Signed-off-by Mark Rutland <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Catalin Marinas <[email protected]>Cc Kees Cook <[email protected]>Cc Laura Abbott <[email protected]>Cc Will Deacon <[email protected]>
Awesome!
-Kees
Signature · 2 lines
Kees Cook Nexus Security
PATCH 1/1 arm64: always enable DEBUG_RODATA and remove the Kconfig option
In reply to Mark RutlandQuoted 15 lines · Mark Rutland
Follow the example set by x86 in commit
9ccaf77cf05915f5("x86/mm:
Always enableCONFIG_DEBUG_RODATAand remove theKconfigoption"), and make these protections a fundamental security feature rather than an opt-in. This also results in a minor code simplification.For those rare cases when users wish to disable this protection (e.g. for debugging), this can be done by passing 'rodata=off' on the command line.
As
DEBUG_RODATA_ALIGNis only intended to address a performance/memory tradeoff, and does not affect correctness, this is left user-selectable.DEBUG_MODULE_RONXis also left user-selectable until the core code provides a boot-time option to disable the protection for debugging use-cases.
Quoted 6 lines
Signed-off-by Mark Rutland <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Catalin Marinas <[email protected]>Cc Kees Cook <[email protected]>Cc Laura Abbott <[email protected]>Cc Will Deacon <[email protected]>
Excellent!
Quoted 55 lines
--- arch/arm64/Kconfig | 3 +++ arch/arm64/Kconfig.debug | 10 ---------- arch/arm64/kernel/insn.c | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-)arch/arm64/Kconfig +3
-0@@ -122,6 +122,9 @@ config ARCH_PHYS_ADDR_T_64BIT config MMU def_bool y +config DEBUG_RODATA + def_bool y + config ARM64_PAGE_SHIFT int default 16 if ARM64_64K_PAGESarch/arm64/Kconfig.debug +0
-10@@ -49,16 +49,6 @@ config DEBUG_SET_MODULE_RONX If in doubt, say Y. -config DEBUG_RODATA - bool "Make kernel text and rodata read-only" - default y - 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. - - If in doubt, say Y. - config DEBUG_ALIGN_RODATA depends on DEBUG_RODATA bool "Align linker sections up to SECTION_SIZE"arch/arm64/kernel/insn.c +1
-1@@ -96,7 +96,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 =pfn_to_page (PHYS_PFN (__pa (addr)));else return addr;
PATCH 1/1 arm64: always enable DEBUG_RODATA and remove the Kconfig option
In reply to Mark RutlandQuoted 21 lines · Mark Rutland
Follow the example set by x86 in commit
9ccaf77cf05915f5("x86/mm:
Always enableCONFIG_DEBUG_RODATAand remove theKconfigoption"), and make these protections a fundamental security feature rather than an opt-in. This also results in a minor code simplification.For those rare cases when users wish to disable this protection (e.g. for debugging), this can be done by passing 'rodata=off' on the command line.
As
DEBUG_RODATA_ALIGNis only intended to address a performance/memory tradeoff, and does not affect correctness, this is left user-selectable.DEBUG_MODULE_RONXis also left user-selectable until the core code provides a boot-time option to disable the protection for debugging use-cases.Signed-off-by Mark Rutland <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc Catalin Marinas <[email protected]>Cc Kees Cook <[email protected]>Cc Laura Abbott <[email protected]>Cc Will Deacon <[email protected]>
Quoted 5 lines
--- arch/arm64/Kconfig | 3 +++ arch/arm64/Kconfig.debug | 10 ---------- arch/arm64/kernel/insn.c | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-)
This is a very popular patch.
Applied for 4.9. Perhaps it makes up for all the unpopular patches I've applied in the past.
Will