Thread (28 messages) 28 messages, 4 authors, 2025-04-14

Re: [RFC PATCH v3 08/15] mm: Introduce kernel_pgtables_set_pkey()

From: Linus Walleij <hidden>
Date: 2025-02-06 19:01:47
Also in: linux-hardening, linux-mm, lkml

Hi Kevin,

thanks for your patch!

On Mon, Feb 3, 2025 at 11:20 AM Kevin Brodsky [off-list ref] wrote:
kernel_pgtables_set_pkey() allows setting the pkey of all page table
pages in swapper_pg_dir, recursively. This will be needed by
kpkeys_hardened_pgtables, as it relies on all PTPs being mapped with
a non-default pkey. Those initial kernel page tables cannot
practically be assigned a non-default pkey right when they are
allocated, so mutating them during (early) boot is required.

Signed-off-by: Kevin Brodsky <redacted>
(...)
+static int set_page_pkey(void *p, int pkey)
+static int set_pkey_pte(pmd_t *pmd, int pkey)
+static int set_pkey_pmd(pud_t *pud, int pkey)
+static int set_pkey_pud(p4d_t *p4d, int pkey)
+static int set_pkey_p4d(pgd_t *pgd, int pkey)
+int kernel_pgtables_set_pkey(int pkey)
Aren't these all discardable after boot, so the whole set should
be tagged with __init?

Other than that it LGTM.

Yours,
Linus Walleij
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help