From nobody Tue Apr 7 19:54:17 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13669369965; Fri, 27 Feb 2026 17:57:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772215034; cv=none; b=I5+j+IxXTf+mq2c8g/aiQkWYrnx4ZbIaPaeWw3Kz54AJa8NNeHPA22ljwr8Rd4mbXdK3sj7HiT4WE4oVXXcuUQ4C5hatACr/b1nDegeSWj4zs6Gxz44yEzOw/nxwn3JjRokOVIqlWw+APdwWrV0alJxmcSeVeUBcvuvY+Vx1b3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772215034; c=relaxed/simple; bh=IVtWpE4iYL1iaOI2bh5r9ny0xwvgTtzMY7/T+a43U54=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JYJfT0Y1jq7DA+juoiVxyatqQ4peZzltpGr3tEJ8bmBkCiUBiEUGjadaZ/szstLcWZuorYHh6m3PDMaclXC5z054jS7SUv9OcTid/h1dzqIc/0rFYCVAHGRezo8ghucfTF2XvpTedP8lQ7uUE1VLrqLw2Moi1Mfk5Ay69lVtSQk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 621D814BF; Fri, 27 Feb 2026 09:57:06 -0800 (PST) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4C5903F73B; Fri, 27 Feb 2026 09:57:08 -0800 (PST) From: Kevin Brodsky To: linux-hardening@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Kevin Brodsky , Andrew Morton , Andy Lutomirski , Catalin Marinas , Dave Hansen , David Hildenbrand , Ira Weiny , Jann Horn , Jeff Xu , Joey Gouly , Kees Cook , Linus Walleij , Lorenzo Stoakes , Marc Zyngier , Mark Brown , Matthew Wilcox , Maxwell Bland , "Mike Rapoport (IBM)" , Peter Zijlstra , Pierre Langlois , Quentin Perret , Rick Edgecombe , Ryan Roberts , Thomas Gleixner , Vlastimil Babka , Will Deacon , Yang Shi , Yeoreum Yun , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH v6 19/30] mm: kpkeys: Introduce hook for protecting static page tables Date: Fri, 27 Feb 2026 17:55:07 +0000 Message-ID: <20260227175518.3728055-20-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260227175518.3728055-1-kevin.brodsky@arm.com> References: <20260227175518.3728055-1-kevin.brodsky@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 73b456ecec65..cf2f7735ce03 100644 --- a/include/linux/kpkeys.h +++ b/include/linux/kpkeys.h @@ -141,6 +141,10 @@ void kpkeys_hardened_pgtables_init_late(void); =20 phys_addr_t kpkeys_physmem_pgtable_alloc(void); =20 +#ifndef arch_kpkeys_protect_static_pgtables +static inline void arch_kpkeys_protect_static_pgtables(void) {} +#endif + #else /* CONFIG_KPKEYS_HARDENED_PGTABLES */ =20 static inline bool kpkeys_hardened_pgtables_enabled(void) diff --git a/mm/kpkeys_hardened_pgtables.c b/mm/kpkeys_hardened_pgtables.c index 1b649812f474..cc1dc44335c3 100644 --- a/mm/kpkeys_hardened_pgtables.c +++ b/mm/kpkeys_hardened_pgtables.c @@ -125,6 +125,7 @@ void __init kpkeys_hardened_pgtables_init_late(void) pba_init_late(); =20 ppa_finalize(); + arch_kpkeys_protect_static_pgtables(); } =20 /* --=20 2.51.2