Re: [PATCH 2/3] hugetlbfs: close race between MADV_DONTNEED and page fault

From: Rik van Riel
Date: Mon Oct 02 2023 - 09:13:53 EST


On Sun, 2023-10-01 at 21:39 -0700, Mike Kravetz wrote:
>
> Looks like vma->vm_file is NULL and __hugetlb_zap_begin is trying to
> do
> i_mmap_lock_write(vma->vm_file->f_mapping).
>
> Guess I did look closely. :)

Ugh. It looks like the fix for this bug ended up getting pulled
into patch 3, instead of patch 2. I've had it in my code for a
while now :/

Let me move the fix for this thing into patch 2.

void __hugetlb_zap_begin(struct vm_area_struct *vma,
unsigned long *start, unsigned long *end)
{
adjust_range_if_pmd_sharing_possible(vma, start, end);
hugetlb_vma_lock_write(vma);
if (vma->vm_file)
i_mmap_lock_write(vma->vm_file->f_mapping);
}


--
All Rights Reversed.