From hashiz@tomba.cskk-sv.co.jp  Thu Mar 10 10:07:55 2005
Return-Path: <hashiz@tomba.cskk-sv.co.jp>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 74E2E16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 10 Mar 2005 10:07:55 +0000 (GMT)
Received: from tomba.cskk-sv.co.jp (usen-221x245x15x82.ap-US01.usen.ad.jp [221.245.15.82])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9672943D1D
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 10 Mar 2005 10:07:54 +0000 (GMT)
	(envelope-from hashiz@tomba.cskk-sv.co.jp)
Received: from tomba.cskk-sv.co.jp (localhost.cskk-sv.co.jp [127.0.0.1])
	by tomba.cskk-sv.co.jp (8.13.3/8.13.1) with ESMTP id j2AA7qwY001532
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 10 Mar 2005 19:07:52 +0900 (JST)
	(envelope-from hashiz@tomba.cskk-sv.co.jp)
Received: (from hashiz@localhost)
	by tomba.cskk-sv.co.jp (8.13.3/8.13.1/Submit) id j2AA7qj8001531;
	Thu, 10 Mar 2005 19:07:52 +0900 (JST)
	(envelope-from hashiz)
Message-Id: <200503101007.j2AA7qj8001531@tomba.cskk-sv.co.jp>
Date: Thu, 10 Mar 2005 19:07:52 +0900 (JST)
From: HASHI Hiroaki <hashiz@tomba.cskk-sv.co.jp>
Reply-To: HASHI Hiroaki <hashiz@tomba.cskk-sv.co.jp>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: truss does not work on 5-STABLE(5.4-PRERELEASE)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         78664
>Category:       kern
>Synopsis:       truss does not work on 5-STABLE(5.4-PRERELEASE)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jeff
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 10 10:10:02 GMT 2005
>Closed-Date:    Sat Aug 06 19:25:36 GMT 2005
>Last-Modified:  Sat Aug 06 19:25:36 GMT 2005
>Originator:     HASHI Hiroaki
>Release:        FreeBSD 5.4-PRERELEASE i386
>Organization:
>Environment:
System: FreeBSD tomba.cskk-sv.co.jp 5.4-PRERELEASE FreeBSD 5.4-PRERELEASE #8: Thu Mar 10 15:52:56 JST 2005 hashiz@tomba.cskk-sv.co.jp:/usr/obj/home/sources/src/sys/TOMBA i386


	
>Description:
	truss command does not work with below message.

	"truss: PIOCBIS: Inappropriate ioctl for device"

>How-To-Repeat:
	% truss ls
	truss: PIOCBIS: Inappropriate ioctl for device

>Fix:
	I don't know how to fix.
	But I found a discussion about this ploblem in freebsd-current mailing list.
	thread "Nov 26 10:05:29 PST 2004 ptrace broken on latest CURRENT ?" 

>Release-Note:
>Audit-Trail:

From: Maxim Konovalov <maxim@macomnet.ru>
To: HASHI Hiroaki <hashiz@tomba.cskk-sv.co.jp>
Cc: bug-followup@freebsd.org
Subject: Re: kern/78664: truss does not work on 5-STABLE(5.4-PRERELEASE)
Date: Thu, 10 Mar 2005 13:50:20 +0300 (MSK)

 Does
 
 mount -t procfs proc /proc
 
 help?
 
 -- 
 Maxim Konovalov

From: HASHI Hiroaki <hashiz@tomba.cskk-sv.co.jp>
To: maxim@macomnet.ru
Cc: bug-followup@freebsd.org
Subject: Re: kern/78664: truss does not work on 5-STABLE(5.4-PRERELEASE)
Date: Fri, 11 Mar 2005 01:20:28 +0900 (JST)

 In "Re: kern/78664: truss does not work on 5-STABLE(5.4-PRERELEASE)" at Thu, 10 Mar 2005 13:50:20 +0300 (MSK)
  Maxim Konovalov <maxim@macomnet.ru>  wrote:
 > Does
 > 
 > mount -t procfs proc /proc
 
 mounted. but not work.
 
 tomba% mount 
 /dev/ad0s1a on / (ufs, local, soft-updates)
 devfs on /dev (devfs, local)
 /dev/da0s1a on /home (ufs, local, soft-updates, acls)
 procfs on /proc (procfs, local)
 linprocfs on /usr/compat/linux/proc (linprocfs, local)
 devfs on /var/named/dev (devfs, local)

From: Maxim Konovalov <maxim@macomnet.ru>
To: HASHI Hiroaki <hashiz@tomba.cskk-sv.co.jp>
Cc: bug-followup@freebsd.org
Subject: Re: kern/78664: truss does not work on 5-STABLE(5.4-PRERELEASE)
Date: Thu, 10 Mar 2005 22:49:42 +0300 (MSK)

 On Fri, 11 Mar 2005, 01:20+0900, HASHI Hiroaki wrote:
 
 > In "Re: kern/78664: truss does not work on 5-STABLE(5.4-PRERELEASE)" at Thu, 10 Mar 2005 13:50:20 +0300 (MSK)
 >  Maxim Konovalov <maxim@macomnet.ru>  wrote:
 > > Does
 > >
 > > mount -t procfs proc /proc
 >
 > mounted. but not work.
 >
 > tomba% mount
 > /dev/ad0s1a on / (ufs, local, soft-updates)
 > devfs on /dev (devfs, local)
 > /dev/da0s1a on /home (ufs, local, soft-updates, acls)
 > procfs on /proc (procfs, local)
 > linprocfs on /usr/compat/linux/proc (linprocfs, local)
 > devfs on /var/named/dev (devfs, local)
 
 I confirm I can reproduce this bug on recent RELENG_5 and fail on HEAD
 system.
 
 -- 
 Maxim Konovalov

