[PATCH 3/4] mm/mprotect: fix unpaired notifier start at address 0
From: Lorenzo Stoakes (ARM)
Date: Fri Nov 27 2026 - 14:46:23 EST
From: Chris Mason <mason@xxxxxxxxxx>
A protection change on a VMA that starts at address 0 can leave an MMU
notifier invalidation open forever.
Waiters for its end, such as kvm_swap_active_memslots() and
mmu_interval_read_begin(), then sleep uninterruptibly and never wake up.
Fix by using a boolean value to track this instead of the start address of
the range.
Fixes: a5338093bfb4 ("mm: move mmu notifier call from change_protection to change_pmd_range")
Signed-off-by: Chris Mason <mason@xxxxxxxxxx>
[ ljs: commit msg tweak ]
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
---
mm/mprotect.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/mprotect.c b/mm/mprotect.c
index e18d4e12fc34..0f94b0287895 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -579,8 +579,7 @@ static inline long change_pud_range(struct mmu_gather *tlb,
pud_t *pudp, pud;
unsigned long next;
long pages = 0, ret;
-
- range.start = 0;
+ bool notified = false;
pudp = pud_offset(p4d, addr);
do {
@@ -596,7 +595,8 @@ static inline long change_pud_range(struct mmu_gather *tlb,
if (pud_none(pud))
continue;
- if (!range.start) {
+ if (!notified) {
+ notified = true;
mmu_notifier_range_init(&range,
MMU_NOTIFY_PROTECTION_VMA, 0,
vma->vm_mm, addr, end);
@@ -624,7 +624,7 @@ static inline long change_pud_range(struct mmu_gather *tlb,
cp_flags);
} while (pudp++, addr = next, addr != end);
- if (range.start)
+ if (notified)
mmu_notifier_invalidate_range_end(&range);
return pages;
--
2.56.1