summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_mmap.c
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2002-06-26 00:29:28 +0000
committerdillon <dillon@FreeBSD.org>2002-06-26 00:29:28 +0000
commitff4bf466480a64136e0e6a7758a29624eafbd106 (patch)
treea346a6d505627055a83c70b91c8751c9f2aa92ed /sys/vm/vm_mmap.c
parentb6fded0fafcf9aca9e1db60dc0d8d9ed9c48393e (diff)
downloadFreeBSD-src-ff4bf466480a64136e0e6a7758a29624eafbd106.zip
FreeBSD-src-ff4bf466480a64136e0e6a7758a29624eafbd106.tar.gz
Part I of RLIMIT_VMEM implementation. Implement core functionality for
a new resource limit that covers a process's entire VM space, including mmap()'d space. (Part II will be additional code to check RLIMIT_VMEM during exec() but it needs more fleshing out). PR: kern/18209 Submitted by: Andrey Alekseyev <uitm@zenon.net>, Dmitry Kim <jason@nichego.net> MFC after: 7 days
Diffstat (limited to 'sys/vm/vm_mmap.c')
-rw-r--r--sys/vm/vm_mmap.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 4911ef7..698179a 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -55,6 +55,8 @@
#include <sys/sysproto.h>
#include <sys/filedesc.h>
#include <sys/proc.h>
+#include <sys/resource.h>
+#include <sys/resourcevar.h>
#include <sys/vnode.h>
#include <sys/fcntl.h>
#include <sys/file.h>
@@ -1124,6 +1126,11 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot,
objsize = size = round_page(size);
+ if (td->td_proc->p_vmspace->vm_map.size + size >
+ td->td_proc->p_rlimit[RLIMIT_VMEM].rlim_cur) {
+ return(ENOMEM);
+ }
+
/*
* We currently can only deal with page aligned file offsets.
* The check is here rather than in the syscall because the
OpenPOWER on IntegriCloud