Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ff8d3bd authored by Laura Abbott's avatar Laura Abbott Committed by Shiraz Hashim
Browse files

mm: Mark free pages as read only



Drivers have a tendency to scribble on everything, including free
pages. Make life easier by marking free pages as read only when
on the buddy list and re-marking as read/write when allocating.

Change-Id: I978ed2921394919917307b9c99217fdc22f82c59
Signed-off-by: default avatarLaura Abbott <lauraa@codeaurora.org>
parent d11e2126
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -85,6 +85,18 @@ config FORCE_PAGES

          If unsure say N.

config FREE_PAGES_RDONLY
	bool "Set pages as read only while on the buddy list"
	select FORCE_PAGES
	select PAGE_POISONING
	help
          Pages are always mapped in the kernel. This means that anyone
          can write to the page if they have the address. Enable this option
          to mark pages as read only to trigger a fault if any code attempts
          to write to a page on the buddy list. This may have a performance
          impact.

          If unsure, say N.

# These options are only for real kernel hackers who want to get their hands dirty.
config DEBUG_LL
+8 −0
Original line number Diff line number Diff line
@@ -520,4 +520,12 @@ static inline void set_kernel_text_ro(void) { }
void flush_uprobe_xol_access(struct page *page, unsigned long uaddr,
			     void *kaddr, unsigned long len);

#ifdef CONFIG_FREE_PAGES_RDONLY
#define mark_addr_rdonly(a)	set_memory_ro((unsigned long)a, 1)
#define mark_addr_rdwrite(a)	set_memory_rw((unsigned long)a, 1)
#else
#define mark_addr_rdonly(a)
#define mark_addr_rdwrite(a)
#endif

#endif