From owner-svn-src-all@FreeBSD.ORG Wed Mar 27 00:15:23 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9D5032A3; Wed, 27 Mar 2013 00:15:23 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 76617D8; Wed, 27 Mar 2013 00:15:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2R0FMAT070706; Wed, 27 Mar 2013 00:15:22 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2R0FMTN070705; Wed, 27 Mar 2013 00:15:22 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303270015.r2R0FMTN070705@svn.freebsd.org> From: Jim Harris Date: Wed, 27 Mar 2013 00:15:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248778 - head/sys/dev/isci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Mar 2013 00:15:23 -0000 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); } /**