⬢ DragonFlyBSD Kernel Audit
DF-3164 / fix.diff
← back to finding ↓ download raw
--- a/sys/vfs/udf/udf_vfsops.c
+++ b/sys/vfs/udf/udf_vfsops.c
@@ -154,6 +154,11 @@
 		imp = VFSTOUDFFS(mp);
 		if (args.fspec == NULL)
 			return(vfs_export(mp, &imp->im_export, &args.export));
+		/*
+		 * Replacing the backing device of a live mount is not
+		 * supported; udf_mountfs would clobber mp->mnt_data.
+		 */
+		return (EOPNOTSUPP);
 	}
 
 	/* Check that the mount device exists */
@@ -240,6 +245,7 @@
 	int error = EINVAL, needclose = 0;
 	int logvol_found = 0, part_found = 0, fsd_found = 0;
 	int bsize;
+	qaddr_t omnt_data = mp->mnt_data;
 
 	/*
 	 * Disallow multiple mounts of the same device. Flush the buffer
@@ -391,6 +397,11 @@
 	return(0);
 
 bail:
+	/*
+	 * Never leave a dangling mnt_data behind: on a failed
+	 * MNT_UPDATE the mount pointed to by mp stays alive.
+	 */
+	mp->mnt_data = omnt_data;
 	if (udfmp != NULL)
 		kfree(udfmp, M_UDFMOUNT);
 	if (bp != NULL)