Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Feb 2012 06:45:51 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r231819 - head/sys/vm
Message-ID:  <201202160645.q1G6jpRG002965@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Thu Feb 16 06:45:51 2012
New Revision: 231819
URL: http://svn.freebsd.org/changeset/base/231819

Log:
  When vm_mmap() is used to map a vm object into a kernel vm_map, it
  makes no sense to check the size of the kernel vm_map against the
  user-level resource limits for the calling process.
  
  Reviewed by:	kib

Modified:
  head/sys/vm/vm_mmap.c

Modified: head/sys/vm/vm_mmap.c
==============================================================================
--- head/sys/vm/vm_mmap.c	Thu Feb 16 06:11:00 2012	(r231818)
+++ head/sys/vm/vm_mmap.c	Thu Feb 16 06:45:51 2012	(r231819)
@@ -1438,18 +1438,18 @@ vm_mmap(vm_map_t map, vm_offset_t *addr,
 
 	size = round_page(size);
 
-	PROC_LOCK(td->td_proc);
-	if (td->td_proc->p_vmspace->vm_map.size + size >
-	    lim_cur(td->td_proc, RLIMIT_VMEM)) {
-		PROC_UNLOCK(td->td_proc);
-		return (ENOMEM);
-	}
-	if (racct_set(td->td_proc, RACCT_VMEM,
-	    td->td_proc->p_vmspace->vm_map.size + size)) {
+	if (map == &td->td_proc->p_vmspace->vm_map) {
+		PROC_LOCK(td->td_proc);
+		if (map->size + size > lim_cur(td->td_proc, RLIMIT_VMEM)) {
+			PROC_UNLOCK(td->td_proc);
+			return (ENOMEM);
+		}
+		if (racct_set(td->td_proc, RACCT_VMEM, map->size + size)) {
+			PROC_UNLOCK(td->td_proc);
+			return (ENOMEM);
+		}
 		PROC_UNLOCK(td->td_proc);
-		return (ENOMEM);
 	}
-	PROC_UNLOCK(td->td_proc);
 
 	/*
 	 * We currently can only deal with page aligned file offsets.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202160645.q1G6jpRG002965>