diff options
author | rwatson <rwatson@FreeBSD.org> | 2002-11-05 01:59:56 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2002-11-05 01:59:56 +0000 |
commit | e05e16efa1b6fdbeab87f3c35f6dd106ed1789c9 (patch) | |
tree | ae3d42ca3a43dfe5238a6503057532919bbbc2a3 | |
parent | b2a246fa7430c692dccca295c0c132324c419662 (diff) | |
download | FreeBSD-src-e05e16efa1b6fdbeab87f3c35f6dd106ed1789c9.zip FreeBSD-src-e05e16efa1b6fdbeab87f3c35f6dd106ed1789c9.tar.gz |
Remove reference to struct execve_args from struct imgact, which
describes an image activation instance. Instead, make use of the
existing fname structure entry, and introduce two new entries,
userspace_argv, and userspace_envv. With the addition of
mac_execve(), this divorces the image structure from the specifics
of the execve() system call, removes a redundant pointer, etc.
No semantic change from current behavior, but it means that the
structure doesn't depend on syscalls.master-generated includes.
There seems to be some redundant initialization of imgact entries,
which I have maintained, but which could probably use some cleaning
up at some point.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
-rw-r--r-- | sys/compat/pecoff/imgact_pecoff.c | 3 | ||||
-rw-r--r-- | sys/kern/imgact_elf.c | 3 | ||||
-rw-r--r-- | sys/kern/imgact_shell.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_exec.c | 56 | ||||
-rw-r--r-- | sys/sys/imgact.h | 3 |
5 files changed, 46 insertions, 21 deletions
diff --git a/sys/compat/pecoff/imgact_pecoff.c b/sys/compat/pecoff/imgact_pecoff.c index 1d70189..bf05ca8 100644 --- a/sys/compat/pecoff/imgact_pecoff.c +++ b/sys/compat/pecoff/imgact_pecoff.c @@ -363,7 +363,8 @@ pecoff_load_file(struct thread * td, const char *file, u_long * addr, u_long * e * Initialize part of the common data */ imgp->proc = td->td_proc; - imgp->uap = NULL; + imgp->userspace_argv = NULL; + imgp->userspace_envv = NULL; imgp->attr = &attr; imgp->firstpage = NULL; diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 6f42df6..ff15a46 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -514,7 +514,8 @@ __elfN(load_file)(struct proc *p, const char *file, u_long *addr, * Initialize part of the common data */ imgp->proc = p; - imgp->uap = NULL; + imgp->userspace_argv = NULL; + imgp->userspace_envv = NULL; imgp->attr = attr; imgp->firstpage = NULL; imgp->image_header = (char *)kmem_alloc_wait(exec_map, PAGE_SIZE); diff --git a/sys/kern/imgact_shell.c b/sys/kern/imgact_shell.c index 8480fcc..3df4890 100644 --- a/sys/kern/imgact_shell.c +++ b/sys/kern/imgact_shell.c @@ -120,7 +120,7 @@ exec_shell_imgact(imgp) } } - imgp->argv0 = imgp->uap->fname; + imgp->argv0 = imgp->fname; return(0); } diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 0e5c94c..3afbd24 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -76,6 +76,8 @@ static MALLOC_DEFINE(M_ATEXEC, "atexec", "atexec callback"); static int sysctl_kern_ps_strings(SYSCTL_HANDLER_ARGS); static int sysctl_kern_usrstack(SYSCTL_HANDLER_ARGS); +static int kern_execve(struct thread *td, char *fname, char **argv, + char **envv); /* * callout list for things to do at exec time @@ -135,23 +137,18 @@ sysctl_kern_usrstack(SYSCTL_HANDLER_ARGS) */ static const struct execsw **execsw; -#ifndef _SYS_SYSPROTO_H_ -struct execve_args { - char *fname; - char **argv; - char **envv; -}; -#endif - /* - * execve() system call. + * In-kernel implementation of execve(). All arguments are assumed to be + * userspace pointers from the passed thread. * * MPSAFE */ -int -execve(td, uap) +static int +kern_execve(td, fname, argv, envv) struct thread *td; - register struct execve_args *uap; + char *fname; + char **argv; + char **envv; { struct proc *p = td->td_proc; struct nameidata nd, *ndp; @@ -203,7 +200,8 @@ execve(td, uap) * Initialize part of the common data */ imgp->proc = p; - imgp->uap = uap; + imgp->userspace_argv = argv; + imgp->userspace_envv = envv; imgp->attr = &attr; imgp->argc = imgp->envc = 0; imgp->argv0 = NULL; @@ -239,7 +237,7 @@ execve(td, uap) */ ndp = &nd; NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, - UIO_USERSPACE, uap->fname, td); + UIO_USERSPACE, fname, td); mtx_lock(&Giant); interpret: @@ -252,7 +250,7 @@ interpret: } imgp->vp = ndp->ni_vp; - imgp->fname = uap->fname; + imgp->fname = fname; /* * Check file permissions (also 'opens' file) @@ -624,6 +622,30 @@ done2: return (error); } +#ifndef _SYS_SYSPROTO_H_ +struct execve_args { + char *fname; + char **argv; + char **envv; +}; +#endif + +/* + * MPSAFE + */ +int +execve(td, uap) + struct thread *td; + struct execve_args /* { + syscallarg(char *) fname; + syscallarg(char **) argv; + syscallarg(char **) envv; + } */ *uap; +{ + + return (kern_execve(td, uap->fname, uap->argv, uap->envv)); +} + int exec_map_first_page(imgp) struct image_params *imgp; @@ -799,7 +821,7 @@ exec_extract_strings(imgp) * extract arguments first */ - argv = imgp->uap->argv; + argv = imgp->userspace_argv; if (argv) { argp = (caddr_t)(intptr_t)fuword(argv); @@ -832,7 +854,7 @@ exec_extract_strings(imgp) * extract environment strings */ - envv = imgp->uap->envv; + envv = imgp->userspace_envv; if (envv) { while ((envp = (caddr_t)(intptr_t)fuword(envv++))) { diff --git a/sys/sys/imgact.h b/sys/sys/imgact.h index d2ea2cd..16b6e74 100644 --- a/sys/sys/imgact.h +++ b/sys/sys/imgact.h @@ -44,7 +44,8 @@ struct vm_object; struct image_params { struct proc *proc; /* our process struct */ - struct execve_args *uap; /* syscall arguments */ + char **userspace_argv; /* system call argument */ + char **userspace_envv; /* system call argument */ struct vnode *vp; /* pointer to vnode of file to exec */ struct vm_object *object; /* The vm object for this vp */ struct vattr *attr; /* attributes of file */ |