Fix a small race condition in sys_linux_ustat() related to accessing
a vnode which can get ripped out from under the procedure.
# Install the system from the live CD
#
cpdup -o / /mnt
+cpdup -o /boot /mnt/boot
+cpdup -o /usr /mnt/usr
cpdup -o /var /mnt/var
cpdup -o /dev /mnt/dev
cpdup -i0 /etc.hdd /mnt/etc
dev = udev2dev(makeudev(args->dev >> 8, args->dev & 0xFF), 0);
if (dev != NULL && vfinddev(dev, VCHR, &vp)) {
if (vp->v_mount == NULL) {
+ vrele(vp);
return (EINVAL);
}
stat = &(vp->v_mount->mnt_stat);
error = VFS_STATFS(vp->v_mount, stat, curproc->p_ucred);
+ vrele(vp);
if (error) {
return (error);
}
/*
* Lookup a vnode by device number.
+ *
+ * Returns non-zero and *vpp set to a vref'd vnode on success.
+ * Returns zero on failure.
*/
int
vfinddev(cdev_t dev, enum vtype type, struct vnode **vpp)
SLIST_FOREACH(vp, &dev->si_hlist, v_cdevnext) {
if (type == vp->v_type) {
*vpp = vp;
+ vref(vp);
lwkt_reltoken(&ilock);
return (1);
}