[PATCH] init: fix misleading "This architecture does not have kernel memory protection" message

Subsystems: the rest

STALE2417d

2 messages, 2 authors, 2020-01-10 · open the first message on its own page

[PATCH] init: fix misleading "This architecture does not have kernel memory protection" message

From: Christophe Leroy <hidden>
Date: 2020-01-09 08:15:06

This message leads to think that memory protection is not implemented
for the said architecture, whereas absence of CONFIG_STRICT_KERNEL_RWX
only means that memory protection has not been selected at
compile time.

Don't print this message when CONFIG_ARCH_HAS_STRICT_KERNEL_RWX is
selected by the architecture. Instead, print "Kernel memory protection
not selected by kernel config."

Signed-off-by: Christophe Leroy <redacted>
---
 init/main.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/init/main.c b/init/main.c
index 2cd736059416..fd31b15cc910 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1090,6 +1090,11 @@ static void mark_readonly(void)
 	} else
 		pr_info("Kernel memory protection disabled.\n");
 }
+#elif defined(CONFIG_ARCH_HAS_STRICT_KERNEL_RWX)
+static inline void mark_readonly(void)
+{
+	pr_warn("Kernel memory protection not selected by kernel config.\n");
+}
 #else
 static inline void mark_readonly(void)
 {
-- 
2.13.3

Re: [PATCH] init: fix misleading "This architecture does not have kernel memory protection" message

From: Kees Cook <hidden>
Date: 2020-01-10 05:13:03

On Thu, Jan 09, 2020 at 08:15:01AM +0000, Christophe Leroy wrote:
This message leads to think that memory protection is not implemented
for the said architecture, whereas absence of CONFIG_STRICT_KERNEL_RWX
only means that memory protection has not been selected at
compile time.

Don't print this message when CONFIG_ARCH_HAS_STRICT_KERNEL_RWX is
selected by the architecture. Instead, print "Kernel memory protection
not selected by kernel config."

Signed-off-by: Christophe Leroy <redacted>
Oh, yes, I like this. Should the message include a hint to the config
name?

Regardless:

Acked-by: Kees Cook <redacted>

-Kees
quoted hunk
---
 init/main.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/init/main.c b/init/main.c
index 2cd736059416..fd31b15cc910 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1090,6 +1090,11 @@ static void mark_readonly(void)
 	} else
 		pr_info("Kernel memory protection disabled.\n");
 }
+#elif defined(CONFIG_ARCH_HAS_STRICT_KERNEL_RWX)
+static inline void mark_readonly(void)
+{
+	pr_warn("Kernel memory protection not selected by kernel config.\n");
+}
 #else
 static inline void mark_readonly(void)
 {
-- 
2.13.3
-- 
Kees Cook
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help