diff options
author | jh <jh@FreeBSD.org> | 2010-10-19 16:48:49 +0000 |
---|---|---|
committer | jh <jh@FreeBSD.org> | 2010-10-19 16:48:49 +0000 |
commit | e0ef538943372391168a941960a346e5b71fdccc (patch) | |
tree | 74f3cef44d60d20656a994496934dcc29248f74c /sys | |
parent | 3f66b926771c75cf92084431cf4f12eecfd68413 (diff) | |
download | FreeBSD-src-e0ef538943372391168a941960a346e5b71fdccc.zip FreeBSD-src-e0ef538943372391168a941960a346e5b71fdccc.tar.gz |
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
Diffstat (limited to 'sys')
-rw-r--r-- | sys/geom/geom_dev.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index 173e326..e4cbbe3 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -126,8 +126,16 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused) 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; |