diff options
author | ae <ae@FreeBSD.org> | 2011-05-25 11:14:26 +0000 |
---|---|---|
committer | ae <ae@FreeBSD.org> | 2011-05-25 11:14:26 +0000 |
commit | bd082ea669aca8f3e9ec34cd515f4aeef2d662a0 (patch) | |
tree | 45fc0642a59c68ab69d2607402a8dfb391161fe9 /sys/geom | |
parent | 22d66d32a10be9f960272dbbcfc8a5c0f312b5ef (diff) | |
download | FreeBSD-src-bd082ea669aca8f3e9ec34cd515f4aeef2d662a0.zip FreeBSD-src-bd082ea669aca8f3e9ec34cd515f4aeef2d662a0.tar.gz |
Prevent non-aligned reading from provider while tasting. Reject
providers with unsupported sectorsize.
Reported by: Joerg Wunsch
MFC after: 1 week
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/vinum/geom_vinum_drive.c | 4 | ||||
-rw-r--r-- | sys/geom/vinum/geom_vinum_events.c | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/sys/geom/vinum/geom_vinum_drive.c b/sys/geom/vinum/geom_vinum_drive.c index 5ab68f3..f782fd0 100644 --- a/sys/geom/vinum/geom_vinum_drive.c +++ b/sys/geom/vinum/geom_vinum_drive.c @@ -126,6 +126,10 @@ gv_read_header(struct g_consumer *cp, struct gv_hdr *m_hdr) pp = cp->provider; KASSERT(pp != NULL, ("gv_read_header: null pp")); + if ((GV_HDR_OFFSET % pp->sectorsize) != 0 || + (GV_HDR_LEN % pp->sectorsize) != 0) + return (ENODEV); + d_hdr = g_read_data(cp, GV_HDR_OFFSET, pp->sectorsize, NULL); if (d_hdr == NULL) return (-1); diff --git a/sys/geom/vinum/geom_vinum_events.c b/sys/geom/vinum/geom_vinum_events.c index fcd45f1..db4e543 100644 --- a/sys/geom/vinum/geom_vinum_events.c +++ b/sys/geom/vinum/geom_vinum_events.c @@ -109,6 +109,12 @@ gv_drive_tasted(struct gv_softc *sc, struct g_provider *pp) buf = NULL; G_VINUM_DEBUG(2, "tasted drive on '%s'", pp->name); + if ((GV_CFG_OFFSET % pp->sectorsize) != 0 || + (GV_CFG_LEN % pp->sectorsize) != 0) { + G_VINUM_DEBUG(0, "provider %s has unsupported sectorsize.", + pp->name); + return; + } gp = sc->geom; g_topology_lock(); |