PERFORCE change 177490 for review
Alexander Motin
mav at FreeBSD.org
Thu Apr 29 21:06:35 UTC 2010
http://p4web.freebsd.org/@@177490?ac=10
Change 177490 by mav at mav_mavtest on 2010/04/29 21:05:57
Validate Target/LUN IDs before use. Do not trust CAM.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/dev/mvs/mvs.c#20 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/dev/mvs/mvs.c#20 (text+ko) ====
@@ -1953,6 +1953,24 @@
return (1);
}
+static int
+mvs_check_ids(device_t dev, union ccb *ccb)
+{
+ struct mvs_channel *ch = device_get_softc(dev);
+
+ if (ccb->ccb_h.target_id > ((ch->quirks & MVS_Q_GENI) ? 0 : 15)) {
+ ccb->ccb_h.status = CAM_TID_INVALID;
+ xpt_done(ccb);
+ return (-1);
+ }
+ if (ccb->ccb_h.target_lun != 0) {
+ ccb->ccb_h.status = CAM_LUN_INVALID;
+ xpt_done(ccb);
+ return (-1);
+ }
+ return (0);
+}
+
static void
mvsaction(struct cam_sim *sim, union ccb *ccb)
{
@@ -1968,9 +1986,10 @@
/* Common cases first */
case XPT_ATA_IO: /* Execute the requested I/O operation */
case XPT_SCSI_IO:
+ if (mvs_check_ids(dev, ccb))
+ return;
if (ch->devices == 0) {
ccb->ccb_h.status = CAM_SEL_TIMEOUT;
- xpt_done(ccb);
break;
}
/* Check for command collision. */
@@ -1979,10 +1998,10 @@
ch->frozen = ccb;
/* We have only one frozen slot, so freeze simq also. */
xpt_freeze_simq(ch->sim, 1);
- break;
+ return;
}
mvs_begin_transaction(dev, ccb);
- break;
+ return;
case XPT_EN_LUN: /* Enable LUN as a target */
case XPT_TARGET_IO: /* Execute target I/O request */
case XPT_ACCEPT_TARGET_IO: /* Accept Host Target Mode CDB */
@@ -1990,13 +2009,14 @@
case XPT_ABORT: /* Abort the specified CCB */
/* XXX Implement */
ccb->ccb_h.status = CAM_REQ_INVALID;
- xpt_done(ccb);
break;
case XPT_SET_TRAN_SETTINGS:
{
struct ccb_trans_settings *cts = &ccb->cts;
struct mvs_device *d;
+ if (mvs_check_ids(dev, ccb))
+ return;
if (cts->type == CTS_TYPE_CURRENT_SETTINGS)
d = &ch->curr[ccb->ccb_h.target_id];
else
@@ -2016,7 +2036,6 @@
if (cts->xport_specific.sata.valid & CTS_SATA_VALID_ATAPI)
d->atapi = cts->xport_specific.sata.atapi;
ccb->ccb_h.status = CAM_REQ_CMP;
- xpt_done(ccb);
break;
}
case XPT_GET_TRAN_SETTINGS:
@@ -2026,6 +2045,8 @@
struct mvs_device *d;
uint32_t status;
+ if (mvs_check_ids(dev, ccb))
+ return;
if (cts->type == CTS_TYPE_CURRENT_SETTINGS)
d = &ch->curr[ccb->ccb_h.target_id];
else
@@ -2061,19 +2082,16 @@
cts->xport_specific.sata.atapi = d->atapi;
cts->xport_specific.sata.valid |= CTS_SATA_VALID_ATAPI;
ccb->ccb_h.status = CAM_REQ_CMP;
- xpt_done(ccb);
break;
}
case XPT_RESET_BUS: /* Reset the specified SCSI bus */
case XPT_RESET_DEV: /* Bus Device Reset the specified SCSI device */
mvs_reset(dev);
ccb->ccb_h.status = CAM_REQ_CMP;
- xpt_done(ccb);
break;
case XPT_TERM_IO: /* Terminate the I/O process */
/* XXX Implement */
ccb->ccb_h.status = CAM_REQ_INVALID;
- xpt_done(ccb);
break;
case XPT_PATH_INQ: /* Path routing inquiry */
{
@@ -2108,14 +2126,13 @@
cpi->protocol_version = PROTO_VERSION_UNSPECIFIED;
cpi->maxio = MAXPHYS;
cpi->ccb_h.status = CAM_REQ_CMP;
- xpt_done(ccb);
break;
}
default:
ccb->ccb_h.status = CAM_REQ_INVALID;
- xpt_done(ccb);
break;
}
+ xpt_done(ccb);
}
static void
More information about the p4-projects
mailing list