Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Don't set AT_SUN_EXECNAME if we don't have a fully ...



details:   https://anonhg.NetBSD.org/src/rev/1277787d94e4
branches:  trunk
changeset: 454389:1277787d94e4
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Sep 15 20:20:26 2019 +0000

description:
Don't set AT_SUN_EXECNAME if we don't have a fully resolved name.

diffstat:

 sys/kern/exec_elf.c |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (50 lines):

diff -r 52c8dc8e7677 -r 1277787d94e4 sys/kern/exec_elf.c
--- a/sys/kern/exec_elf.c       Sun Sep 15 19:38:08 2019 +0000
+++ b/sys/kern/exec_elf.c       Sun Sep 15 20:20:26 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec_elf.c,v 1.98 2019/06/07 23:35:52 christos Exp $   */
+/*     $NetBSD: exec_elf.c,v 1.99 2019/09/15 20:20:26 christos Exp $   */
 
 /*-
  * Copyright (c) 1994, 2000, 2005, 2015 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.98 2019/06/07 23:35:52 christos Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.99 2019/09/15 20:20:26 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -157,6 +157,7 @@
        size_t len, vlen;
        AuxInfo ai[ELF_AUX_ENTRIES], *a, *execname;
        struct elf_args *ap;
+       char *path = l->l_proc->p_path;
        int error;
 
        a = ai;
@@ -224,9 +225,12 @@
                a->a_v = l->l_proc->p_stackbase;
                a++;
 
-               execname = a;
-               a->a_type = AT_SUN_EXECNAME;
-               a++;
+               /* "/" means fexecve(2) could not resolve the pathname */
+               if (path[0] == '/' && path[1] != '\0') {
+                       execname = a;
+                       a->a_type = AT_SUN_EXECNAME;
+                       a++;
+               }
 
                exec_free_emul_arg(pack);
        } else {
@@ -242,7 +246,6 @@
        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)



Home | Main Index | Thread Index | Old Index