Skip to content

Commit 6581ccf

Browse files
committed
mm: fix __access_remote_vm() GUP failure case
Commit ca5e863 ("mm/gup: remove vmas parameter from get_user_pages_remote()") removed the vma argument from GUP handling, and instead added a helper function (get_user_page_vma_remote()) that looks it up separately using 'vma_lookup()'. And then converted existing users that needed a vma to use the helper instead. However, the helper function intentionally acts exactly like the old get_user_pages_remote() did, and only fills in 'vma' on successful page lookup. Fine so far. However, __access_remote_vm() wants the vma even for the unsuccessful case, and used to do a vma = vma_lookup(mm, addr); explicitly to look it up when the get_user_page() failed. However, that conversion commit incorrectly removed that vma lookup, thinking that get_user_page_vma_remote() would have done it. Not so. So add the vma_lookup() back in. Fixes: ca5e863 ("mm/gup: remove vmas parameter from get_user_pages_remote()") Cc: Lorenzo Stoakes <lstoakes@gmail.com> Cc: David Hildenbrand <david@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 77b1a7f commit 6581ccf

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

mm/memory.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5592,6 +5592,7 @@ int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf,
55925592
* Check if this is a VM_IO | VM_PFNMAP VMA, which
55935593
* we can access using slightly different code.
55945594
*/
5595+
vma = vma_lookup(mm, addr);
55955596
if (!vma)
55965597
break;
55975598
if (vma->vm_ops && vma->vm_ops->access)

0 commit comments

Comments
 (0)