From nobody@FreeBSD.org  Thu Nov  3 18:15:33 2005
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 CDDCA16A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  3 Nov 2005 18:15:33 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9F64743D45
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  3 Nov 2005 18:15:33 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id jA3IFXhU066139
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 3 Nov 2005 18:15:33 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id jA3IFXrX066138;
	Thu, 3 Nov 2005 18:15:33 GMT
	(envelope-from nobody)
Message-Id: <200511031815.jA3IFXrX066138@www.freebsd.org>
Date: Thu, 3 Nov 2005 18:15:33 GMT
From: "trasz <"<trasz@pin.if.uz.zgora.pl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: 'devfs rule add'  before 'devfs ruleset' kills devfs.
X-Send-Pr-Version: www-2.3

>Number:         88463
>Category:       bin
>Synopsis:       devfs(8): 'devfs rule add'  before 'devfs ruleset' kills devfs.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 03 18:20:14 GMT 2005
>Closed-Date:    Thu Jan 05 20:35:40 GMT 2006
>Last-Modified:  Thu Jan 05 20:35:40 GMT 2006
>Originator:     trasz
>Release:        6.0-rc1
>Organization:
>Environment:
FreeBSD traszkan.ds7 6.0-RC1 FreeBSD 6.0-RC1 #0: Sat Oct 29 21:42:46 CEST 2005     trasz@traszkan.ds7:/usr/obj/usr/src/sys/TRASHCAN  i386
>Description:
doing 'devfs rule add <whatever>' before 'devfs ruleset <number>' makes
all the dev-related processes - and some ordinary ones like ps(1) - sleep
endlessly on 'devfs rule lock'.  clean reboot of the system is impossible
after that.

note that this occurs only if you don't have any ruleset enabled - that
is, no 'devfs_system_ruleset=something' in /etc/rc.conf.

>How-To-Repeat:

>Fix:
              
>Release-Note:
>Audit-Trail:

From: Guy Harris <guy@alum.mit.edu>
To: bug-followup@FreeBSD.org, trasz@pin.if.uz.zgora.pl
Cc:  
Subject: Re: bin/88463: devfs(8): 'devfs rule add'  before 'devfs ruleset'
 kills devfs.
Date: Thu, 05 Jan 2006 01:04:32 -0800

 This sounds like the bug from
 
 	http://lists.freebsd.org/pipermail/freebsd-hackers/2006-January/015009.html
 
 which I also saw.
 
 It appears that if you submit a rule with DEVFSIO_RADD, and the rule set 
 number of the rule is 0, devfs_rules_ioctl() will return without 
 releasing any locks - in particular, it won't release the devfs ruleset 
 lock.  This might be the cause.
 
 If you're getting
 
 	devfs rule: ioctl DEVFSIO_RADD: Input/output error
 
 from the "devfs rule add", then that's the problem.
 
 The fix - release the lock before returning EIO:
 
 Index: devfs_rule.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/fs/devfs/devfs_rule.c,v
 retrieving revision 1.20
 diff -c -r1.20 devfs_rule.c
 *** devfs_rule.c    24 Sep 2005 07:03:09 -0000    1.20
 --- devfs_rule.c    1 Jan 2006 02:28:32 -0000
 ***************
 *** 186,193 ****
                error = EEXIST;
                break;
            }
 !         if (rid2rsn(dr->dr_id) == 0)
 !             return (EIO);
            error = devfs_rule_insert(dr);
            break;
        case DEVFSIO_RAPPLY:
 --- 186,195 ----
                error = EEXIST;
                break;
            }
 !         if (rid2rsn(dr->dr_id) == 0) {
 !             error = EIO;
 !             break;
 !         }
            error = devfs_rule_insert(dr);
            break;
        case DEVFSIO_RAPPLY:
 
 
 

From: Guy Harris <guy@alum.mit.edu>
To: bug-followup@FreeBSD.org, trasz@pin.if.uz.zgora.pl
Cc:  
Subject: Re: bin/88463: devfs(8): 'devfs rule add'  before 'devfs ruleset'
 kills devfs.
Date: Thu, 05 Jan 2006 11:32:09 -0800

 This is a dup of kern/91338; the latter has the right category (the bug 
 is in the devfs kernel code), and a higher severity (it pretty badly 
 locked up my machine, although if it's unlikely to happen, it might be 
 less severe).  One of them should be closed.
 
 In any case, the fix should be a no-brainer - the bug, and fix, are 
 fairly obvious.
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Thu Jan 5 20:34:47 UTC 2006 
State-Changed-Why:  
A suggested fix is now in kern/91338. 

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