Re: [PATCH v2 28/35] mm/migrate: check hugetlb PMD sharing in move_pages()
From: Jose A. Perez de Azpillaga
Date: Fri Dec 04 2026 - 06:39:05 EST
On 12/3/26 12:37 PM, David Hildenbrand (Arm) wrote:
> Without MPOL_MF_MOVE_ALL, which requires CAP_SYS_NICE, move_pages(2)
> refuses to migrate folios that might be mapped by other processes.
>
> However, folio_maybe_mapped_shared() does not check for page table
> sharing. So move_pages(2) with MPOL_MF_MOVE can migrate hugetlb
> folios that other processes map.
>
> mbind(2) and migrate_pages(2) already handle PMD table sharing since
> commit 73bdf65ea748 ("migrate: hugetlb: check for hugetlb shared PMD in
> node migration"), but we missed move_pages(2).
>
> Let's fix it by using hugetlb_folio_maybe_mapped_shared() for hugetlb
> folios in move_pages(2). Such folios are now reported with -EACCES in
> the status array.
>
> Rework the code to have separate checks for hugetlb vs. !hugetlb.
>
> This has low urgency.
>
> Fixes: e632a938d914 ("mm: migrate: add hugepage migration code to move_pages()")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Reported-by: Chris Mason <mason@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
LGTM:
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
--
cheers,
jose a. p-a