diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2008-02-13 19:31:23 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2008-02-13 19:31:23 +0000 |
commit | 7e96caa7cea3371986e54e0c8191ba395af885d1 (patch) | |
tree | d69cc9737119a319f814ac11e6f385ab7c5281de | |
parent | 103b03191cf7af64eff2b4fc65f6b7c6e446d7c1 (diff) |
Make sure we reserve enough stack space on MACHINE_STACK_GROWS_UP architectures
by aligning the stack gap. Fixes gettext port build (and probably many others).
ok miod@, tedu@, tested by sthen@
-rw-r--r-- | sys/kern/kern_exec.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 3fb29047c5a..801b69df0d4 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.105 2007/12/11 22:09:29 kettenis Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.106 2008/02/13 19:31:22 kettenis Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -388,6 +388,9 @@ sys_execve(struct proc *p, void *v, register_t *retval) sgap = STACKGAPLEN; if (stackgap_random != 0) sgap += (arc4random() * ALIGNBYTES) & (stackgap_random - 1); +#ifdef MACHINE_STACK_GROWS_UP + sgap = ALIGN(sgap); +#endif /* Now check if args & environ fit into new stack */ len = ((argc + envc + 2 + pack.ep_emul->e_arglen) * sizeof(char *) + sizeof(long) + dp + sgap + sizeof(struct ps_strings)) - argp; @@ -435,8 +438,8 @@ sys_execve(struct proc *p, void *v, register_t *retval) arginfo.ps_nenvstr = envc; #ifdef MACHINE_STACK_GROWS_UP - stack = (char *)USRSTACK + sizeof(arginfo) + ALIGN(sgap); - slen = len - sizeof(arginfo) - ALIGN(sgap); + stack = (char *)USRSTACK + sizeof(arginfo) + sgap; + slen = len - sizeof(arginfo) - sgap; #else stack = (char *)(USRSTACK - len); #endif |