[patch 14/39] remap_file_pages protection support: assume VM_SHARED never disappears

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Paolo 'Blaisorblade' Giarrusso <[email protected]>

Assume that even after dropping and reacquiring the lock, (vma->vm_flags &
VM_SHARED) won't change, thus moving a check earlier.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[email protected]>
---

 linux-2.6.git-paolo/mm/fremap.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff -puN mm/fremap.c~rfp-assume-VM_PRIVATE-stays mm/fremap.c
--- linux-2.6.git/mm/fremap.c~rfp-assume-VM_PRIVATE-stays	2005-08-11 12:58:07.000000000 +0200
+++ linux-2.6.git-paolo/mm/fremap.c	2005-08-11 13:38:56.000000000 +0200
@@ -232,6 +232,8 @@ retry:
 
 		/* Must set VM_NONLINEAR before any pages are populated. */
 		if (pgoff != linear_page_index(vma, start)) {
+			if (!(vma->vm_flags & VM_SHARED))
+				goto out_unlock;
 			if (!(vma->vm_flags & VM_NONLINEAR)) {
 				if (!has_write_lock) {
 					up_read(&mm->mmap_sem);
@@ -239,12 +241,6 @@ retry:
 					has_write_lock = 1;
 					goto retry;
 				}
-				/* XXX: we check VM_SHARED after re-getting the
-				 * (write) semaphore but I guess that we could
-				 * check it earlier as we're not allowed to turn
-				 * a VM_PRIVATE vma into a VM_SHARED one! */
-				if (!(vma->vm_flags & VM_SHARED))
-					goto out_unlock;
 
 				mapping = vma->vm_file->f_mapping;
 				spin_lock(&mapping->i_mmap_lock);
@@ -254,10 +250,6 @@ retry:
 				vma_nonlinear_insert(vma, &mapping->i_mmap_nonlinear);
 				flush_dcache_mmap_unlock(mapping);
 				spin_unlock(&mapping->i_mmap_lock);
-			} else {
-				/* Won't drop the lock, check it here.*/
-				if (!(vma->vm_flags & VM_SHARED))
-					goto out_unlock;
 			}
 		}
 
_
-
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/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux