PERFORCE change 134241 for review
Robert Watson
rwatson at FreeBSD.org
Sun Jan 27 13:03:45 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=134241
Change 134241 by rwatson at 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));
More information about the p4-projects
mailing list