Commit a68d2ebc authored by Linus Torvalds's avatar Linus Torvalds

Fix up recent get_user_pages() handling

The VM_FAULT_WRITE thing is an extra bit, not a valid return value, and
has to be treated as such by get_user_pages().
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f33ea7f4
...@@ -949,6 +949,8 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, ...@@ -949,6 +949,8 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
cond_resched_lock(&mm->page_table_lock); cond_resched_lock(&mm->page_table_lock);
while (!(page = follow_page(mm, start, write_access))) { while (!(page = follow_page(mm, start, write_access))) {
int ret;
/* /*
* Shortcut for anonymous pages. We don't want * Shortcut for anonymous pages. We don't want
* to force the creation of pages tables for * to force the creation of pages tables for
...@@ -961,16 +963,18 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, ...@@ -961,16 +963,18 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
break; break;
} }
spin_unlock(&mm->page_table_lock); spin_unlock(&mm->page_table_lock);
switch (__handle_mm_fault(mm, vma, start, ret = __handle_mm_fault(mm, vma, start, write_access);
write_access)) {
case VM_FAULT_WRITE:
/* /*
* do_wp_page has broken COW when * The VM_FAULT_WRITE bit tells us that do_wp_page has
* necessary, even if maybe_mkwrite * broken COW when necessary, even if maybe_mkwrite
* decided not to set pte_write * decided not to set pte_write. We can thus safely do
* subsequent page lookups as if they were reads.
*/ */
if (ret & VM_FAULT_WRITE)
write_access = 0; write_access = 0;
/* FALLTHRU */
switch (ret & ~VM_FAULT_WRITE) {
case VM_FAULT_MINOR: case VM_FAULT_MINOR:
tsk->min_flt++; tsk->min_flt++;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment