diff options
author | mav <mav@FreeBSD.org> | 2013-12-10 12:36:44 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2013-12-10 12:36:44 +0000 |
commit | 057ae4aad3a8bda9ecaf67047ba7cd49dcb0ac16 (patch) | |
tree | 829301412b806c49065688717dd1d2bd7088d492 /sys/cddl | |
parent | 28ab9c57056ffc8be0574b6cc4f6477afca314e0 (diff) | |
download | FreeBSD-src-057ae4aad3a8bda9ecaf67047ba7cd49dcb0ac16.zip FreeBSD-src-057ae4aad3a8bda9ecaf67047ba7cd49dcb0ac16.tar.gz |
Don't even try to read vdev labels from devices smaller then SPA_MINDEVSIZE
(64MB). Even if we would find one somehow, ZFS kernel code rejects such
devices. It is funny to look on attempts to read 4 256K vdev labels from
1.44MB floppy, though it is not very practical and quite slow.
Diffstat (limited to 'sys/cddl')
-rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c index 0ec6657..e1cca48 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c @@ -401,10 +401,16 @@ vdev_geom_attach_taster(struct g_consumer *cp, struct g_provider *pp) if (pp->flags & G_PF_WITHER) return (EINVAL); - if (pp->sectorsize > VDEV_PAD_SIZE || !ISP2(pp->sectorsize)) - return (EINVAL); g_attach(cp, pp); error = g_access(cp, 1, 0, 0); + if (error == 0) { + if (pp->sectorsize > VDEV_PAD_SIZE || !ISP2(pp->sectorsize)) + error = EINVAL; + else if (pp->mediasize < SPA_MINDEVSIZE) + error = EINVAL; + if (error != 0) + g_access(cp, -1, 0, 0); + } if (error != 0) g_detach(cp); return (error); |