[PATCH 1/2] revoke: only revoke mappings for the given inode

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Pekka J Enberg
Date: Tuesday, March 27, 2007 - 12:14 am

From: Pekka Enberg <penberg@cs.helsinki.fi>

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@cs.helsinki.fi>
---
 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);
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/2] revoke: only revoke mappings for the given inode, Pekka J Enberg, (Tue Mar 27, 12:14 am)