Date: Tue, 17 Nov 2009 20:41:15 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r199430 - stable/8/sys/cam Message-ID: <200911172041.nAHKfF09037005@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Tue Nov 17 20:41:15 2009 New Revision: 199430 URL: http://svn.freebsd.org/changeset/base/199430 Log: MFC r198705: Ensure target/lun passed from user-level supported on this bus. Scanning unsupported IDs causes different issues from duplicate devices to system crash. Modified: stable/8/sys/cam/cam_xpt.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/cam/cam_xpt.c ============================================================================== --- stable/8/sys/cam/cam_xpt.c Tue Nov 17 20:35:29 2009 (r199429) +++ stable/8/sys/cam/cam_xpt.c Tue Nov 17 20:41:15 2009 (r199430) @@ -452,7 +452,34 @@ xptioctl(struct cdev *dev, u_long cmd, c ccb = xpt_alloc_ccb(); CAM_SIM_LOCK(bus->sim); - + /* Ensure passed in target/lun supported on this bus. */ + if ((inccb->ccb_h.target_id != CAM_TARGET_WILDCARD) || + (inccb->ccb_h.target_lun != CAM_LUN_WILDCARD)) { + if (xpt_create_path(&ccb->ccb_h.path, + xpt_periph, + inccb->ccb_h.path_id, + CAM_TARGET_WILDCARD, + CAM_LUN_WILDCARD) != CAM_REQ_CMP) { + error = EINVAL; + CAM_SIM_UNLOCK(bus->sim); + xpt_free_ccb(ccb); + break; + } + xpt_setup_ccb(&ccb->ccb_h, ccb->ccb_h.path, + inccb->ccb_h.pinfo.priority); + ccb->ccb_h.func_code = XPT_PATH_INQ; + xpt_action(ccb); + xpt_free_path(ccb->ccb_h.path); + if ((inccb->ccb_h.target_id != CAM_TARGET_WILDCARD && + inccb->ccb_h.target_id > ccb->cpi.max_target) || + (inccb->ccb_h.target_lun != CAM_LUN_WILDCARD && + inccb->ccb_h.target_lun > ccb->cpi.max_lun)) { + error = EINVAL; + CAM_SIM_UNLOCK(bus->sim); + xpt_free_ccb(ccb); + break; + } + } /* * Create a path using the bus, target, and lun the * user passed in.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911172041.nAHKfF09037005>