- mm-recheck-lock-rlim-after-f_op-mmap-method.patch removed from -mm tree

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

 



The patch titled
     mm: recheck lock rlim after f_op->mmap() method
has been removed from the -mm tree.  Its filename was
     mm-recheck-lock-rlim-after-f_op-mmap-method.patch

This patch was dropped because it is obsolete

------------------------------------------------------
Subject: mm: recheck lock rlim after f_op->mmap() method
From: Dmitry Monakhov <dmonakhov@xxxxx>

Some device drivers can change vm_flags in their f_op->mmap method.  In
order to be on the safe side we have to recheck lock rlimit.  Now we have
to check lock rlimit from two places, let's move this common code to helper
functon.

Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
Cc: Herbert van den Bergh <herbert.van.den.bergh@xxxxxxxxxx>
Cc: Chris Mason <chris.mason@xxxxxxxxxx>
Cc: Nick Piggin <nickpiggin@xxxxxxxxxxxx>
Cc: Hugh Dickins <hugh@xxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/mmap.c |   33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff -puN mm/mmap.c~mm-recheck-lock-rlim-after-f_op-mmap-method mm/mmap.c
--- a/mm/mmap.c~mm-recheck-lock-rlim-after-f_op-mmap-method
+++ a/mm/mmap.c
@@ -885,6 +885,18 @@ void vm_stat_account(struct mm_struct *m
 }
 #endif /* CONFIG_PROC_FS */
 
+static int check_lock_limit(unsigned long delta, struct mm_struct* mm)
+{
+	unsigned long locked, lock_limit;
+	locked = delta >> PAGE_SHIFT;
+	locked += mm->locked_vm;
+	lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
+	lock_limit >>= PAGE_SHIFT;
+	if (locked > lock_limit && !capable(CAP_IPC_LOCK))
+		return -EAGAIN;
+	return 0;
+}
+
 /*
  * The caller must hold down_write(current->mm->mmap_sem).
  */
@@ -954,13 +966,9 @@ unsigned long do_mmap_pgoff(struct file 
 	}
 	/* mlock MCL_FUTURE? */
 	if (vm_flags & VM_LOCKED) {
-		unsigned long locked, lock_limit;
-		locked = len >> PAGE_SHIFT;
-		locked += mm->locked_vm;
-		lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
-		lock_limit >>= PAGE_SHIFT;
-		if (locked > lock_limit && !capable(CAP_IPC_LOCK))
-			return -EAGAIN;
+		error = check_lock_limit(len, mm);
+		if (error)
+			return error;
 	}
 
 	inode = file ? file->f_path.dentry->d_inode : NULL;
@@ -1101,6 +1109,17 @@ munmap_back:
 		error = file->f_op->mmap(file, vma);
 		if (error)
 			goto unmap_and_free_vma;
+
+		if (vma->vm_flags & VM_LOCKED
+				&& !(vm_flags & VM_LOCKED)) {
+		/*
+		 * VM_LOCKED was added in f_op->mmap() method,
+		 * so we have to recheck limit.
+		 */
+			error = check_lock_limit(len, mm);
+			if (error)
+				goto unmap_and_free_vma;
+		}
 	} else if (vm_flags & VM_SHARED) {
 		error = shmem_zero_setup(vma);
 		if (error)
_

Patches currently in -mm which might be from dmonakhov@xxxxx are

mspec_mmap-dont-set-vm_locked.patch
mm-recheck-lock-rlim-after-f_op-mmap-method.patch
fs-introduce-write_begin-write_end-and-perform_write-aops.patch
deny-partial-write-for-loop-dev-fd.patch
ext3-convert-to-new-aops-fix.patch
ext4-convert-to-new-aops-fix.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux