summaryrefslogtreecommitdiff
path: root/include/linux/miscdevice.h
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2024-12-04 16:31:00 +0100
committerAndrew Morton <akpm@linux-foundation.org>2025-01-13 22:40:46 -0800
commitd8fd84dd4ce72e371a6604809e25e16e24b997d4 (patch)
tree3abfdc0f4578e6beafaa040d53976e70197f9fcc /include/linux/miscdevice.h
parentd0f14f7ee0e2d5df447d54487ae0c3aee5a7208f (diff)
mm/hugetlb: don't map folios writable without VM_WRITE when copying during fork()
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 longterm-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. Link: https://lkml.kernel.org/r/20241204153100.1967364-1-david@redhat.com Fixes: 4eae4efa2c29 ("hugetlb: do early cow when page pinned on src mm") Signed-off-by: David Hildenbrand <david@redhat.com> Acked-by: Peter Xu <peterx@redhat.com> Cc: Muchun Song <muchun.song@linux.dev> Cc: Guillaume Morin <guillaume@morinfr.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'include/linux/miscdevice.h')
0 files changed, 0 insertions, 0 deletions