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.
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to