From: Dan Nelson <dnelson@allantgroup.com>
To: freebsd-gnats-submit@FreeBSD.org, hashiz@tomba.cskk-sv.co.jp,
	stable@FreeBSD.org
Cc:  
Subject: Re: kern/78664: truss does not work on 5-STABLE(5.4-PRERELEASE)
Date: Thu, 17 Mar 2005 11:03:31 -0600

 HASHI Hiroaki wrote:
 > truss command does not work with below message.
 >
 > "truss: PIOCBIS: Inappropriate ioctl for device"
 
 I've narrowed it down to something committed between 02-24 and 02-27,
 but can't continue the binary search until tonight.  It would be really
 nice if this was fixed before 5.4 gets released :)
 
 -- 
 	Dan Nelson
 	dnelson@allantgroup.com

From: Dan Nelson <dnelson@allantgroup.com>
To: freebsd-gnats-submit@FreeBSD.org, hashiz@tomba.cskk-sv.co.jp,
	jeffr@FreeBSD.org
Cc:  
Subject: Re: kern/78664: truss does not work on 5-STABLE(5.4-PRERELEASE)
Date: Fri, 18 Mar 2005 13:08:01 -0600

 In the last episode (Mar 17), Dan Nelson said:
 > HASHI Hiroaki wrote:
 > > truss command does not work with below message.
 > >
 > > "truss: PIOCBIS: Inappropriate ioctl for device"
 > 
 > I've narrowed it down to something committed between 02-24 and 02-27,
 > but can't continue the binary search until tonight.  It would be
 > really nice if this was fixed before 5.4 gets released :)
 
 Jeff, it looks like your fdesc-locking MFC inadvertantly broke the
 PIOCBIS ioctl.  Craig Rodrigues' analysis at
 http://lists.freebsd.org/pipermail/freebsd-current/2004-November/043647.html
 looks accurate: the extra argument checking in
 kern/sys_generic.c:ioctl() is failing on a 0-byte IOC_IN ioctl that
 really should have used _IO().
 
 A quick grep shows some misuse in the other direction.  All the ioctls
 in aac_ioctl.h are _IO(), but many take struct* arguments and should
 have been _IOR or _IOW.  Since the ioctl definition itself is
 consistent though, it would still pass the checks.  I didn't see any
 ioctls (besides the pioctl.h ones) that would fail the checks, but
 since you can't guarantee that 3rd-party drivers aren't doing the same
 thing with private ioctls of their own, I think removing the size
 checks completely (maybe sending a kernel printf saying "this will fail
 on 6.x" on first occurance or something) is the best solution.
 
 Index: sys_generic.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/kern/sys_generic.c,v
 retrieving revision 1.132.2.3
 diff -u -r1.132.2.3 sys_generic.c
 --- sys_generic.c	27 Feb 2005 02:42:55 -0000	1.132.2.3
 +++ sys_generic.c	18 Mar 2005 18:32:53 -0000
 @@ -500,9 +503,7 @@
  	 */
  	size = IOCPARM_LEN(com);
  	if ((size > IOCPARM_MAX) ||
 -	    ((com & (IOC_VOID  | IOC_IN | IOC_OUT)) == 0) ||
 -	    ((com & IOC_VOID) && size > 0) ||
 -	    ((com & (IOC_IN | IOC_OUT)) && size == 0)) {
 +	    ((com & (IOC_VOID | IOC_IN | IOC_OUT)) == 0)) {
  		fdrop(fp, td);
  		return (ENOTTY);
  	}
 
 
 -- 
 	Dan Nelson
 	dnelson@allantgroup.com

From: "Wojciech A. Koszek" <dunstan@freebsd.czest.pl>
To: freebsd-gnats-submit@FreeBSD.org, hashiz@tomba.cskk-sv.co.jp
Cc: maxim@FreeBSD.org
Subject: Re: kern/78664: truss does not work on 5-STABLE(5.4-PRERELEASE)
Date: Sun, 3 Apr 2005 06:46:15 +0000

 Hello,
 I can also confirm that problem exists on my box with FreeBSD
 5.4-PRERELEASE. Craig's patch works for me. I hope it'll be commited.
 
 Regards,
 -- 
 * Wojciech A. Koszek && dunstan@FreeBSD.czest.pl
Responsible-Changed-From-To: freebsd-bugs->jeffr 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Apr 13 20:23:31 GMT 2005 
Responsible-Changed-Why:  
Based on reading the followups, it sounds like this change was introduced 
by jeffr's code, so over to him. 

Note: a patch, with some backing analysis, is contained. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=78664 
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sat Aug 6 19:20:51 GMT 2005 
State-Changed-Why:  
Committed to RELENG_5 on Fri Apr 8 12:05:37 2005 UTC by jeff (not jeffr). 


Responsible-Changed-From-To: jeffr->jeff 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Aug 6 19:20:51 GMT 2005 
Responsible-Changed-Why:  
Correct assignment. 

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