[PATCH RFC v9 11/25] mm: kpkeys: Introduce kpkeys_hardened_pgtables feature
Mike Rapoport
rppt at kernel.org
Mon Sep 7 03:54:14 PDT 2026
Hi Kevin,
> kpkeys_hardened_pgtables is a hardening feature based on kpkeys. It
> aims to prevent the corruption of page tables by: 1. mapping all
> page table pages, both kernel and user, with a privileged pkey
> (KPKEYS_PKEY_PGTABLES), and 2. granting write access to that pkey
> only when running at in a privileged kpkeys context
> (KPKEYS_CTX_PGTABLES). This patch introduces basic infrastructure;
> the implementation of both aspects will follow.
>
> The feature is exposed as CONFIG_KPKEYS_HARDENED_PGTABLES; it
> requires explicit architecture opt-in by selecting
> ARCH_HAS_KPKEYS_HARDENED_PGTABLES, since much of the page table
> handling is arch-specific.
>
> Because this feature relies on kpkeys being supported and modifies
> attributes of the linear map, it must be inactive on boot.
> kpkeys_hardened_pgtables_init() enables it by toggling a static key;
> this function must be called by supported architectures in
> mem_init(), before any call to pagetable_alloc() is made.
Presuming other architecures will use kpkeys framework it's better to
call kpkeys_hardened_pgtables_init() from mm_core_init() rather than
stick into each arch's mem_init().
--
Sincerely yours,
Mike.
More information about the linux-arm-kernel
mailing list