Bug 91338

Summary: Adding a devfs rule with a rule set number of 0 locks the devfs rules
Product: Base System Reporter: guy
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 6.0-RELEASE   
Hardware: Any   
OS: Any   

Description guy 2006-01-05 08:40:10 UTC
 	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.

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:
How-To-Repeat:  	Do
 
 		devfs rule add path 'bpf*' group staff mode 0660
 
 	from the command line; it should report
 
 		devfs rule: ioctl DEVFSIO_RADD: Input/output error
 
 	and should now lock up on any subsequent attempt to add rules
 	(or anything else that tries to get the devfs ruleset lock).
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2006-01-05 17:50:36 UTC
Responsible Changed
From-To: gnats-admin->freebsd-bugs

Rescue this PR from the 'pending' category.
Comment 2 Robert Watson freebsd_committer freebsd_triage 2006-01-14 08:49:47 UTC
State Changed
From-To: open->closed

This is a dup of bin/88463, and was corrected by a recent commit and 
MFC I made (with an identical fix to the one proposed here). 

Thanks!