diff options
author | John Baldwin <jhb@FreeBSD.org> | 2006-02-06 22:06:54 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2006-02-06 22:06:54 +0000 |
commit | 8917b8d28ccb2f718e6f8929e1ec0567ef1b0428 (patch) | |
tree | e021a567f29f575137e73762ca951faf54b3cfd1 /sys/kern/kern_exec.c | |
parent | 809f984b21006f1c8df0e15ee44f871264f2c45c (diff) | |
download | src-8917b8d28ccb2f718e6f8929e1ec0567ef1b0428.tar.gz src-8917b8d28ccb2f718e6f8929e1ec0567ef1b0428.zip |
- 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.
Notes
Notes:
svn path=/head/; revision=155402
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r-- | sys/kern/kern_exec.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index f55e196439f7..c2392ffd68e7 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) { |