[PATCH 1/2] revoke: only revoke mappings for the given inode
From: Pekka J Enberg
Date: Tue Mar 27 2007 - 03:14:27 EST
From: Pekka Enberg <penberg@xxxxxxxxxxxxxx>
This fixes a bug that was introduced when we switched to rescanning all the
vmas of a mm. We need to check that the vma host file points to the same
inode we are revoking; otherwise we end up revoking all shared mappings.
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxxxxxx>
---
fs/revoke.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
Index: uml-2.6/fs/revoke.c
===================================================================
--- uml-2.6.orig/fs/revoke.c 2007-03-26 17:43:57.000000000 +0300
+++ uml-2.6/fs/revoke.c 2007-03-26 17:48:40.000000000 +0300
@@ -160,15 +160,24 @@ for (fd = 0; fd < fdt->max_fds; fd++) {
}
static inline bool need_revoke(struct vm_area_struct *vma,
+ struct inode *inode,
struct file *to_exclude)
{
+ struct file *file = vma->vm_file;
+
if (vma->vm_flags & VM_REVOKED)
return false;
+ if (!file)
+ return false;
+
+ if (file->f_path.dentry->d_inode != inode)
+ return false;
+
if (!(vma->vm_flags & VM_SHARED))
return false;
- return vma->vm_file != to_exclude;
+ return file != to_exclude;
}
/*
@@ -226,7 +235,7 @@ int err = 0;
goto out;
}
for (vma = mm->mmap; vma != NULL; vma = vma->vm_next) {
- if (!need_revoke(vma, to_exclude))
+ if (!need_revoke(vma, mapping->host, to_exclude))
continue;
err = revoke_vma(vma, &details);
@@ -252,7 +261,7 @@ int try_again = 0;
vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, 0, ULONG_MAX) {
int err;
- if (likely(!need_revoke(vma, to_exclude)))
+ if (likely(!need_revoke(vma, mapping->host, to_exclude)))
continue;
err = revoke_mm(vma->vm_mm, mapping, to_exclude);
@@ -282,7 +291,7 @@ int try_again = 0;
list_for_each_entry(vma, &mapping->i_mmap_nonlinear, shared.vm_set.list) {
int err;
- if (likely(!need_revoke(vma, to_exclude)))
+ if (likely(!need_revoke(vma, mapping->host, to_exclude)))
continue;
err = revoke_mm(vma->vm_mm, mapping, to_exclude);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/