Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Li Zhe <lizhe.67@bytedance.com>,
	muchun.song@linux.dev, osalvador@suse.de,
	akpm@linux-foundation.org, rppt@kernel.org, peterx@redhat.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2 1/3] mm/hugetlb: fix mremap move length truncation
Date: Tue, 20 Oct 2026 10:18:23 +0200	[thread overview]
Message-ID: <b6d4de88-cf2c-444d-8050-da2a9b22c7b9@kernel.org> (raw)
In-Reply-To: <20261019113034.97690-2-lizhe.67@bytedance.com>

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?

> 
> 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@bytedance.com>
> ---
>  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@kernel.org>

-- 
Cheers,

David


  reply	other threads:[~2026-10-20  8:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 11:30 [PATCH V2 0/3] mm/hugetlb: fix mremap bugs Li Zhe
2026-10-19 11:30 ` [PATCH V2 1/3] mm/hugetlb: fix mremap move length truncation Li Zhe
2026-10-20  8:18   ` David Hildenbrand (Arm) [this message]
2026-10-19 11:30 ` [PATCH V2 2/3] mm/hugetlb: disable PMD sharing for UFFD missing mode Li Zhe
2026-10-20 10:11   ` Mike Rapoport
2026-10-20 10:33     ` David Hildenbrand (Arm)
2026-10-19 11:30 ` [PATCH V2 3/3] mm/hugetlb: fix mremap deadlock when PMD sharing is possible Li Zhe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b6d4de88-cf2c-444d-8050-da2a9b22c7b9@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizhe.67@bytedance.com \
    --cc=muchun.song@linux.dev \
    --cc=osalvador@suse.de \
    --cc=peterx@redhat.com \
    --cc=rppt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox