All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [uml-devel] [PATCH v2] um: Add mark_rodata_ro support
@ 2017-05-24 21:34 Thomas Meyer
  0 siblings, 0 replies; only message in thread
From: Thomas Meyer @ 2017-05-24 21:34 UTC (permalink / raw
  To: user-mode-linux-devel

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 arch/um/Kconfig.common |  1 +
 arch/um/kernel/mem.c   | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index 85f6dd2..061009b 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
@@ -2,6 +2,7 @@ config UML
 	bool
 	default y
 	select ARCH_HAS_KCOV
+	select ARCH_HAS_STRICT_KERNEL_RWX
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_UID16
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index e7437ec..8705eff 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <asm/fixmap.h>
 #include <asm/page.h>
+#include <asm/sections.h>
 #include <as-layout.h>
 #include <init.h>
 #include <kern.h>
@@ -168,7 +169,6 @@ void __init paging_init(void)
  * This can't do anything because nothing in the kernel image can be freed
  * since it's not in kernel physical memory.
  */
-
 void free_initmem(void)
 {
 }
@@ -238,3 +238,14 @@ void *uml_kmalloc(int size, int flags)
 {
 	return kmalloc(size, flags);
 }
+
+void mark_rodata_ro(void)
+{
+	/* rodata_start/end must be PAGE_SIZE aligend! */
+	unsigned long rodata_start = (unsigned long) __start_rodata;
+	unsigned long rodata_end = (unsigned long) __end_rodata;
+
+	printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
+	       (rodata_end - rodata_start) >> 10);
+	os_protect_memory((void*)rodata_start, (rodata_end - rodata_start), 1, 0, 0);
+}

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-24 21:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-24 21:34 [uml-devel] [PATCH v2] um: Add mark_rodata_ro support Thomas Meyer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.