svn commit: r214063 - head/sys/geom

Jaakko Heinonen jh at FreeBSD.org
Tue Oct 19 16:48:50 UTC 2010


Author: jh
Date: Tue Oct 19 16:48:49 2010
New Revision: 214063
URL: http://svn.freebsd.org/changeset/base/214063

Log:
  Use make_dev_p(9) with the MAKEDEV_CHECKNAME flag instead of make_dev(9)
  and print a diagnostic if the call fails.
  
  This avoids a panic when a device with an invalid name is attempted to
  be registered. For example the label class gets device names from
  untrusted input.
  
  Reviewed by:	freebsd-geom

Modified:
  head/sys/geom/geom_dev.c

Modified: head/sys/geom/geom_dev.c
==============================================================================
--- head/sys/geom/geom_dev.c	Tue Oct 19 16:06:00 2010	(r214062)
+++ head/sys/geom/geom_dev.c	Tue Oct 19 16:48:49 2010	(r214063)
@@ -126,8 +126,16 @@ g_dev_taste(struct g_class *mp, struct g
 	error = g_attach(cp, pp);
 	KASSERT(error == 0,
 	    ("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error));
-	dev = make_dev(&g_dev_cdevsw, 0,
-	    UID_ROOT, GID_OPERATOR, 0640, "%s", gp->name);
+	error = make_dev_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, &dev,
+	    &g_dev_cdevsw, NULL, UID_ROOT, GID_OPERATOR, 0640, "%s", gp->name);
+	if (error != 0) {
+		printf("%s: make_dev_p() failed (gp->name=%s, error=%d)\n",
+		    __func__, gp->name, error);
+		g_detach(cp);
+		g_destroy_consumer(cp);
+		g_destroy_geom(gp);
+		return (NULL);
+	}
 	if (pp->flags & G_PF_CANDELETE)
 		dev->si_flags |= SI_CANDELETE;
 	dev->si_iosize_max = MAXPHYS;


More information about the svn-src-head mailing list