audit: rely on use count instead of hold count in audit_canon_path
This commit is contained in:
parent
3cd1f28e4a
commit
a1197bde68
@ -443,7 +443,7 @@ audit_canon_path(struct thread *td, int dirfd, char *path, char *cpath)
|
|||||||
*/
|
*/
|
||||||
if (fdp->fd_rdir != NULL && fdp->fd_rdir != rootvnode) {
|
if (fdp->fd_rdir != NULL && fdp->fd_rdir != rootvnode) {
|
||||||
rvnp = fdp->fd_rdir;
|
rvnp = fdp->fd_rdir;
|
||||||
vhold(rvnp);
|
vrefact(rvnp);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* If the supplied path is relative, make sure we capture the current
|
* If the supplied path is relative, make sure we capture the current
|
||||||
@ -453,19 +453,16 @@ audit_canon_path(struct thread *td, int dirfd, char *path, char *cpath)
|
|||||||
if (*path != '/') {
|
if (*path != '/') {
|
||||||
if (dirfd == AT_FDCWD) {
|
if (dirfd == AT_FDCWD) {
|
||||||
cvnp = fdp->fd_cdir;
|
cvnp = fdp->fd_cdir;
|
||||||
vhold(cvnp);
|
vrefact(cvnp);
|
||||||
} else {
|
} else {
|
||||||
/* XXX: fgetvp() that vhold()s vnode instead of vref()ing it would be better */
|
|
||||||
error = fgetvp(td, dirfd, cap_rights_init(&rights), &cvnp);
|
error = fgetvp(td, dirfd, cap_rights_init(&rights), &cvnp);
|
||||||
if (error) {
|
if (error) {
|
||||||
FILEDESC_SUNLOCK(fdp);
|
FILEDESC_SUNLOCK(fdp);
|
||||||
cpath[0] = '\0';
|
cpath[0] = '\0';
|
||||||
if (rvnp != NULL)
|
if (rvnp != NULL)
|
||||||
vdrop(rvnp);
|
vrele(rvnp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vhold(cvnp);
|
|
||||||
vrele(cvnp);
|
|
||||||
}
|
}
|
||||||
needslash = (fdp->fd_rdir != cvnp);
|
needslash = (fdp->fd_rdir != cvnp);
|
||||||
} else {
|
} else {
|
||||||
@ -492,11 +489,11 @@ audit_canon_path(struct thread *td, int dirfd, char *path, char *cpath)
|
|||||||
*/
|
*/
|
||||||
if (rvnp != NULL) {
|
if (rvnp != NULL) {
|
||||||
error = vn_fullpath_global(td, rvnp, &rbuf, &fbuf);
|
error = vn_fullpath_global(td, rvnp, &rbuf, &fbuf);
|
||||||
vdrop(rvnp);
|
vrele(rvnp);
|
||||||
if (error) {
|
if (error) {
|
||||||
cpath[0] = '\0';
|
cpath[0] = '\0';
|
||||||
if (cvnp != NULL)
|
if (cvnp != NULL)
|
||||||
vdrop(cvnp);
|
vrele(cvnp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(void) sbuf_cat(&sbf, rbuf);
|
(void) sbuf_cat(&sbf, rbuf);
|
||||||
@ -504,7 +501,7 @@ audit_canon_path(struct thread *td, int dirfd, char *path, char *cpath)
|
|||||||
}
|
}
|
||||||
if (cvnp != NULL) {
|
if (cvnp != NULL) {
|
||||||
error = vn_fullpath(td, cvnp, &rbuf, &fbuf);
|
error = vn_fullpath(td, cvnp, &rbuf, &fbuf);
|
||||||
vdrop(cvnp);
|
vrele(cvnp);
|
||||||
if (error) {
|
if (error) {
|
||||||
cpath[0] = '\0';
|
cpath[0] = '\0';
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user