Subject: kern/20478: revoke(2) on a device file does not close the device properly
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itohy@netbsd.org>
List: netbsd-bugs
Date: 02/24/2003 23:14:46
>Number:         20478
>Category:       kern
>Synopsis:       revoke(2) on a device file does not close the device properly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 24 06:15:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     ITOH Yasufumi
>Release:        NetBSD 1.6K
>Organization:
>Environment:
System: NetBSD pino.my.domain 1.6K NetBSD 1.6K (PINO) #351: Mon Nov 11 23:43:52 JST 2002 itohy@pino.my.domain:/w/src/sys/arch/i386/compile/PINO i386
Architecture: i386
Machine: i386

>Description:
	revoke(2) on a device file invalidates all file descriptors
	associated to the device, but it doesn't cause
	xxclose() driver interface called.

	That is, the device driver can't know ``not opened'' state.
	All descriptors are already gone, but xxclose() hasn't be called.

	If the driver implements locking (in xxopen() and xxclose())
	to avoid multiple open, the device can't be opened any longer.

>How-To-Repeat:
	Here's a sample program.

	revoke.c:
	#include <unistd.h>
	main()
	{
		return revoke("/dev/audio");
	}

	# cc -o revoketest revoke.c
	# audiorecord foo.wav &
	# ./revoketest			# this cause recording stop
	# audiorecord foo.wav
	audiorecord: failed to open /dev/sound0: Device busy
	# audioplay foo.wav
	audioplay: failed to open /dev/sound0: Device busy
	#

>Fix:
	ENOCLUE
	Change sys_revoke() ?

>Release-Note:
>Audit-Trail:
>Unformatted: