hugetlb does not support soft-dirty tracking: since commit f96f7a40874d ("mm/hugetlb: fix hugetlb not supporting softdirty tracking"), vma_wants_writenotify() ignores VM_SOFTDIRTY for hugetlb VMAs, and clear_refs never clears the soft-dirty bits of hugetlb entries. However, clear_refs still clears VM_SOFTDIRTY on hugetlb VMAs. With CONFIG_MEM_SOFT_DIRTY, a FOLL_FORCE write to a private hugetlb mapping without VM_WRITE can then loop in __get_user_pages() until the task is killed, with the mmap_lock held for reading: __get_user_pages() retry: follow_page_mask() follow_huge_pmd() can_follow_write_pmd() pmd_needs_soft_dirty_wp() is true returns NULL faultin_page() hugetlb_wp() set_huge_ptep_maybe_writable() no VM_WRITE: the entry stays as it is returns 0 goto retry Let's fix it by not clearing VM_SOFTDIRTY on hugetlb VMAs, so we always treat hugetlb pages as soft-dirty. This has low urgency, as the loop can be killed. Fixes: 052ccfbcc6cd ("mm/hugetlb: support FOLL_FORCE|FOLL_WRITE") Cc: Reported-by: Chris Mason Signed-off-by: David Hildenbrand (Arm) --- fs/proc/task_mmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 41b280ab7b19d..d9ecb94f4daa5 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1801,6 +1801,9 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, if (type == CLEAR_REFS_SOFT_DIRTY) { for_each_vma(vmi, vma) { + /* hugetlb does not support soft-dirty tracking. */ + if (vma_is_hugetlb(vma)) + continue; if (!(vma->vm_flags & VM_SOFTDIRTY)) continue; vm_flags_clear(vma, VM_SOFTDIRTY); -- 2.56.1