From owner-p4-projects@FreeBSD.ORG Sat Oct 31 08:47:49 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id ECA0E106568B; Sat, 31 Oct 2009 08:47:48 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B10E61065676 for ; Sat, 31 Oct 2009 08:47:48 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 9EBD18FC08 for ; Sat, 31 Oct 2009 08:47:48 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n9V8lmmq033949 for ; Sat, 31 Oct 2009 08:47:48 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n9V8lm6l033947 for perforce@freebsd.org; Sat, 31 Oct 2009 08:47:48 GMT (envelope-from mav@freebsd.org) Date: Sat, 31 Oct 2009 08:47:48 GMT Message-Id: <200910310847.n9V8lm6l033947@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mav@freebsd.org using -f From: Alexander Motin To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 169980 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2009 08:47:49 -0000 http://p4web.freebsd.org/chv.cgi?CH=169980 Change 169980 by mav@mav_mavtest on 2009/10/31 08:47:33 Ensure target/lun passed from user-level supported on this bus. Scanning unsupported IDs causes different issues from duplicate devices to system crash. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#111 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#111 (text+ko) ==== @@ -453,7 +453,34 @@ 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.