diff options
author | jimharris <jimharris@FreeBSD.org> | 2013-03-27 00:15:22 +0000 |
---|---|---|
committer | jimharris <jimharris@FreeBSD.org> | 2013-03-27 00:15:22 +0000 |
commit | e86d6338eb787e1cab93b3a3f6791bf686bede1e (patch) | |
tree | 18f48edf33b1f345c546ba983da347609bc77747 | |
parent | efa760e156417ddf7ac1f60cc955b2bdc40df712 (diff) | |
download | FreeBSD-src-e86d6338eb787e1cab93b3a3f6791bf686bede1e.zip FreeBSD-src-e86d6338eb787e1cab93b3a3f6791bf686bede1e.tar.gz |
Panic should the SCI framework ever request a pointer into the ccb's
data buffer for a ccb that is unmapped.
This case is currently not possible, since the SCI framework only
requests these pointers for doing SCSI/ATA translation of non-
READ/WRITE commands. The panic is more to protect against the
unlikely future scenario where additional commands could be unmapped.
Sponsored by: Intel
-rw-r--r-- | sys/dev/isci/isci_io_request.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/sys/dev/isci/isci_io_request.c b/sys/dev/isci/isci_io_request.c index 9d2dd59..4486f31 100644 --- a/sys/dev/isci/isci_io_request.c +++ b/sys/dev/isci/isci_io_request.c @@ -506,10 +506,31 @@ uint8_t * scif_cb_io_request_get_virtual_address_from_sgl(void * scif_user_io_request, uint32_t byte_offset) { - struct ISCI_IO_REQUEST *isci_request = - (struct ISCI_IO_REQUEST *)scif_user_io_request; + struct ISCI_IO_REQUEST *isci_request; + union ccb *ccb; + + + isci_request = scif_user_io_request; + ccb = isci_request->ccb; + + /* + * This callback is only invoked for SCSI/ATA translation of + * PIO commands such as INQUIRY and READ_CAPACITY, to allow + * the driver to write the translated data directly into the + * data buffer. It is never invoked for READ/WRITE commands. + * The driver currently assumes only READ/WRITE commands will + * be unmapped. + * + * As a safeguard against future changes to unmapped commands, + * add an explicit panic here should the DATA_MASK != VADDR. + * Otherwise, we would return some garbage pointer back to the + * caller which would result in a panic or more subtle data + * corruption later on. + */ + if ((ccb->ccb_h.flags & CAM_DATA_MASK) != CAM_DATA_VADDR) + panic("%s: requesting pointer into unmapped ccb", __func__); - return (isci_request->ccb->csio.data_ptr + byte_offset); + return (ccb->csio.data_ptr + byte_offset); } /** |