summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-02-06 22:06:54 +0000
committerjhb <jhb@FreeBSD.org>2006-02-06 22:06:54 +0000
commitae432f93f28bc2a60c708a33b77ad08e34501984 (patch)
treee021a567f29f575137e73762ca951faf54b3cfd1 /sys
parent1f0c541bd133ce3b047f18de07fa40324097bfad (diff)
downloadFreeBSD-src-ae432f93f28bc2a60c708a33b77ad08e34501984.zip
FreeBSD-src-ae432f93f28bc2a60c708a33b77ad08e34501984.tar.gz
- Always call exec_free_args() in kern_execve() instead of doing it in all
the callers if the exec either succeeds or fails early. - Move the code to call exit1() if the exec fails after the vmspace is gone to the bottom of kern_execve() to cut down on some code duplication.
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/linux/linux_machdep.c1
-rw-r--r--sys/alpha/osf1/osf1_misc.c1
-rw-r--r--sys/amd64/linux32/linux32_machdep.c1
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c1
-rw-r--r--sys/compat/svr4/svr4_misc.c2
-rw-r--r--sys/i386/ibcs2/ibcs2_misc.c2
-rw-r--r--sys/i386/linux/linux_machdep.c1
-rw-r--r--sys/kern/kern_exec.c31
-rw-r--r--sys/kern/kern_kse.c1
-rw-r--r--sys/sys/imgact.h1
10 files changed, 9 insertions, 33 deletions
diff --git a/sys/alpha/linux/linux_machdep.c b/sys/alpha/linux/linux_machdep.c
index b4cebb0..7f468f6 100644
--- a/sys/alpha/linux/linux_machdep.c
+++ b/sys/alpha/linux/linux_machdep.c
@@ -81,7 +81,6 @@ linux_execve(struct thread *td, struct linux_execve_args *args)
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
- exec_free_args(&eargs);
return (error);
}
diff --git a/sys/alpha/osf1/osf1_misc.c b/sys/alpha/osf1/osf1_misc.c
index 63ce5ee..13a5ca7 100644
--- a/sys/alpha/osf1/osf1_misc.c
+++ b/sys/alpha/osf1/osf1_misc.c
@@ -1246,7 +1246,6 @@ osf1_execve(td, uap)
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
- exec_free_args(&eargs);
return (error);
}
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c
index 7f738bb..2163bc2 100644
--- a/sys/amd64/linux32/linux32_machdep.c
+++ b/sys/amd64/linux32/linux32_machdep.c
@@ -205,7 +205,6 @@ linux_execve(struct thread *td, struct linux_execve_args *args)
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
- exec_free_args(&eargs);
return (error);
}
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index f2acf1a..4c00a20 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -324,7 +324,6 @@ freebsd32_execve(struct thread *td, struct freebsd32_execve_args *uap)
uap->argv, uap->envv);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
- exec_free_args(&eargs);
return (error);
}
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index 7fae260..5a585cf 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -175,7 +175,6 @@ svr4_sys_execv(td, uap)
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
- exec_free_args(&eargs);
return (error);
}
@@ -195,7 +194,6 @@ svr4_sys_execve(td, uap)
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
- exec_free_args(&eargs);
return (error);
}
diff --git a/sys/i386/ibcs2/ibcs2_misc.c b/sys/i386/ibcs2/ibcs2_misc.c
index e5ecace..c4efc02 100644
--- a/sys/i386/ibcs2/ibcs2_misc.c
+++ b/sys/i386/ibcs2/ibcs2_misc.c
@@ -207,7 +207,6 @@ ibcs2_execv(td, uap)
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
- exec_free_args(&eargs);
return (error);
}
@@ -227,7 +226,6 @@ ibcs2_execve(td, uap)
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
- exec_free_args(&eargs);
return (error);
}
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index 5aea62a..68e7039 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -122,7 +122,6 @@ linux_execve(struct thread *td, struct linux_execve_args *args)
free(newpath, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
- exec_free_args(&eargs);
return (error);
}
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index f55e196..c2392ff 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -86,6 +86,7 @@ static int sysctl_kern_usrstack(SYSCTL_HANDLER_ARGS);
static int sysctl_kern_stackprot(SYSCTL_HANDLER_ARGS);
static int do_execve(struct thread *td, struct image_args *args,
struct mac *mac_p);
+static void exec_free_args(struct image_args *);
/* XXX This should be vm_size_t. */
SYSCTL_PROC(_kern, KERN_PS_STRINGS, ps_strings, CTLTYPE_ULONG|CTLFLAG_RD,
@@ -181,12 +182,8 @@ execve(td, uap)
error = exec_copyin_args(&args, uap->fname, UIO_USERSPACE,
uap->argv, uap->envv);
-
if (error == 0)
error = kern_execve(td, &args, NULL);
-
- exec_free_args(&args);
-
return (error);
}
@@ -218,12 +215,8 @@ __mac_execve(td, uap)
error = exec_copyin_args(&args, uap->fname, UIO_USERSPACE,
uap->argv, uap->envv);
-
if (error == 0)
error = kern_execve(td, &args, uap->mac_p);
-
- exec_free_args(&args);
-
return (error);
#else
return (ENOSYS);
@@ -776,19 +769,6 @@ exec_fail:
p->p_flag &= ~P_INEXEC;
PROC_UNLOCK(p);
- if (imgp->vmspace_destroyed) {
- /* sorry, no more process anymore. exit gracefully */
-#ifdef MAC
- mac_execve_exit(imgp);
- if (interplabel != NULL)
- mac_vnode_label_free(interplabel);
-#endif
- VFS_UNLOCK_GIANT(vfslocked);
- exec_free_args(args);
- exit1(td, W_EXITCODE(0, SIGABRT));
- /* NOT REACHED */
- error = 0;
- }
done2:
#ifdef MAC
mac_execve_exit(imgp);
@@ -796,6 +776,13 @@ done2:
mac_vnode_label_free(interplabel);
#endif
VFS_UNLOCK_GIANT(vfslocked);
+ exec_free_args(args);
+
+ if (error && imgp->vmspace_destroyed) {
+ /* sorry, no more process anymore. exit gracefully */
+ exit1(td, W_EXITCODE(0, SIGABRT));
+ /* NOT REACHED */
+ }
return (error);
}
@@ -1036,7 +1023,7 @@ exec_copyin_args(struct image_args *args, char *fname,
return (0);
}
-void
+static void
exec_free_args(struct image_args *args)
{
diff --git a/sys/kern/kern_kse.c b/sys/kern/kern_kse.c
index 15c0f18..7618043 100644
--- a/sys/kern/kern_kse.c
+++ b/sys/kern/kern_kse.c
@@ -266,7 +266,6 @@ kse_thr_interrupt(struct thread *td, struct kse_thr_interrupt_args *uap)
args.argv, args.envp);
if (error == 0)
error = kern_execve(td, &iargs, NULL);
- exec_free_args(&iargs);
if (error == 0) {
PROC_LOCK(p);
SIGSETOR(td->td_siglist, args.sigpend);
diff --git a/sys/sys/imgact.h b/sys/sys/imgact.h
index b1d0f0d..20c65e9 100644
--- a/sys/sys/imgact.h
+++ b/sys/sys/imgact.h
@@ -76,7 +76,6 @@ void exec_setregs(struct thread *, u_long, u_long, u_long);
int exec_shell_imgact(struct image_params *);
int exec_copyin_args(struct image_args *, char *, enum uio_seg,
char **, char **);
-void exec_free_args(struct image_args *);
#endif
#endif /* !_SYS_IMGACT_H_ */
OpenPOWER on IntegriCloud