From owner-p4-projects Sun Nov 3 17: 2:33 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6A6ED37B404; Sun, 3 Nov 2002 17:02:27 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ECD4B37B401 for ; Sun, 3 Nov 2002 17:02:26 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F72643E4A for ; Sun, 3 Nov 2002 17:02:26 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id gA410mmV018880 for ; Sun, 3 Nov 2002 17:00:48 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id gA410m2j018877 for perforce@freebsd.org; Sun, 3 Nov 2002 17:00:48 -0800 (PST) Date: Sun, 3 Nov 2002 17:00:48 -0800 (PST) Message-Id: <200211040100.gA410m2j018877@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson Subject: PERFORCE change 20616 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://perforce.freebsd.org/chv.cgi?CH=20616 Change 20616 by rwatson@rwatson_tislabs on 2002/11/03 17:00:36 Break out the imgp->uap argument to make it system-call independent. Implement execve via kern_execve() and wrap both __execve_mac() and execve() around it, rather than making execve() a wrapper around __execve_mac(), following the model used in the main tree for other system calls. No semantic change, otherwise. Affected files ... .. //depot/projects/trustedbsd/mac/sys/compat/pecoff/imgact_pecoff.c#15 edit .. //depot/projects/trustedbsd/mac/sys/kern/imgact_elf.c#18 edit .. //depot/projects/trustedbsd/mac/sys/kern/imgact_shell.c#5 edit .. //depot/projects/trustedbsd/mac/sys/kern/kern_exec.c#41 edit .. //depot/projects/trustedbsd/mac/sys/sys/imgact.h#14 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/compat/pecoff/imgact_pecoff.c#15 (text+ko) ==== @@ -363,7 +363,10 @@ * Initialize part of the common data */ imgp->proc = td->td_proc; - imgp->uap = NULL; + imgp->userspace_fname = NULL; + imgp->userspace_argv = NULL; + imgp->userspace_envv = NULL; + imgp->userspace_mac_p = NULL; imgp->attr = &attr; imgp->firstpage = NULL; ==== //depot/projects/trustedbsd/mac/sys/kern/imgact_elf.c#18 (text+ko) ==== @@ -514,7 +514,10 @@ * Initialize part of the common data */ imgp->proc = p; - imgp->uap = NULL; + imgp->userspace_fname = NULL; + imgp->userspace_argv = NULL; + imgp->userspace_envv = NULL; + imgp->userspace_mac_p = NULL; imgp->attr = attr; imgp->firstpage = NULL; imgp->image_header = (char *)kmem_alloc_wait(exec_map, PAGE_SIZE); ==== //depot/projects/trustedbsd/mac/sys/kern/imgact_shell.c#5 (text+ko) ==== @@ -120,7 +120,7 @@ } } - imgp->argv0 = imgp->uap->fname; + imgp->argv0 = imgp->userspace_fname; return(0); } ==== //depot/projects/trustedbsd/mac/sys/kern/kern_exec.c#41 (text+ko) ==== @@ -76,6 +76,9 @@ 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, struct mac *mac_p); + /* * callout list for things to do at exec time @@ -135,24 +138,19 @@ */ static const struct execsw **execsw; -#ifndef _SYS_SYSPROTO_H_ -struct __execve_mac_args { - char *fname; - char **argv; - char **envv; - struct mac *mac_p; -}; -#endif - /* - * __execve_mac() system call. + * In-kernel implementation of execve(). All arguments are assumed to + * be userspace pointers from the passed thread. * * MPSAFE */ -int -__execve_mac(td, uap) +static int +kern_execve(td, fname, argv, envv, mac_p) struct thread *td; - register struct __execve_mac_args *uap; + char *fname; + char **argv; + char **envv; + struct mac *mac_p; { struct proc *p = td->td_proc; struct nameidata nd, *ndp; @@ -209,7 +207,10 @@ * Initialize part of the common data */ imgp->proc = p; - imgp->uap = uap; + imgp->userspace_fname = fname; + imgp->userspace_argv = argv; + imgp->userspace_envv = envv; + imgp->userspace_mac_p = mac_p; imgp->execlabel = NULL; imgp->attr = &attr; imgp->argc = imgp->envc = 0; @@ -226,7 +227,7 @@ imgp->auxarg_size = 0; #ifdef MAC - error = mac_execve_enter(imgp, uap->mac_p, &execlabel); + error = mac_execve_enter(imgp, mac_p, &execlabel); if (error) { mtx_lock(&Giant); goto exec_fail; @@ -254,7 +255,7 @@ */ ndp = &nd; NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME | SAVESTART, - UIO_USERSPACE, uap->fname, td); + UIO_USERSPACE, fname, td); mtx_lock(&Giant); interpret: @@ -267,7 +268,7 @@ } imgp->vp = ndp->ni_vp; - imgp->fname = uap->fname; + imgp->fname = fname; /* * Check file permissions (also 'opens' file, caches various @@ -684,9 +685,6 @@ } /* - * execve() system call. This is simply a wrapper for __execve_mac - * which passes in a NULL label argument. - * * MPSAFE */ int @@ -698,13 +696,26 @@ syscallarg(char **) envv; } */ *uap; { - struct __execve_mac_args mac_args; + + return (kern_execve(td, uap->fname, uap->argv, uap->envv, NULL)); +} + +/* + * MPSAFE + */ +int +__execve_mac(td, uap) + struct thread *td; + struct __execve_mac_args /* { + syscallarg(char *) fname; + syscallarg(char **) argv; + syscallarg(char **) envv; + syscallarg(struct mac *) mac_p; + } */ *uap; +{ - mac_args.fname = uap->fname; - mac_args.argv = uap->argv; - mac_args.envv = uap->envv; - mac_args.mac_p = NULL; - return (__execve_mac(td, &mac_args)); + return (kern_execve(td, uap->fname, uap->argv, uap->envv, + uap->mac_p)); } int @@ -882,7 +893,7 @@ * extract arguments first */ - argv = imgp->uap->argv; + argv = imgp->userspace_argv; if (argv) { argp = (caddr_t)(intptr_t)fuword(argv); @@ -915,7 +926,7 @@ * extract environment strings */ - envv = imgp->uap->envv; + envv = imgp->userspace_envv; if (envv) { while ((envp = (caddr_t)(intptr_t)fuword(envv++))) { ==== //depot/projects/trustedbsd/mac/sys/sys/imgact.h#14 (text+ko) ==== @@ -45,7 +45,10 @@ struct image_params { struct proc *proc; /* our process struct */ - struct __execve_mac_args *uap; /* syscall arguments */ + char *userspace_fname; /* system call argument */ + char **userspace_argv; /* system call argument */ + char **userspace_envv; /* system call argument */ + struct mac *userspace_mac_p; /* system call argument */ struct label *execlabel; /* MAC label to compose transition with */ struct vnode *vp; /* pointer to vnode of file to exec */ struct vm_object *object; /* The vm object for this vp */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message