From fa55c3d213d42a244212fa76cde60209fc68cce6 Mon Sep 17 00:00:00 2001 From: mjacob Date: Sat, 16 Sep 2006 21:21:07 +0000 Subject: Don't allow attachment of disks that could cause GEOM to panic. --- sys/cam/scsi/scsi_da.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'sys/cam') diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index c097409..c0ddefc 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1519,15 +1519,30 @@ dadone(struct cam_periph *periph, union ccb *done_ccb) block_size = scsi_4btoul(rcaplong->length); maxsector = scsi_8btou64(rcaplong->addr); } - dasetgeom(periph, block_size, maxsector); - dp = &softc->params; - snprintf(announce_buf, sizeof(announce_buf), - "%juMB (%ju %u byte sectors: %dH %dS/T %dC)", - (uintmax_t) (((uintmax_t)dp->secsize * - dp->sectors) / (1024*1024)), - (uintmax_t)dp->sectors, - dp->secsize, dp->heads, dp->secs_per_track, - dp->cylinders); + + /* + * Because GEOM code just will panic us if we + * give them an 'illegal' value we'll avoid that + * here. + */ + if (block_size >= MAXPHYS || block_size == 0) { + xpt_print_path(periph->path); + printf("unsupportable block size %ju\n", + (uintmax_t) block_size); + announce_buf[0] = '\0'; + cam_periph_invalidate(periph); + } else { + dasetgeom(periph, block_size, maxsector); + dp = &softc->params; + snprintf(announce_buf, sizeof(announce_buf), + "%juMB (%ju %u byte sectors: %dH %dS/T " + "%dC)", (uintmax_t) + (((uintmax_t)dp->secsize * + dp->sectors) / (1024*1024)), + (uintmax_t)dp->sectors, + dp->secsize, dp->heads, + dp->secs_per_track, dp->cylinders); + } } else { int error; -- cgit v1.1