]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs/proc/task_mmu: use huge_page_size() in pagemap_scan_hugetlb_entry()
authorKiryl Shutsemau (Meta) <kas@kernel.org>
Fri, 29 May 2026 17:23:26 +0000 (18:23 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 9 Jun 2026 01:21:28 +0000 (18:21 -0700)
The partial-page check compares against HPAGE_SIZE (PMD_SIZE), which is
wrong for gigantic hugetlb hstates (e.g.  1G).  The walker hands the
callback a huge_page_size()-sized range, never start + HPAGE_SIZE, so the
comparison always declares it partial and aborts the WP.  Compare against
the actual hstate's page size.

Link: https://lore.kernel.org/20260529172331.356655-3-kas@kernel.org
Fixes: 52526ca7fdb9 ("fs/proc/task_mmu: implement IOCTL to get and optionally clear info about PTEs")
Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
Reported-by: Sashiko AI review <sashiko-bot@kernel.org>
Reviewed-by: Lorenzo Stoakes <ljs@kernel.org>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Balbir Singh <balbirs@nvidia.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/proc/task_mmu.c

index e21a38ac745b0bf72d7d34a1dd844ae743f12b1d..1489c67e88f7431d64806cde465023fc90893147 100644 (file)
@@ -2960,7 +2960,7 @@ static int pagemap_scan_hugetlb_entry(pte_t *ptep, unsigned long hmask,
        if (~categories & PAGE_IS_WRITTEN)
                goto out_unlock;
 
-       if (end != start + HPAGE_SIZE) {
+       if (end != start + huge_page_size(hstate_vma(vma))) {
                /* Partial HugeTLB page WP isn't possible. */
                pagemap_scan_backout_range(p, start, end);
                p->arg.walk_end = start;