aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Wunsch <joerg@FreeBSD.org>2026-07-26 20:54:01 +0000
committerJoerg Wunsch <joerg@FreeBSD.org>2026-07-26 21:25:53 +0000
commit34ae0f7834d1bd6bb765d1c12e57e01e32b3e060 (patch)
tree16af266f20a5400621cd7facb5c14f13277fe60e
parent297394e995e5ea1ea9bc85e609ca116255d51e97 (diff)
cam/cd: avoid integer divide fault in cdstart()
If something goes very badly (e.g. forcibly removing a medium while the OS tries to start it), this could end up in params.blksize being 0 (and params.disksize 1). Avoid an integer divide fault, panicking the kernel, by bailing out before. MFC after: 3 days
-rw-r--r--sys/cam/scsi/scsi_cd.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c
index e622a96ec77e..1e8dc98d53f4 100644
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -918,6 +918,16 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb)
return;
}
+ if (softc->params.blksize == 0) {
+ /*
+ * Something went utterly wrong.
+ * Avoid integer divide fault below.
+ */
+ biofinish(bp, NULL, ENXIO);
+ xpt_release_ccb(start_ccb);
+ return;
+ }
+
scsi_read_write(&start_ccb->csio,
/*retries*/ cd_retry_count,
/* cbfcnp */ cddone,