Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Jul 2026 21:27:47 +0000
From:      Joerg Wunsch <joerg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 34ae0f7834d1 - main - cam/cd: avoid integer divide fault in cdstart()
Message-ID:  <6a667bd3.426ed.1ab5a52e@gitrepo.freebsd.org>

index | next in thread | raw e-mail

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,


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a667bd3.426ed.1ab5a52e>