Author: jimharris Date: Wed Mar 27 00:15:22 2013 New Revision: 248778 URL: http://svnweb.freebsd.org/changeset/base/248778
Log: 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 Modified: head/sys/dev/isci/isci_io_request.c Modified: head/sys/dev/isci/isci_io_request.c ============================================================================== --- head/sys/dev/isci/isci_io_request.c Tue Mar 26 23:58:13 2013 (r248777) +++ head/sys/dev/isci/isci_io_request.c Wed Mar 27 00:15:22 2013 (r248778) @@ -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); } /** _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"