diff options
author | mjacob <mjacob@FreeBSD.org> | 2006-09-16 21:21:07 +0000 |
---|---|---|
committer | mjacob <mjacob@FreeBSD.org> | 2006-09-16 21:21:07 +0000 |
commit | fa55c3d213d42a244212fa76cde60209fc68cce6 (patch) | |
tree | 0c120edfdb1e331a2f3c4314ead5b2dd3f3f66ce | |
parent | 9e8a4daa6bfb66b9c9565e9f7ed6639f28b4ba38 (diff) | |
download | FreeBSD-src-fa55c3d213d42a244212fa76cde60209fc68cce6.zip FreeBSD-src-fa55c3d213d42a244212fa76cde60209fc68cce6.tar.gz |
Don't allow attachment of disks that could cause GEOM to panic.
-rw-r--r-- | sys/cam/scsi/scsi_da.c | 33 |
1 files changed, 24 insertions, 9 deletions
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; |