DF-2450 / fix.diff
diff --git a/sys/dev/disk/dm/dm_pdev.c b/sys/dev/disk/dm/dm_pdev.c --- a/sys/dev/disk/dm/dm_pdev.c +++ b/sys/dev/disk/dm/dm_pdev.c @@ -150,6 +150,16 @@ } dmp->ref_cnt = 1; + /* Reject non-device vnodes (e.g. regular files) which have no + * v_rdev. Without this, dev_dioctl(NULL, DIOCGPART, ...) below + * dereferences v_rdev and panics. */ + if (dmp->pdev_vnode->v_rdev == NULL) { + dmdebug("%s is not a block device\n", dev_name); + dm_pdev_free(dmp); + lockmgr(&dm_pdev_mutex, LK_RELEASE); + return NULL; + } + if (dm_pdev_get_vattr(dmp, &va) == -1) { dmdebug("getattr on %s failed\n", dev_name); dm_pdev_free(dmp); |