git: cdd9dd5ac768 - stable/13 - cam: add missing zeroing of a stack-allocated CCB.

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Mon, 20 Jan 2025 12:42:15 UTC
The branch stable/13 has been updated by zlei:

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

commit cdd9dd5ac768675c1e67b6aa33f8f1c0ae56534a
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-05-16 09:28:04 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-01-20 12:39:27 +0000

    cam: add missing zeroing of a stack-allocated CCB.
    
    This could cause a panic at boot.
    
    Reported By:    Shawn Webb <shawn.webb AT hardenedbsd.org>
    Sponsored by:   NetApp, Inc.
    Sponsored by:   Klara, Inc.
    
    (cherry picked from commit 0f206cc91279e630ad9e733eb6e330b7dbe6c70e)
---
 sys/cam/ata/ata_xpt.c   | 1 +
 sys/cam/scsi/scsi_xpt.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/sys/cam/ata/ata_xpt.c b/sys/cam/ata/ata_xpt.c
index 81e6269dfa0d..c20c8626e395 100644
--- a/sys/cam/ata/ata_xpt.c
+++ b/sys/cam/ata/ata_xpt.c
@@ -2181,6 +2181,7 @@ ata_announce_periph_sbuf(struct cam_periph *periph, struct sbuf *sb)
 	struct ccb_trans_settings cts;
 	u_int speed, mb;
 
+	bzero(&cts, sizeof(cts));
 	_ata_announce_periph(periph, &cts, &speed);
 	if ((cts.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
 		return;
diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c
index 28d6445afac5..3b3aaabf2968 100644
--- a/sys/cam/scsi/scsi_xpt.c
+++ b/sys/cam/scsi/scsi_xpt.c
@@ -3144,6 +3144,7 @@ scsi_announce_periph(struct cam_periph *periph)
 	struct	ccb_trans_settings cts;
 	u_int speed, freq, mb;
 
+	memset(&cts, 0, sizeof(cts));
 	_scsi_announce_periph(periph, &speed, &freq, &cts);
 	if (cam_ccb_status((union ccb *)&cts) != CAM_REQ_CMP)
 		return;