changeset 12645:0de9ed7d05ab

6942874 Loop in autofs/lofs mount causes stack overflow, leading to crash
author Jan Kryl <Jan.Kryl@Sun.COM>
date Fri, 18 Jun 2010 13:58:16 +0200
parents 4f9a0cd40c5f
children 6faf82030b5c
files usr/src/uts/common/fs/lofs/lofs_vfsops.c
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/fs/lofs/lofs_vfsops.c	Thu Jun 17 17:23:59 2010 -0700
+++ b/usr/src/uts/common/fs/lofs/lofs_vfsops.c	Fri Jun 18 13:58:16 2010 +0200
@@ -277,12 +277,22 @@
 	}
 
 	/*
-	 * realrootvp may be an AUTOFS node, in which case we
-	 * perform a VOP_ACCESS() to trigger the mount of the
-	 * intended filesystem, so we loopback mount the intended
-	 * filesystem instead of the AUTOFS filesystem.
+	 * realrootvp may be an AUTOFS node, in which case we perform a
+	 * VOP_ACCESS() to trigger the mount of the intended filesystem.
+	 * This causes a loopback mount of the intended filesystem instead
+	 * of the AUTOFS filesystem.
+	 *
+	 * If a lofs mount creates a mount loop (such that a lofs vfs is
+	 * mounted on an autofs node and that lofs vfs points back to the
+	 * autofs node which it is mounted on) then a VOP_ACCESS call will
+	 * create a deadlock. Once this deadlock is released, VOP_ACCESS will
+	 * return EINTR. In such a case we don't want the lofs vfs to be
+	 * created as the loop could panic the system.
 	 */
-	(void) VOP_ACCESS(realrootvp, 0, 0, cr, NULL);
+	if ((error = VOP_ACCESS(realrootvp, 0, 0, cr, NULL)) != 0) {
+		VN_RELE(realrootvp);
+		return (error);
+	}
 
 	/*
 	 * We're interested in the top most filesystem.