Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern execve_runproc: The stack address passed to the new...



details:   https://anonhg.NetBSD.org/src/rev/b730adc3f663
branches:  trunk
changeset: 328649:b730adc3f663
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Fri Apr 11 17:28:24 2014 +0000

description:
execve_runproc: The stack address passed to the newly execve()'ed process,
via the 3rd register argument, always points to the stack base address (==
minsaddr (min stack address) + ssize (stack size)).  Clarify that.

diffstat:

 sys/kern/kern_exec.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (64 lines):

diff -r 5de363a931f8 -r b730adc3f663 sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c      Fri Apr 11 17:06:02 2014 +0000
+++ b/sys/kern/kern_exec.c      Fri Apr 11 17:28:24 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exec.c,v 1.383 2014/04/11 17:06:02 uebayasi Exp $ */
+/*     $NetBSD: kern_exec.c,v 1.384 2014/04/11 17:28:24 uebayasi Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.383 2014/04/11 17:06:02 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.384 2014/04/11 17:28:24 uebayasi Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -909,7 +909,6 @@
        struct exec_package     * const epp = &data->ed_pack;
        int error = 0;
        struct proc             *p;
-       char                    *stack;
        struct vmspace          *vm;
 
        /*
@@ -1116,6 +1115,9 @@
        }
     }
 
+    {
+       char                    *stack;
+
        stack = (char *)STACK_ALLOC(STACK_GROW(vm->vm_minsaddr,
                STACK_PTHREADSPACE + data->ed_ps_strings_sz + data->ed_szsigcode),
                epp->ep_ssize - (data->ed_ps_strings_sz + data->ed_szsigcode));
@@ -1158,8 +1160,7 @@
                DPRINTF(("%s: copyargs failed %d\n", __func__, error));
                goto exec_abort;
        }
-       /* Move the stack back to original point */
-       stack = (char *)STACK_GROW(vm->vm_minsaddr, epp->ep_ssize);
+    }
 
        /* fill process ps_strings info */
        p->p_psstrp = (vaddr_t)STACK_ALLOC(STACK_GROW(vm->vm_minsaddr,
@@ -1324,12 +1325,17 @@
 
        doexechooks(p);
 
+    {
+       char * const stack = (char *)STACK_GROW(
+           (void *)epp->ep_minsaddr, epp->ep_ssize);
+
        /* setup new registers and do misc. setup. */
        (*epp->ep_esch->es_emul->e_setregs)(l, epp,
             (vaddr_t)stack);
        if (epp->ep_esch->es_setregs)
                (*epp->ep_esch->es_setregs)(l, epp,
                    (vaddr_t)stack);
+    }
 
        /* Provide a consistent LWP private setting */
        (void)lwp_setprivate(l, NULL);



Home | Main Index | Thread Index | Old Index