git: 34ae0f7834d1 - main - cam/cd: avoid integer divide fault in cdstart()

Joerg Wunsch <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a667bd3.426ed.1ab5a52e__2582.2830431693$1785101283$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by joerg:

URL: https://cgit.FreeBSD.org/src/commit/?id=34ae0f7834d1bd6bb765d1c12e57e01e32b3e060

commit 34ae0f7834d1bd6bb765d1c12e57e01e32b3e060
Author:     Joerg Wunsch <[email protected]>
AuthorDate: 2026-07-26 20:54:01 +0000
Commit:     Joerg Wunsch <[email protected]>
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,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.