mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
hugetlb: follow_hugetlb_page() for write access
When calling get_user_pages(), a write flag is passed in by the caller to indicate if write access is required on the faulted-in pages. Currently, follow_hugetlb_page() ignores this flag and always faults pages for read-only access. This can cause data corruption because a device driver that calls get_user_pages() with write set will not expect COW faults to occur on the returned pages. This patch passes the write flag down to follow_hugetlb_page() and makes sure hugetlb_fault() is called with the right write_access parameter. [[email protected]: build fix] Signed-off-by: Adam Litke <[email protected]> Reviewed-by: Ken Chen <[email protected]> Cc: David Gibson <[email protected]> Cc: William Lee Irwin III <[email protected]> Cc: Badari Pulavarty <[email protected]> Signed-off-by: Erez Zadok <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
19cd7537bd
commit
5b23dbe817
3 changed files with 6 additions and 5 deletions
|
|
@ -868,7 +868,8 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
|
|||
|
||||
int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
|
||||
struct page **pages, struct vm_area_struct **vmas,
|
||||
unsigned long *position, int *length, int i)
|
||||
unsigned long *position, int *length, int i,
|
||||
int write)
|
||||
{
|
||||
unsigned long pfn_offset;
|
||||
unsigned long vaddr = *position;
|
||||
|
|
@ -890,7 +891,7 @@ int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
|
|||
int ret;
|
||||
|
||||
spin_unlock(&mm->page_table_lock);
|
||||
ret = hugetlb_fault(mm, vma, vaddr, 0);
|
||||
ret = hugetlb_fault(mm, vma, vaddr, write);
|
||||
spin_lock(&mm->page_table_lock);
|
||||
if (!(ret & VM_FAULT_ERROR))
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -1036,7 +1036,7 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
|
|||
|
||||
if (is_vm_hugetlb_page(vma)) {
|
||||
i = follow_hugetlb_page(mm, vma, pages, vmas,
|
||||
&start, &len, i);
|
||||
&start, &len, i, write);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue