Date: Sun, 27 Jan 2008 21:03:44 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 134241 for review Message-ID: <200801272103.m0RL3iOF050896@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=134241 Change 134241 by rwatson@rwatson_freebsd_capabilities on 2008/01/27 21:02:52 Use vn_fullpath(9) to generate p_comm when we first extract the vnode in fexecve(), rather than while the process lock is being held later. Affected files ... .. //depot/projects/trustedbsd/capabilities/src/sys/kern/kern_exec.c#7 edit Differences ... ==== //depot/projects/trustedbsd/capabilities/src/sys/kern/kern_exec.c#7 (text+ko) ==== @@ -319,6 +319,7 @@ int credential_changing; int vfslocked; int textset; + char pcomm[MAXCOMLEN + 1]; #ifdef MAC struct label *interplabel = NULL; int will_transition; @@ -404,6 +405,9 @@ binvp = ndp->ni_vp; imgp->vp = binvp; } else { + char *freepath = NULL; + char *fullpath = NULL; + /* XXXRW: Possibly should just be CAP_FEXECVE? */ error = fgetvp_read(td, args->fd, CAP_READ | CAP_FEXECVE, &binvp); @@ -412,6 +416,16 @@ vfslocked = VFS_LOCK_GIANT(binvp->v_mount); vn_lock(binvp, LK_EXCLUSIVE | LK_RETRY); imgp->vp = binvp; + + error = vn_fullpath(td, binvp, &fullpath, &freepath); + if (error == 0) { + strlcpy(pcomm, fullpath, sizeof(pcomm)); + if (freepath) + free(freepath, M_TEMP); + } else { + strlcpy(pcomm, "fexecve process", sizeof(pcomm)); + error = 0; + } } /* @@ -572,24 +586,11 @@ /* name this process - nameiexec(p, ndp) */ if (args->fname) { - len = min(ndp->ni_cnd.cn_namelen,MAXCOMLEN); + len = min(ndp->ni_cnd.cn_namelen, MAXCOMLEN); bcopy(ndp->ni_cnd.cn_nameptr, p->p_comm, len); } else { - char *freepath; - char *fullpath = NULL; - - error = vn_fullpath(td, binvp, &fullpath, &freepath); - if (error == 0) { - len = min(strlen(fullpath), MAXCOMLEN); - bcopy(fullpath, p->p_comm, len); - if (freepath) - free(freepath, M_TEMP); - } else { - static const char proc_title[] = "fexecved process"; - len = sizeof(proc_title); - bcopy(proc_title, p->p_comm, len); - } - error = 0; + len = strlen(pcomm); + bcopy(pcomm, p->p_comm, len); } p->p_comm[len] = 0; bcopy(p->p_comm, td->td_name, sizeof(td->td_name));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801272103.m0RL3iOF050896>