Enforce RLIMIT_VMEM on growable mappings (aka the primary stack or any

MAP_STACK mapping).

Suggested by:	alc
This commit is contained in:
Matthew Dillon 2002-06-26 03:13:46 +00:00
parent fa98e2d56e
commit a69ac1740f

View File

@ -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 @@ vm_map_growstack (struct proc *p, vm_offset_t addr)
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;