Thread (71 messages) flat view 71 messages, 6 authors, 7d ago

Re: [PATCH RFC v9 11/25] mm: kpkeys: Introduce kpkeys_hardened_pgtables feature

From: Kevin Brodsky <hidden>
Date: 2026-09-07 15:50:54
Also in: linux-hardening, linux-mm

On 07/09/2026 12:54, Mike Rapoport wrote:
Hi Kevin,
quoted
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().
Ah yes I was wondering whether it was acceptable to stick another call
directly in mm_core_init(), but I suppose it doesn't hurt. I can move
the call to kpkeys_hardened_pgtables_init() just before
memblock_free_all() and leave mem_init() alone.

Thanks for chipping in!

- Kevin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help