Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 Sync auxv vector generation with exec_el...



details:   https://anonhg.NetBSD.org/src/rev/222a83320bc2
branches:  trunk
changeset: 999538:222a83320bc2
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jun 07 20:13:54 2019 +0000

description:
Sync auxv vector generation with exec_elf.c. Fixes $ORIGIN on compat_netbsd32.
Found by zerous as part of GSoC

diffstat:

 sys/compat/netbsd32/netbsd32_exec_elf32.c |  31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)

diffs (68 lines):

diff -r 07c2b6991b85 -r 222a83320bc2 sys/compat/netbsd32/netbsd32_exec_elf32.c
--- a/sys/compat/netbsd32/netbsd32_exec_elf32.c Fri Jun 07 19:05:15 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32_exec_elf32.c Fri Jun 07 20:13:54 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_exec_elf32.c,v 1.43 2019/03/01 11:06:56 pgoyette Exp $        */
+/*     $NetBSD: netbsd32_exec_elf32.c,v 1.44 2019/06/07 20:13:54 christos Exp $        */
 /*     from: NetBSD: exec_aout.c,v 1.15 1996/09/26 23:34:46 cgd Exp */
 
 /*
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_exec_elf32.c,v 1.43 2019/03/01 11:06:56 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_exec_elf32.c,v 1.44 2019/06/07 20:13:54 christos Exp $");
 
 #define        ELFSIZE         32
 
@@ -134,8 +134,8 @@
 netbsd32_elf32_copyargs(struct lwp *l, struct exec_package *pack,
     struct ps_strings *arginfo, char **stackp, void *argp)
 {
-       size_t len;
-       AuxInfo ai[ELF_AUX_ENTRIES], *a;
+       size_t len, vlen;
+       AuxInfo ai[ELF_AUX_ENTRIES], *a, *execname;
        struct elf_args *ap;
        int error;
 
@@ -200,17 +200,36 @@
                a->a_v = l->l_proc->p_stackbase;
                a++;
 
+               execname = a;
+               a->a_type = AT_SUN_EXECNAME;
+               a++;
+
                exec_free_emul_arg(pack);
+       } else {
+               execname = NULL;
        }
 
        a->a_type = AT_NULL;
        a->a_v = 0;
        a++;
 
-       len = (a - ai) * sizeof(AuxInfo);
+       vlen = (a - ai) * sizeof(ai[0]);
+
+       KASSERT(vlen <= sizeof(ai));
+
+       if (execname) {
+               char *path = l->l_proc->p_path;
+               execname->a_v = (uintptr_t)(*stackp + vlen);
+               len = strlen(path) + 1;
+               if ((error = copyout(path, (*stackp + vlen), len)) != 0)
+                       return error;
+               len = ALIGN(len);
+       } else {
+               len = 0;
+       }
        if ((error = copyout(ai, *stackp, len)) != 0)
                return error;
-       *stackp += len;
+       *stackp += vlen + len;
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index