git: 34ae0f7834d1 - main - cam/cd: avoid integer divide fault in cdstart()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 26 Jul 2026 21:27:47 UTC
The branch main has been updated by joerg:
URL: https://cgit.FreeBSD.org/src/commit/?id=34ae0f7834d1bd6bb765d1c12e57e01e32b3e060
commit 34ae0f7834d1bd6bb765d1c12e57e01e32b3e060
Author: Joerg Wunsch <joerg@FreeBSD.org>
AuthorDate: 2026-07-26 20:54:01 +0000
Commit: Joerg Wunsch <joerg@FreeBSD.org>
CommitDate: 2026-07-26 21:25:53 +0000
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
---
sys/cam/scsi/scsi_cd.c | 10 ++++++++++
1 file changed, 10 insertions(+)
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,