arm64: enable CONFIG_DEBUG_RODATA by default
PATCH 1/1 arm64: enable CONFIG_DEBUG_RODATA by default
In spite of its name, CONFIG_DEBUG_RODATA is an important hardening feature for production kernels, and distros all enable it by default in their kernel configs. However, since enabling it used to result in more granular, and thus less efficient kernel mappings, it is not enabled by default for performance reasons.
However, since commit 2f39b5f91eb4 ("arm64: mm: Mark .rodata as RO"), the various kernel segments (.text, .rodata, .init and .data) are already mapped individually, and the only effect of setting CONFIG_DEBUG_RODATA is that the existing .text and .rodata mappings are updated late in the boot sequence to have their read-only attributes set, which means that any performance concerns related to enabling CONFIG_DEBUG_RODATA are no longer valid.
So from now on, make CONFIG_DEBUG_RODATA default to 'y'
--- arch/arm64/Kconfig.debug | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/Kconfig.debug +3 -3
@@ -50,13 +50,13 @@ config DEBUG_SET_MODULE_RONX 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. Additionally splits rodata from kernel - text so it can be made explicitly non-executable. + kernel's executable code. - If in doubt, say Y + If in doubt, say Y config DEBUG_ALIGN_RODATA depends on DEBUG_RODATA && ARM64_4K_PAGES
Signature · 1 line
2.5.0
Mark Rutland
reviewerPATCH 1/1 arm64: enable CONFIG_DEBUG_RODATA by default
Quoted 14 lines · Ard Biesheuvel
In spite of its name,
CONFIG_DEBUG_RODATAis an important hardening feature for production kernels, and distros all enable it by default in their kernel configs. However, since enabling it used to result in more granular, and thus less efficient kernel mappings, it is not enabled by default for performance reasons.However, since commit
2f39b5f91eb4("arm64: mm: Mark .rodata as RO"), the various kernel segments (.text, .rodata, .init and .data) are already mapped individually, and the only effect of settingCONFIG_DEBUG_RODATAis that the existing .text and .rodata mappings are updated late in the boot sequence to have their read-only attributes set, which means that any performance concerns related to enablingCONFIG_DEBUG_RODATAare no longer valid.
Quoted 3 lines
So from now on, make
CONFIG_DEBUG_RODATAdefault to 'y'Signed-off-by Ard Biesheuvel <[email protected]>
Finally! :)
Mark.
Quoted 28 lines
--- arch/arm64/Kconfig.debug | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/arm64/Kconfig.debug +3
-3@@ -50,13 +50,13 @@ config DEBUG_SET_MODULE_RONX 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. Additionally splits rodata from kernel - text so it can be made explicitly non-executable. + kernel's executable code. - If in doubt, say Y + If in doubt, say Y config DEBUG_ALIGN_RODATA depends on DEBUG_RODATA && ARM64_4K_PAGESSignature · 1 line
2.5.0
PATCH 1/1 arm64: enable CONFIG_DEBUG_RODATA by default
In reply to Ard BiesheuvelQuoted 14 lines · Ard Biesheuvel
In spite of its name,
CONFIG_DEBUG_RODATAis an important hardening feature for production kernels, and distros all enable it by default in their kernel configs. However, since enabling it used to result in more granular, and thus less efficient kernel mappings, it is not enabled by default for performance reasons.However, since commit
2f39b5f91eb4("arm64: mm: Mark .rodata as RO"), the various kernel segments (.text, .rodata, .init and .data) are already mapped individually, and the only effect of settingCONFIG_DEBUG_RODATAis that the existing .text and .rodata mappings are updated late in the boot sequence to have their read-only attributes set, which means that any performance concerns related to enablingCONFIG_DEBUG_RODATAare no longer valid.
Quoted 3 lines
So from now on, make
CONFIG_DEBUG_RODATAdefault to 'y'Signed-off-by Ard Biesheuvel <[email protected]>
If this doesn't cause any problems, perhaps we can make it always 'y' soon?
-Kees
Quoted 28 lines
--- arch/arm64/Kconfig.debug | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/arm64/Kconfig.debug +3
-4@@ -50,13 +50,13 @@ config DEBUG_SET_MODULE_RONX 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. Additionally splits rodata from kernel - text so it can be made explicitly non-executable. + kernel's executable code. - If in doubt, say Y + If in doubt, say Y config DEBUG_ALIGN_RODATA depends on DEBUG_RODATA && ARM64_4K_PAGES --2.5.0
Signature · 2 lines
Kees Cook Chrome OS & Brillo Security
PATCH 1/1 arm64: enable CONFIG_DEBUG_RODATA by default
Quoted 16 lines · Kees Cook
Quoted 14 lines · Ard Biesheuvel
In spite of its name,
CONFIG_DEBUG_RODATAis an important hardening feature for production kernels, and distros all enable it by default in their kernel configs. However, since enabling it used to result in more granular, and thus less efficient kernel mappings, it is not enabled by default for performance reasons.However, since commit
2f39b5f91eb4("arm64: mm: Mark .rodata as RO"), the various kernel segments (.text, .rodata, .init and .data) are already mapped individually, and the only effect of settingCONFIG_DEBUG_RODATAis that the existing .text and .rodata mappings are updated late in the boot sequence to have their read-only attributes set, which means that any performance concerns related to enablingCONFIG_DEBUG_RODATAare no longer valid.
Quoted 8 lines
Quoted 3 lines
So from now on, make
CONFIG_DEBUG_RODATAdefault to 'y'Signed-off-by Ard Biesheuvel <[email protected]>Acked-by Kees Cook <[email protected]>If this doesn't cause any problems, perhaps we can make it always 'y' soon?
You mean remove the option altogether? I would not mind, although arguably, being able to map .text and .rodata writable could be considered a useful debug option (and then it would almost, but not quite, live up to its name)
Signature · 1 line
Ard.
PATCH 1/1 arm64: enable CONFIG_DEBUG_RODATA by default
Quoted 23 lines · Ard Biesheuvel
Quoted 22 lines · Kees Cook
Quoted 14 lines · Ard Biesheuvel
In spite of its name,
CONFIG_DEBUG_RODATAis an important hardening feature for production kernels, and distros all enable it by default in their kernel configs. However, since enabling it used to result in more granular, and thus less efficient kernel mappings, it is not enabled by default for performance reasons.However, since commit
2f39b5f91eb4("arm64: mm: Mark .rodata as RO"), the various kernel segments (.text, .rodata, .init and .data) are already mapped individually, and the only effect of settingCONFIG_DEBUG_RODATAis that the existing .text and .rodata mappings are updated late in the boot sequence to have their read-only attributes set, which means that any performance concerns related to enablingCONFIG_DEBUG_RODATAare no longer valid.Quoted 3 lines
So from now on, make
CONFIG_DEBUG_RODATAdefault to 'y'Signed-off-by Ard Biesheuvel <[email protected]>Acked-by Kees Cook <[email protected]>
Quoted 7 lines
Quoted 2 lines
If this doesn't cause any problems, perhaps we can make it always 'y' soon?
You mean remove the option altogether? I would not mind, although arguably, being able to map .text and .rodata writable could be considered a useful debug option (and then it would almost, but not quite, live up to its name)
For x86 (and everything that implements mark_rodata_ro()) this will soon be controlled by rodata=off on the kernel command line (i.e. it skips mark_rodata_ro() during startup).
-Kees
Signature · 2 lines
Kees Cook Chrome OS & Brillo Security
Catalin Marinas
maintainerPATCH 1/1 arm64: enable CONFIG_DEBUG_RODATA by default
In reply to Ard BiesheuvelQuoted 14 lines · Ard Biesheuvel
In spite of its name,
CONFIG_DEBUG_RODATAis an important hardening feature for production kernels, and distros all enable it by default in their kernel configs. However, since enabling it used to result in more granular, and thus less efficient kernel mappings, it is not enabled by default for performance reasons.However, since commit
2f39b5f91eb4("arm64: mm: Mark .rodata as RO"), the various kernel segments (.text, .rodata, .init and .data) are already mapped individually, and the only effect of settingCONFIG_DEBUG_RODATAis that the existing .text and .rodata mappings are updated late in the boot sequence to have their read-only attributes set, which means that any performance concerns related to enablingCONFIG_DEBUG_RODATAare no longer valid.
Quoted 1 line
So from now on, make
CONFIG_DEBUG_RODATAdefault to 'y'
Patch applied. If we later get a command line option as Kees mentioned, I'm happy to drop this option entirely.
Signature · 1 line
Catalin