[PATCH RFC v9 15/25] mm: kpkeys: Introduce hook for protecting static page tables
Kevin Brodsky
kevin.brodsky at arm.com
Tue Aug 18 07:08:57 PDT 2026
The kpkeys_hardened_pgtables infrastructure introduced so far allows
compatible architectures to protect all page table pages (PTPs)
allocated at runtime (first via memblock, then the buddy allocator).
Some PTPs are however required even earlier, before any allocator is
available. This is typically needed for mapping the kernel image
itself.
These PTPs are at least as sensitive as those allocated later on,
and should be protected by mapping them with the privileged pkey.
Exactly how these pages are obtained is entirely arch-specific, so
we introduce a hook to let architectures that implement
kpkeys_hardened_pgtables do the right thing.
Signed-off-by: Kevin Brodsky <kevin.brodsky at arm.com>
---
include/linux/kpkeys.h | 4 ++++
mm/kpkeys_hardened_pgtables.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/include/linux/kpkeys.h b/include/linux/kpkeys.h
index 23526d3f9ab3..df55ec854586 100644
--- a/include/linux/kpkeys.h
+++ b/include/linux/kpkeys.h
@@ -127,6 +127,10 @@ void kpkeys_hardened_pgtables_init(void);
phys_addr_t kpkeys_physmem_pgtable_alloc(void);
+#ifndef arch_kpkeys_protect_static_pgtables
+static inline void arch_kpkeys_protect_static_pgtables(void) {}
+#endif
+
#else /* CONFIG_KPKEYS_HARDENED_PGTABLES */
static inline bool kpkeys_hardened_pgtables_enabled(void)
diff --git a/mm/kpkeys_hardened_pgtables.c b/mm/kpkeys_hardened_pgtables.c
index 9e1e27c2cc96..c133e5896fcc 100644
--- a/mm/kpkeys_hardened_pgtables.c
+++ b/mm/kpkeys_hardened_pgtables.c
@@ -66,6 +66,7 @@ void __init kpkeys_hardened_pgtables_init(void)
static_branch_enable(&kpkeys_hardened_pgtables_key);
ppa_finalize();
+ arch_kpkeys_protect_static_pgtables();
}
/*
--
2.51.2
More information about the linux-arm-kernel
mailing list