summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/init_main.c5
-rw-r--r--sys/kern/kern_exec.c10
-rw-r--r--sys/kern/kern_resource.c17
-rw-r--r--sys/uvm/uvm_unix.c29
4 files changed, 36 insertions, 25 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index a055fae705c..c84a23f80fb 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init_main.c,v 1.233 2015/01/19 01:19:17 deraadt Exp $ */
+/* $OpenBSD: init_main.c,v 1.234 2015/02/09 09:39:09 miod Exp $ */
/* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */
/*
@@ -634,12 +634,13 @@ start_init(void *arg)
#else
addr = USRSTACK - PAGE_SIZE;
#endif
+ p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
+ p->p_vmspace->vm_minsaddr = (caddr_t)(addr + PAGE_SIZE);
if (uvm_map(&p->p_vmspace->vm_map, &addr, PAGE_SIZE,
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(PROT_READ | PROT_WRITE, PROT_MASK, MAP_INHERIT_COPY,
MADV_NORMAL, UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW)))
panic("init: couldn't allocate argument space");
- p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) {
#ifdef MACHINE_STACK_GROWS_UP
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 1a83972782d..9f32fa441b8 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exec.c,v 1.158 2015/02/07 08:47:49 tedu Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.159 2015/02/09 09:39:09 miod Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
@@ -461,12 +461,12 @@ sys_execve(struct proc *p, void *v, register_t *retval)
pr->ps_stackgap = 0;
#ifdef MACHINE_STACK_GROWS_UP
- pr->ps_strings = (vaddr_t)USRSTACK + sgap;
+ pr->ps_strings = (vaddr_t)vm->vm_maxsaddr + sgap;
if (uvm_map_protect(&vm->vm_map, (vaddr_t)vm->vm_maxsaddr,
trunc_page(pr->ps_strings), PROT_NONE, TRUE))
goto exec_abort;
#else
- pr->ps_strings = (vaddr_t)USRSTACK - sizeof(arginfo) - sgap;
+ pr->ps_strings = (vaddr_t)vm->vm_minsaddr - sizeof(arginfo) - sgap;
if (uvm_map_protect(&vm->vm_map,
round_page(pr->ps_strings + sizeof(arginfo)),
(vaddr_t)vm->vm_minsaddr, PROT_NONE, TRUE))
@@ -478,10 +478,10 @@ sys_execve(struct proc *p, void *v, register_t *retval)
arginfo.ps_nenvstr = envc;
#ifdef MACHINE_STACK_GROWS_UP
- stack = (char *)USRSTACK + sizeof(arginfo) + sgap;
+ stack = (char *)vm->vm_maxsaddr + sizeof(arginfo) + sgap;
slen = len - sizeof(arginfo) - sgap;
#else
- stack = (char *)(USRSTACK - len);
+ stack = (char *)(vm->vm_minsaddr - len);
#endif
/* Now copy argc, args & environ to new stack */
if (!(*pack.ep_emul->e_copyargs)(&pack, &arginfo, stack, argp))
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);
}
}
diff --git a/sys/uvm/uvm_unix.c b/sys/uvm/uvm_unix.c
index 3bc74bcbc41..69fb33546db 100644
--- a/sys/uvm/uvm_unix.c
+++ b/sys/uvm/uvm_unix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_unix.c,v 1.54 2014/12/17 06:58:11 guenther Exp $ */
+/* $OpenBSD: uvm_unix.c,v 1.55 2015/02/09 09:39:09 miod Exp $ */
/* $NetBSD: uvm_unix.c,v 1.18 2000/09/13 15:00:25 thorpej Exp $ */
/*
@@ -118,17 +118,17 @@ uvm_grow(struct proc *p, vaddr_t sp)
/* For common case of already allocated (from trap). */
#ifdef MACHINE_STACK_GROWS_UP
- if (sp < USRSTACK + ptoa(vm->vm_ssize))
+ if (sp < (vaddr_t)vm->vm_maxsaddr + ptoa(vm->vm_ssize))
#else
- if (sp >= USRSTACK - ptoa(vm->vm_ssize))
+ if (sp >= (vaddr_t)vm->vm_minsaddr - ptoa(vm->vm_ssize))
#endif
return;
/* Really need to check vs limit and increment stack size if ok. */
#ifdef MACHINE_STACK_GROWS_UP
- si = atop(sp - USRSTACK) - vm->vm_ssize + 1;
+ si = atop(sp - (vaddr_t)vm->vm_maxsaddr) - vm->vm_ssize + 1;
#else
- si = atop(USRSTACK - sp) - vm->vm_ssize;
+ si = atop((vaddr_t)vm->vm_minsaddr - sp) - vm->vm_ssize;
#endif
if (vm->vm_ssize + si <= atop(p->p_rlimit[RLIMIT_STACK].rlim_cur))
vm->vm_ssize += si;
@@ -179,8 +179,10 @@ uvm_coredump(struct proc *p, struct vnode *vp, struct ucred *cred,
end = VM_MAXUSER_ADDRESS;
#ifdef MACHINE_STACK_GROWS_UP
- if (USRSTACK <= start && start < (USRSTACK + MAXSSIZ)) {
- top = round_page(USRSTACK + ptoa(vm->vm_ssize));
+ if ((vaddr_t)vm->vm_maxsaddr <= start &&
+ start < ((vaddr_t)vm->vm_maxsaddr + MAXSSIZ)) {
+ top = round_page((vaddr_t)vm->vm_maxsaddr +
+ ptoa(vm->vm_ssize));
if (end > top)
end = top;
@@ -188,7 +190,8 @@ uvm_coredump(struct proc *p, struct vnode *vp, struct ucred *cred,
continue;
#else
if (start >= (vaddr_t)vm->vm_maxsaddr) {
- top = trunc_page(USRSTACK - ptoa(vm->vm_ssize));
+ top = trunc_page((vaddr_t)vm->vm_minsaddr -
+ ptoa(vm->vm_ssize));
if (start < top)
start = top;
@@ -289,9 +292,10 @@ uvm_coredump_walkmap(struct proc *p, void *iocookie,
state.end = VM_MAXUSER_ADDRESS;
#ifdef MACHINE_STACK_GROWS_UP
- if (USRSTACK <= state.start &&
- state.start < (USRSTACK + MAXSSIZ)) {
- top = round_page(USRSTACK + ptoa(vm->vm_ssize));
+ if ((vaddr_t)vm->vm_maxsaddr <= state.start &&
+ state.start < ((vaddr_t)vm->vm_maxsaddr + MAXSSIZ)) {
+ top = round_page((vaddr_t)vm->vm_maxsaddr +
+ ptoa(vm->vm_ssize));
if (state.end > top)
state.end = top;
@@ -299,7 +303,8 @@ uvm_coredump_walkmap(struct proc *p, void *iocookie,
continue;
#else
if (state.start >= (vaddr_t)vm->vm_maxsaddr) {
- top = trunc_page(USRSTACK - ptoa(vm->vm_ssize));
+ top = trunc_page((vaddr_t)vm->vm_minsaddr -
+ ptoa(vm->vm_ssize));
if (state.start < top)
state.start = top;