From nobody@FreeBSD.org  Wed Sep 29 18:16:17 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0E00D16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 29 Sep 2004 18:16:17 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 02B7A43D62
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 29 Sep 2004 18:16:17 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i8TIGGpe008265
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 29 Sep 2004 18:16:16 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.11/8.12.11/Submit) id i8TIGG39008264;
	Wed, 29 Sep 2004 18:16:16 GMT
	(envelope-from nobody)
Message-Id: <200409291816.i8TIGG39008264@www.freebsd.org>
Date: Wed, 29 Sep 2004 18:16:16 GMT
From: Doug Haigh <dhaigh@mail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: camcontrol's getdevtree fails
X-Send-Pr-Version: www-2.3

>Number:         72177
>Category:       bin
>Synopsis:       [patch] camcontrol's getdevtree fails
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    delphij
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 29 18:20:25 GMT 2004
>Closed-Date:    Wed Jul 13 04:58:00 GMT 2005
>Last-Modified:  Wed Jul 13 04:58:00 GMT 2005
>Originator:     Doug Haigh
>Release:        5.2.1
>Organization:
>Environment:
Environment independent - error in base code for /sbin/camcontrol
>Description:
On SPARC64 machine, running the camcontrol devlist command fails because the xptioctl code thinks the physical flag (CAM_DATA_PHYS) is set. 

In looking into /usr/src/sbin/camcontrol/camcontrol.c in the getdevtree routine, the CCB union is allocated off the stack, but the bzero command to clear out the structure skips the header section and just clears the ccb_dev_match part. Because of this, whatever is on the stack is sent as header flags to the ioctl routine. 

I would suggest clearing out the entire strucure or explicitly setting all fields in the header structure.
>How-To-Repeat:
Difficult to do unless you can mess up the stack data to imitate the CAM_DATA_PHYS being set.
>Fix:
Change line 306 from

bzero(&(&ccb.ccb_h)[1], sizeof(struct ccb_dev_match) - sizeof(struct ccb_hdr));

to

bzero(&ccb, sizeof(ccb));

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: delphij 
State-Changed-When: Wed Jul 13 04:56:57 GMT 2005 
State-Changed-Why:  
It seems that the issue has been fixed by rev. 1.52 of camcontrol.c, 
so close this PR. 


Responsible-Changed-From-To: freebsd-bugs->delphij 
Responsible-Changed-By: delphij 
Responsible-Changed-When: Wed Jul 13 04:56:57 GMT 2005 
Responsible-Changed-Why:  
Contact me if I was wrong.  Thanks for your submission! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72177 
>Unformatted:
