[PATCH v2 1/2] fs/proc/task_mmu: reset walk_end before each pagemap walk

From: Matthew Salsamendi via B4 Relay

Date: Tue Nov 17 2026 - 19:26:26 EST


From: Matthew Salsamendi <matthewsalsamendi@xxxxxxxxx>

When PAGEMAP_SCAN resumes after filling its buffer, it can return ranges
beyond a stale walk_end. This aborts a production game server during
dirty-page tracking.

Reset walk_end before each walk so a completed scan reports the end and
a partial HugeTLB write-protect request keeps its retry address.

Codex assisted with diagnosis, validation and this message.

Fixes: 52526ca7fdb9 ("fs/proc/task_mmu: implement IOCTL to get and optionally clear info about PTEs")
Suggested-by: Chris Down <chris@xxxxxxxxxxxxxx>
Suggested-by: Lorenzo Stoakes <ljs@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx # 6.7+
Signed-off-by: Matthew Salsamendi <matthewsalsamendi@xxxxxxxxx>
---
v2: Use the per-walk reset suggested by Chris and Lorenzo.
Verified the 513-range refill and 2 MiB HugeTLB retry on x86-64.

Stable: The bug is present in v6.7. The hunk needs a context adjustment
on v6.7 and applies unchanged to v6.8.

fs/proc/task_mmu.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index b87d3e86442d..8723ffbff77c 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -3155,6 +3155,7 @@ static long do_pagemap_scan(struct mm_struct *mm, unsigned long uarg)
mmu_notifier_invalidate_range_start(&range);
}

+ p.arg.walk_end = 0; /* Reset partial walks. */
ret = walk_page_range(mm, walk_start, p.arg.end,
&pagemap_scan_ops, &p);