Re: [PATCH v1] mm/hugetlb: don't map folios writable without VM_WRITE when copying during fork()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 04, 2024 at 04:31:00PM +0100, David Hildenbrand wrote:
> If we have to trigger a hugetlb folio copy during fork() because the anon
> folio might be pinned, we currently unconditionally create a writable
> PTE.
> 
> However, the VMA might not have write permissions (VM_WRITE) at that
> point.
> 
> Fix it by checking the VMA for VM_WRITE. Make the code less error prone
> by moving checking for VM_WRITE into make_huge_pte(), and letting
> callers only specify whether we should try making it writable.
> 
> A simple reproducer that longter-pins the folios using liburing to then
> mprotect(PROT_READ) the folios befor fork() [1] results in:
> 
> Before:
> [FAIL] access should not have worked
> 
> After:
> [PASS] access did not work as expected
> 
> [1] https://gitlab.com/davidhildenbrand/scratchspace/-/raw/main/reproducers/hugetlb-mkwrite-fork.c
> 
> This is rather a corner case, so stable might not be warranted.
> 
> Fixes: 4eae4efa2c29 ("hugetlb: do early cow when page pinned on src mm")
> Cc: Muchun Song <muchun.song@xxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Peter Xu <peterx@xxxxxxxxxx>
> Cc: Guillaume Morin <guillaume@xxxxxxxxxxx>
> Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>

Acked-by: Peter Xu <peterx@xxxxxxxxxx>

Thanks,

-- 
Peter Xu





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux