Re: [PATCH] Revert "mm/hugetlbfs: update hugetlbfs to use mmap_prepare"

From: Oscar Salvador

Date: Tue May 12 2026 - 23:21:22 EST


On Tue, May 12, 2026 at 05:06:43PM +0100, Lorenzo Stoakes wrote:
> This reverts commit ea52cb24cd3f ("mm/hugetlbfs: update hugetlbfs to use
> mmap_prepare") with conflict resolution to account for changes in commit
> ea52cb24cd3f ("mm/hugetlbfs: update hugetlbfs to use mmap_prepare").
>
> The patch incorrectly handled hugetlb VMA lock allocation at the
> mmap_prepare stage, where a failed allocation occurring after mmap_prepare
> is called might result in the lock leaking.
>
> There is no risk of a merge causing a similar issues, as VMA_DONTEXPAND_BIT
> is set for hugetlb mappings.
>
> As a first step in addressing this issue, simply revert the change so we
> can rework how we do this having corrected the underlying issues.
>
> We maintain the VMA flags changes as best we can, accounting for the fact
> that we were working with a VMA descriptor previously and propagating
> like-for-like changes for this.
>
> Note that we invoke vma_set_flags() and do not call vma_start_write() as
> vm_flags_set() does. This is OK as it's being done in an .mmap hook where
> the VMA is not yet linked into the tree so nobody else can be accessing it.
>
> Fixes: ea52cb24cd3f ("mm/hugetlbfs: update hugetlbfs to use mmap_prepare")
> Reported-by: Mingyu Wang <25181214217@xxxxxxxxxxxxxxxxx>
> Closes: https://lore.kernel.org/linux-mm/20260425070700.562229-1-25181214217@xxxxxxxxxxxxxxxxx/
> Cc: <stable@xxxxxxxxxxxxxxx>
> Signed-off-by: Lorenzo Stoakes <ljs@xxxxxxxxxx>

Acked-by: Oscar Salvador <osalvador@xxxxxxx>


--
Oscar Salvador
SUSE Labs