DragonFlyBSD Kernel Audit
DF-0193 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/kern/vfs_vfsops.c b/sys/kern/vfs_vfsops.c
--- a/sys/kern/vfs_vfsops.c
+++ b/sys/kern/vfs_vfsops.c
@@ -267,10 +267,18 @@
 vfs_vptofh(struct vnode *vp, struct fid *fhp)
 {
 	VFS_MPLOCK_DECLARE;
-	int error;
-
-	VFS_MPLOCK(vp->v_mount);
-	error = (vp->v_mount->mnt_op->vfs_vptofh)(vp, fhp);
+	struct mount *mp;
+	int error;
+
+	mp = vp->v_mount;
+	if (mp == NULL)
+		return (ENOENT);
+	VFS_MPLOCK(mp);
+	if (vp->v_mount != mp) {
+		VFS_MPUNLOCK();
+		return (ENOENT);
+	}
+	error = (mp->mnt_op->vfs_vptofh)(vp, fhp);
 	VFS_MPUNLOCK();
 	return (error);
 }