--- a/mm/gup.c~mm-gup-fix-__get_user_pages-on-fault-retry-of-hugetlb +++ a/mm/gup.c @@ -1065,6 +1065,16 @@ static long __get_user_pages(struct task i = follow_hugetlb_page(mm, vma, pages, vmas, &start, &nr_pages, i, gup_flags, locked); + if (locked && *locked == 0) { + /* + * We've got a VM_FAULT_RETRY + * and we've lost mmap_sem. + * We must stop here. + */ + BUG_ON(gup_flags & FOLL_NOWAIT); + BUG_ON(ret != 0); + goto out; + } continue; } }