Re: [PATCH V2 1/3] mm/hugetlb: fix mremap move length truncation

From: Li Zhe

Date: Tue Oct 20 2026 - 22:39:25 EST


On 10/20/26 4:18 PM, David Hildenbrand (Arm) wrote:
> On 10/19/26 13:30, Li Zhe wrote:
>> move_hugetlb_page_tables() returns the number of bytes moved, but
>> its return type is int while the generic move_page_tables() path uses
>> unsigned long lengths.
>>
>> A hugetlb mremap() move length above INT_MAX can therefore be
>> misreported to copy_vma_and_data(). The out-of-range conversion to int
>> is implementation-defined; on common 64-bit builds, for example, a
>> 4 GiB move can be reported as zero, making the caller treat the move as
>> a failure and use the wrong length for rollback.
> Sounds like we want to CC stable here, right?


Thanks, I will add Cc: stable@xxxxxxxxxxxxxxx in v3.

>
>> Return unsigned long from move_hugetlb_page_tables(), matching
>> move_page_tables() and preserving the full byte count.
>>
>> Fixes: 550a7d60bd5e ("mm, hugepages: add mremap() support for hugepage backed vma")
>> Signed-off-by: Li Zhe <lizhe.67@xxxxxxxxxxxxx>
>> ---
>> include/linux/hugetlb.h | 18 +++++++++---------
>> mm/hugetlb.c | 8 ++++----
>> 2 files changed, 13 insertions(+), 13 deletions(-)
>>
>> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
>> index 16c4c4caa126..cc12040e4032 100644
>> --- a/include/linux/hugetlb.h
>> +++ b/include/linux/hugetlb.h
>> @@ -121,10 +121,10 @@ void hugepage_put_subpool(struct hugepage_subpool *spool);
>>
>> void hugetlb_dup_vma_private(struct vm_area_struct *vma);
>> void clear_vma_resv_huge_pages(struct vm_area_struct *vma);
>> -int move_hugetlb_page_tables(struct vm_area_struct *vma,
>> - struct vm_area_struct *new_vma,
>> - unsigned long old_addr, unsigned long new_addr,
>> - unsigned long len);
>> +unsigned long move_hugetlb_page_tables(struct vm_area_struct *vma,
>> + struct vm_area_struct *new_vma,
>> + unsigned long old_addr, unsigned long new_addr,
>> + unsigned long len);
> While at it, can you convert all these to use double tab indent instead?
>
> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>


Thanks, I will fix the indentation in v3.

Thanks,
Zhe