From 459d0e830db996f62c1b89f8d0e0bef2746e88d4 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Fri, 4 Feb 2011 15:22:56 +0000 Subject: [PATCH] vdev's sectorsize should not be greater than 8 Kbytes and also it should be power of 2. This prevents non-aligned access while probing vdev's labels. PR: kern/147852 Reviewed by: pjd MFC after: 1 week --- .../opensolaris/uts/common/fs/zfs/vdev_geom.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 d0d5137913c8..fa42871ebd5d 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 @@ -393,7 +393,8 @@ vdev_geom_open_by_path(vdev_t *vd, int check_guid) if (pp != NULL) { ZFS_LOG(1, "Found provider by name %s.", vd->vdev_path); cp = vdev_geom_attach(pp); - if (cp != NULL && check_guid) { + if (cp != NULL && check_guid && ISP2(pp->sectorsize) && + pp->sectorsize <= VDEV_PAD_SIZE) { g_topology_unlock(); guid = vdev_geom_read_guid(cp); g_topology_lock(); @@ -457,6 +458,17 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift) if (cp == NULL) { ZFS_LOG(1, "Provider %s not found.", vd->vdev_path); error = ENOENT; + } else if (cp->provider->sectorsize > VDEV_PAD_SIZE || + !ISP2(cp->provider->sectorsize)) { + ZFS_LOG(1, "Provider %s has unsupported sectorsize.", + vd->vdev_path); + + g_topology_lock(); + vdev_geom_detach(cp, 0); + g_topology_unlock(); + + error = EINVAL; + cp = NULL; } else if (cp->acw == 0 && (spa_mode(vd->vdev_spa) & FWRITE) != 0) { int i;