summaryrefslogtreecommitdiff
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2015-02-09 09:39:10 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2015-02-09 09:39:10 +0000
commit7d2e65ea02d86a88c2578ef0ba9f4c24cfacd57d (patch)
tree450425a1036d82941b47a370428a0981fd95c444 /sys/kern/kern_resource.c
parentff9b0a9233113ee5f492faf397c0416cc25a2615 (diff)
Stop using USRSTACK as the edge of the stack, but rather use the vmspace
vm_minsaddr or vm_maxsaddr, depending upon the direction the stack goes in. This should have no effect on the existing behaviourrr. ok kettenis@ deraadt@
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 29b8b089e04..c0d6f8d95ed 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_resource.c,v 1.53 2014/12/19 05:59:21 tedu Exp $ */
+/* $OpenBSD: kern_resource.c,v 1.54 2015/02/09 09:39:09 miod Exp $ */
/* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */
/*-
@@ -279,27 +279,32 @@ dosetrlimit(struct proc *p, u_int which, struct rlimit *limp)
vaddr_t addr;
vsize_t size;
vm_prot_t prot;
+ struct vmspace *vm = p->p_vmspace;
if (limp->rlim_cur > alimp->rlim_cur) {
prot = PROT_READ | PROT_WRITE;
size = limp->rlim_cur - alimp->rlim_cur;
#ifdef MACHINE_STACK_GROWS_UP
- addr = USRSTACK + alimp->rlim_cur;
+ addr = (vaddr_t)vm->vm_maxsaddr +
+ alimp->rlim_cur;
#else
- addr = USRSTACK - limp->rlim_cur;
+ addr = (vaddr_t)vm->vm_minsaddr -
+ limp->rlim_cur;
#endif
} else {
prot = PROT_NONE;
size = alimp->rlim_cur - limp->rlim_cur;
#ifdef MACHINE_STACK_GROWS_UP
- addr = USRSTACK + limp->rlim_cur;
+ addr = (vaddr_t)vm->vm_maxsaddr +
+ limp->rlim_cur;
#else
- addr = USRSTACK - alimp->rlim_cur;
+ addr = (vaddr_t)vm->vm_minsaddr -
+ alimp->rlim_cur;
#endif
}
addr = trunc_page(addr);
size = round_page(size);
- (void) uvm_map_protect(&p->p_vmspace->vm_map,
+ (void) uvm_map_protect(&vm->vm_map,
addr, addr+size, prot, FALSE);
}
}