⬢ DragonFlyBSD Kernel Audit
DF-3575 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/disk/sym/sym_hipd.c b/sys/dev/disk/sym/sym_hipd.c
--- a/sys/dev/disk/sym/sym_hipd.c
+++ b/sys/dev/disk/sym/sym_hipd.c
@@ -7523,9 +7523,11 @@ static void sym_action(struct cam_sim *sim, union ccb *ccb)
 	 *  at BOOT in the NVRAM. This may speed up
 	 *  the boot and maintain coherency with BIOS
 	 *  device numbering. Clearing the flag allows
 	 *  user to rescan skipped devices later.
 	 *  We also return error for devices not flagged
 	 *  for SCAN LUNS in the NVRAM since some mono-lun
 	 *  devices behave badly when asked for some non
 	 *  zero LUN. Btw, this is an absolute hack.:-)
 	 */
 	if (!(ccb_h->flags & CAM_CDB_PHYS) &&
-	    (0x12 == ((ccb_h->flags & CAM_CDB_POINTER) ?
-		  csio->cdb_io.cdb_ptr[0] : csio->cdb_io.cdb_bytes[0]))) {
+	    ((ccb_h->flags & CAM_CDB_POINTER) ?
+	      (csio->cdb_io.cdb_ptr != NULL &&
+	       0x12 == csio->cdb_io.cdb_ptr[0]) :
+	      (0x12 == csio->cdb_io.cdb_bytes[0]))) {
 		if ((tp->usrflags & SYM_SCAN_BOOT_DISABLED) ||
 		    ((tp->usrflags & SYM_SCAN_LUNS_DISABLED) &&
 		     ccb_h->target_lun != 0)) {
@@ -7690,6 +7692,12 @@ static int sym_setup_cdb(hcb_p np, struct ccb_scsiio *csio, ccb_p cp)
 	if (ccb_h->flags & CAM_CDB_POINTER) {
 		/* CDB is a pointer */
 		if (!(ccb_h->flags & CAM_CDB_PHYS)) {
 			/* CDB pointer is virtual */
+			if (csio->cdb_io.cdb_ptr == NULL) {
+				sym_set_cam_status(cp->cam_ccb,
+						   CAM_REQ_INVALID);
+				return -1;
+			}
 			bcopy(csio->cdb_io.cdb_ptr, cp->cdb_buf, cmd_len);
 			cmd_ba = CCB_BA (cp, cdb_buf[0]);
 		} else {