Skip to contentSkip to conversation

missing check in __get_user_pages

DISCUSSION Dave Jones 2 participants 2 messages Jun 10, 2014 Memory management

lore
Share & tools
lore

Dave Jones

author
#0 lore raw

coverity flagged this code in __get_user_pages

448 if (is_vm_hugetlb_page(vma)) {
449 i = follow_hugetlb_page(mm, vma, pages, vmas,
450 &start, &nr_pages, i,
451 gup_flags);
452 continue;
453 }

It seems unaware that follow_hugetlb_page can in some cases return -EFAULT. I'm not sure if this is triggerable, but it looks dangerous.

Dave

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 11 lines · Dave Jones

coverity flagged this code in __get_user_pages

448 if (is_vm_hugetlb_page(vma)) {
449 i = follow_hugetlb_page(mm, vma, pages, vmas,
450 &start, &nr_pages, i,
451 gup_flags);
452 continue;
453 }

It seems unaware that follow_hugetlb_page can in some cases return -EFAULT. I'm not sure if this is triggerable, but it looks dangerous.

Looks like follow_hugetlb_page() sets nr_pages to 0 in this case, and __get_user_pages() can handle this correctly.

But, yes, it's ugly.

Signature · 7 lines
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>