From: Peter Zijlstra get_user_pages(.write=1, .force=1) can generate COW hits on read-only shared mappings, this patch traps those as mkpage_write candidates and fails to handle them the old way. Cc: David Howells Cc: Miklos Szeredi Cc: Joel Becker Cc: Mark Fasheh Cc: Anton Altaparmakov Cc: David Woodhouse Cc: Hugh Dickins Signed-off-by: Andrew Morton --- mm/memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff -puN mm/memory.c~add-page_mkwrite-vm_operations-method-fix mm/memory.c --- a/mm/memory.c~add-page_mkwrite-vm_operations-method-fix +++ a/mm/memory.c @@ -1463,7 +1463,8 @@ static int do_wp_page(struct mm_struct * if (!old_page) goto gotten; - if (unlikely(vma->vm_flags & VM_SHARED)) { + if (unlikely((vma->vm_flags & (VM_SHARED|VM_WRITE)) == + (VM_SHARED|VM_WRITE))) { if (vma->vm_ops && vma->vm_ops->page_mkwrite) { /* * Notify the address space that the page is about to _