Prevent non-aligned reading from provider while tasting. Reject

providers with unsupported sectorsize.

Reported by:	Joerg Wunsch
MFC after:	1 week
This commit is contained in:
Andrey V. Elsukov 2011-05-25 11:14:26 +00:00
parent a92e80be3f
commit ceef8f2477
2 changed files with 10 additions and 0 deletions

View File

@ -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);

View File

@ -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();