patch-2.1.12 linux/mm/mremap.c

Next file: linux/net/Config.in
Previous file: linux/mm/mmap.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.11/linux/mm/mremap.c linux/mm/mremap.c
@@ -146,6 +146,7 @@
 			insert_vm_struct(current->mm, new_vma);
 			merge_segments(current->mm, new_vma->vm_start, new_vma->vm_end);
 			do_munmap(addr, old_len);
+			current->mm->total_vm += new_len >> PAGE_SHIFT;
 			return new_addr;
 		}
 		kfree(new_vma);
@@ -192,6 +193,9 @@
 		if (locked > current->rlim[RLIMIT_MEMLOCK].rlim_cur)
 			return -EAGAIN;
 	}
+	if ((current->mm->total_vm << PAGE_SHIFT) + (new_len - old_len)
+	    > current->rlim[RLIMIT_AS].rlim_cur)
+		return -ENOMEM;
 
 	/* old_len exactly to the end of the area.. */
 	if (old_len == vma->vm_end - addr &&

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov