Loading arch/arm64/Kconfig.debug +13 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,17 @@ 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. endmenu arch/arm64/include/asm/cacheflush.h +8 −0 Original line number Diff line number Diff line Loading @@ -169,4 +169,12 @@ int set_memory_ro(unsigned long addr, int numpages); int set_memory_rw(unsigned long addr, int numpages); int set_memory_x(unsigned long addr, int numpages); int set_memory_nx(unsigned long addr, int numpages); #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 arch/arm64/mm/pageattr.c +6 −4 Original line number Diff line number Diff line Loading @@ -66,11 +66,13 @@ static int change_memory_common(unsigned long addr, int numpages, unsigned long end = start + size; int ret; if (!IS_ENABLED(CONFIG_FORCE_PAGES)) { if (start < MODULES_VADDR || start >= MODULES_END) return -EINVAL; if (end < MODULES_VADDR || end >= MODULES_END) return -EINVAL; } if (set) ret = apply_to_page_range(&init_mm, start, size, Loading Loading
arch/arm64/Kconfig.debug +13 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,17 @@ 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. endmenu
arch/arm64/include/asm/cacheflush.h +8 −0 Original line number Diff line number Diff line Loading @@ -169,4 +169,12 @@ int set_memory_ro(unsigned long addr, int numpages); int set_memory_rw(unsigned long addr, int numpages); int set_memory_x(unsigned long addr, int numpages); int set_memory_nx(unsigned long addr, int numpages); #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
arch/arm64/mm/pageattr.c +6 −4 Original line number Diff line number Diff line Loading @@ -66,11 +66,13 @@ static int change_memory_common(unsigned long addr, int numpages, unsigned long end = start + size; int ret; if (!IS_ENABLED(CONFIG_FORCE_PAGES)) { if (start < MODULES_VADDR || start >= MODULES_END) return -EINVAL; if (end < MODULES_VADDR || end >= MODULES_END) return -EINVAL; } if (set) ret = apply_to_page_range(&init_mm, start, size, Loading