On Thu, Nov 01, 2007 at 08:14:47AM -0700, Linus Torvalds wrote:No, it COWs it (the file is RW). I believe do_wp_page will still attach an anon_vma to the vma, which will make the pte discoverable via rmap. Yeah of course that won't work, stupid... The intent is to stop get_user_pages from proceeding with a write fault (and subsequent COW) to readonly shared mappings, when force is set. I think it can be done simply via get_user_pages(), which is what I should have done to begin with. Untested patch follows --- Index: linux-2.6/mm/memory.c =================================================================== --- linux-2.6.orig/mm/memory.c +++ linux-2.6/mm/memory.c @@ -1031,7 +1031,9 @@ int get_user_pages(struct task_struct *t } if (!vma || (vma->vm_flags & (VM_IO | VM_PFNMAP)) - || !(vm_flags & vma->vm_flags)) + || !(vm_flags & vma->vm_flags) + || (write && ((vma->vm_flags & + (VM_SHARED|VM_MAYSHARE)) == VM_MAYSHARE))) return i ? : -EFAULT; if (is_vm_hugetlb_page(vma)) { @@ -1563,13 +1565,11 @@ static int do_wp_page(struct mm_struct * reuse = can_share_swap_page(old_page); unlock_page(old_page); } - } else if (unlikely((vma->vm_flags & (VM_WRITE|VM_SHARED)) == - (VM_WRITE|VM_SHARED))) { + } else if (unlikely((vma->vm_flags & VM_SHARED))) { /* - * Only catch write-faults on shared writable pages, - * read-only shared pages can get COWed by - * get_user_pages(.write=1, .force=1). + * Only catch write-faults on shared writable pages. */ + BUG_ON(!(vma->vm_flags & VM_WRITE)); if (vma->vm_ops && vma->vm_ops->page_mkwrite) { /* * Notify the address space that the page is about to -
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| david | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Rob Landley | What still uses the block layer? |
git: | |
| Antonio Almeida | HTB accuracy for high speed |
| Alexey Dobriyan | Re: [GIT]: Networking |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
