mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mark tramp_pg_dir read-only
@ 2018-05-29  9:16 YaoJun
  2018-05-29 10:02 ` Mark Rutland
  0 siblings, 1 reply; 2+ messages in thread
From: YaoJun @ 2018-05-29  9:16 UTC (permalink / raw)
  To: kernel-hardening; +Cc: linux-kernel, linux-security-module, jmorris

To prevent KSMA(Kernel Space Mirroring Attack), it's necessary
to set tramp_pg_dir read-only after initialization.

---
 arch/arm64/mm/mmu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 2dbb2c9f1ec1..964520e4e675 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -551,6 +551,9 @@ static int __init map_entry_trampoline(void)
 	__create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS, PAGE_SIZE,
 			     prot, pgd_pgtable_alloc, 0);
 
+	update_mapping_prot(__pa_symbol(tramp_pg_dir), (unsigned long)tramp_pg_dir,
+			    PGD_SIZE, PAGE_KERNEL_RO);
+
 	/* Map both the text and data into the kernel page table */
 	__set_fixmap(FIX_ENTRY_TRAMP_TEXT, pa_start, prot);
 	if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
-- 
2.17.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-29 10:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-29  9:16 [PATCH] mark tramp_pg_dir read-only YaoJun
2018-05-29 10:02 ` Mark Rutland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®