mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-13 10:02:38 +00:00
Fix some bugs in the previous revision (1.419). Don't perform extra
vfs_rel() on the mountpoint if the MAC checks fail in kern_statfs() and kern_fstatfs(). Similarly, don't perform an extra vfs_rel() if we get a doomed vnode in kern_fstatfs(), and handle the case of mp being NULL (for some doomed vnodes) by conditionalizing the vfs_rel() in kern_fstatfs() on mp != NULL. CID: 1517 Found by: Coverity Prevent (tm) (kern_fstatfs()) Pointy hat to: jhb
This commit is contained in:
parent
dad9051355
commit
9802d04ce0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=160924
@ -253,10 +253,8 @@ kern_statfs(struct thread *td, char *path, enum uio_seg pathseg,
|
|||||||
vput(nd.ni_vp);
|
vput(nd.ni_vp);
|
||||||
#ifdef MAC
|
#ifdef MAC
|
||||||
error = mac_check_mount_stat(td->td_ucred, mp);
|
error = mac_check_mount_stat(td->td_ucred, mp);
|
||||||
if (error) {
|
if (error)
|
||||||
vfs_rel(mp);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* Set these in case the underlying filesystem fails to do so.
|
* Set these in case the underlying filesystem fails to do so.
|
||||||
@ -335,17 +333,13 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf)
|
|||||||
VOP_UNLOCK(vp, 0, td);
|
VOP_UNLOCK(vp, 0, td);
|
||||||
fdrop(fp, td);
|
fdrop(fp, td);
|
||||||
if (vp->v_iflag & VI_DOOMED) {
|
if (vp->v_iflag & VI_DOOMED) {
|
||||||
if (mp)
|
|
||||||
vfs_rel(mp);
|
|
||||||
error = EBADF;
|
error = EBADF;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#ifdef MAC
|
#ifdef MAC
|
||||||
error = mac_check_mount_stat(td->td_ucred, mp);
|
error = mac_check_mount_stat(td->td_ucred, mp);
|
||||||
if (error) {
|
if (error)
|
||||||
vfs_rel(mp);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* Set these in case the underlying filesystem fails to do so.
|
* Set these in case the underlying filesystem fails to do so.
|
||||||
@ -365,7 +359,8 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf)
|
|||||||
}
|
}
|
||||||
*buf = *sp;
|
*buf = *sp;
|
||||||
out:
|
out:
|
||||||
vfs_rel(mp);
|
if (mp)
|
||||||
|
vfs_rel(mp);
|
||||||
VFS_UNLOCK_GIANT(vfslocked);
|
VFS_UNLOCK_GIANT(vfslocked);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
@ -253,10 +253,8 @@ kern_statfs(struct thread *td, char *path, enum uio_seg pathseg,
|
|||||||
vput(nd.ni_vp);
|
vput(nd.ni_vp);
|
||||||
#ifdef MAC
|
#ifdef MAC
|
||||||
error = mac_check_mount_stat(td->td_ucred, mp);
|
error = mac_check_mount_stat(td->td_ucred, mp);
|
||||||
if (error) {
|
if (error)
|
||||||
vfs_rel(mp);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* Set these in case the underlying filesystem fails to do so.
|
* Set these in case the underlying filesystem fails to do so.
|
||||||
@ -335,17 +333,13 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf)
|
|||||||
VOP_UNLOCK(vp, 0, td);
|
VOP_UNLOCK(vp, 0, td);
|
||||||
fdrop(fp, td);
|
fdrop(fp, td);
|
||||||
if (vp->v_iflag & VI_DOOMED) {
|
if (vp->v_iflag & VI_DOOMED) {
|
||||||
if (mp)
|
|
||||||
vfs_rel(mp);
|
|
||||||
error = EBADF;
|
error = EBADF;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#ifdef MAC
|
#ifdef MAC
|
||||||
error = mac_check_mount_stat(td->td_ucred, mp);
|
error = mac_check_mount_stat(td->td_ucred, mp);
|
||||||
if (error) {
|
if (error)
|
||||||
vfs_rel(mp);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* Set these in case the underlying filesystem fails to do so.
|
* Set these in case the underlying filesystem fails to do so.
|
||||||
@ -365,7 +359,8 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf)
|
|||||||
}
|
}
|
||||||
*buf = *sp;
|
*buf = *sp;
|
||||||
out:
|
out:
|
||||||
vfs_rel(mp);
|
if (mp)
|
||||||
|
vfs_rel(mp);
|
||||||
VFS_UNLOCK_GIANT(vfslocked);
|
VFS_UNLOCK_GIANT(vfslocked);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user