patch-2.2.16 linux/mm/mmap.c

Next file: linux/mm/page_alloc.c
Previous file: linux/mm/filemap.c
Back to the patch index
Back to the overall index

diff -urN v2.2.15/linux/mm/mmap.c linux/mm/mmap.c
@@ -197,6 +197,8 @@
 	if (mm->def_flags & VM_LOCKED) {
 		unsigned long locked = mm->locked_vm << PAGE_SHIFT;
 		locked += len;
+		if (locked < len)
+			return -EAGAIN;
 		if ((current->rlim[RLIMIT_MEMLOCK].rlim_cur < RLIM_INFINITY) &&
 		   (locked > current->rlim[RLIMIT_MEMLOCK].rlim_cur))
 			return -EAGAIN;
@@ -289,6 +291,8 @@
 		goto free_vma;
 
 	/* Check against address space limit. */
+	if ((mm->total_vm << PAGE_SHIFT) + len < len)
+		goto free_vma;
 	if ((current->rlim[RLIMIT_AS].rlim_cur < RLIM_INFINITY) &&
 	    ((mm->total_vm << PAGE_SHIFT) + len
 	    > current->rlim[RLIMIT_AS].rlim_cur))

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)