diff options
author | dillon <dillon@FreeBSD.org> | 2002-06-26 03:13:46 +0000 |
---|---|---|
committer | dillon <dillon@FreeBSD.org> | 2002-06-26 03:13:46 +0000 |
commit | 371cb8c6de82e6b4b072b7d9b306a9c419c41175 (patch) | |
tree | 566bf91857942198ee88c0f8ddba3a32e5cc176d | |
parent | 65b6386089928d7c7f38c6fa7fc2e1acada14a5f (diff) | |
download | FreeBSD-src-371cb8c6de82e6b4b072b7d9b306a9c419c41175.zip FreeBSD-src-371cb8c6de82e6b4b072b7d9b306a9c419c41175.tar.gz |
Enforce RLIMIT_VMEM on growable mappings (aka the primary stack or any
MAP_STACK mapping).
Suggested by: alc
-rw-r--r-- | sys/vm/vm_map.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 656858e..50fc1b9 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -2375,6 +2375,13 @@ vm_map_stack (vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize, return (KERN_NO_SPACE); } + /* If we would blow our VMEM resource limit, no go */ + if (map->size + init_ssize > + curthread->td_proc->p_rlimit[RLIMIT_VMEM].rlim_cur) { + vm_map_unlock(map); + return (KERN_NO_SPACE); + } + /* If we can't accomodate max_ssize in the current mapping, * no go. However, we need to be aware that subsequent user * mappings might map into the space we have reserved for @@ -2518,6 +2525,13 @@ Retry: ctob(vm->vm_ssize); } + /* If we would blow our VMEM resource limit, no go */ + if (map->size + grow_amount > + curthread->td_proc->p_rlimit[RLIMIT_VMEM].rlim_cur) { + vm_map_unlock_read(map); + return (KERN_NO_SPACE); + } + if (vm_map_lock_upgrade(map)) goto Retry; |