git: 736d7302e445 - stable/14 - cam/cd: avoid integer divide fault in cdstart()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 25 Sep 2026 08:33:35 UTC
The branch stable/14 has been updated by joerg:
URL: https://cgit.FreeBSD.org/src/commit/?id=736d7302e44598cb10557026b0a72e319a63194b
commit 736d7302e44598cb10557026b0a72e319a63194b
Author: Joerg Wunsch <joerg@FreeBSD.org>
AuthorDate: 2026-07-26 20:54:01 +0000
Commit: Joerg Wunsch <joerg@FreeBSD.org>
CommitDate: 2026-09-25 08:09:58 +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
(cherry picked from commit 34ae0f7834d1bd6bb765d1c12e57e01e32b3e060)
---
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 da6d25ad0031..6482bb44226d 100644
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -930,6 +930,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,