Pekka J Enberg wrote:
From: Pekka Enberg <[EMAIL PROTECTED]>

We need to break COW for private mappings to make sure a process cannot
read new data after an inode has been revoked.

Seems OK.


Signed-off-by: Pekka Enberg <[EMAIL PROTECTED]>
---
 fs/revoke.c |   85 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 73 insertions(+), 12 deletions(-)

Index: uml-2.6/fs/revoke.c
===================================================================
--- uml-2.6.orig/fs/revoke.c    2007-03-26 18:10:24.000000000 +0300
+++ uml-2.6/fs/revoke.c 2007-03-26 18:27:25.000000000 +0300
@@ -174,12 +174,58 @@ static inline bool need_revoke(struct vm
        if (file->f_path.dentry->d_inode != inode)
                return false;
- if (!(vma->vm_flags & VM_SHARED))
-               return false;
-
        return file != to_exclude;
 }
+static int __revoke_break_cow(struct task_struct *tsk, struct inode *inode,
+                             struct file *to_exclude)
+{
+       struct mm_struct *mm = tsk->mm;
+       struct vm_area_struct *vma;
+       int err = 0;
+
+       down_write(&mm->mmap_sem);
+       for (vma = mm->mmap; vma != NULL; vma = vma->vm_next) {
+               int ret;
+
+               if (vma->vm_flags & VM_SHARED)
+                       continue;
+
+               if (!need_revoke(vma, inode, to_exclude))
+                       continue;
+
+               ret = get_user_pages(tsk, tsk->mm, vma->vm_start,
+                                    vma->vm_end-vma->vm_start, 1, 1, NULL,
+                                    NULL);

get_user_pages length argument is in # of pages, rather than address range,
I think. vma_pages is what you want?

+               if (ret < 0) {
+                       err = ret;
+                       break;
+               }
+       }
+       up_write(&mm->mmap_sem);

I think you just need down_read of mmap_sem here?

--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to