[PATCH 2/2] mm/madvise: Use set_pte() to write page tables

From: Samuel Holland

Date: Thu Dec 11 2025 - 03:11:44 EST


Generic code must always use the architecture-provided helper function
to write page tables.

Fixes: 662df3e5c376 ("mm: madvise: implement lightweight guard page mechanism")
Signed-off-by: Samuel Holland <samuel.holland@xxxxxxxxxx>
---

mm/madvise.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/madvise.c b/mm/madvise.c
index b617b1be0f535..4da9c32f8738a 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -1114,7 +1114,7 @@ static int guard_install_set_pte(unsigned long addr, unsigned long next,
unsigned long *nr_pages = (unsigned long *)walk->private;

/* Simply install a PTE marker, this causes segfault on access. */
- *ptep = make_pte_marker(PTE_MARKER_GUARD);
+ set_pte(ptep, make_pte_marker(PTE_MARKER_GUARD));
(*nr_pages)++;

return 0;
--
2.47.2