summaryrefslogtreecommitdiffstats
path: root/sys/cam/cam_xpt.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2009-10-31 09:03:48 +0000
committermav <mav@FreeBSD.org>2009-10-31 09:03:48 +0000
commitc621c3c0b4159f52d9826811dfca312655c09e1d (patch)
treec8a94accdb89c2e2524d2d0e84e1fdfc2b183674 /sys/cam/cam_xpt.c
parentaad71995319d82ad248fc09625c6f36d5749859d (diff)
downloadFreeBSD-src-c621c3c0b4159f52d9826811dfca312655c09e1d.zip
FreeBSD-src-c621c3c0b4159f52d9826811dfca312655c09e1d.tar.gz
MFp4:
Ensure target/lun passed from user-level supported on this bus. Scanning unsupported IDs causes different issues from duplicate devices to system crash.
Diffstat (limited to 'sys/cam/cam_xpt.c')
-rw-r--r--sys/cam/cam_xpt.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index 479a605..d3ed9aa 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -452,7 +452,34 @@ xptioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td
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.
OpenPOWER on IntegriCloud