From nobody@FreeBSD.org  Sat Dec 18 19:48:06 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 0768016A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 18 Dec 2004 19:48:06 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id C44DD43D39
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 18 Dec 2004 19:48:05 +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 iBIJm5iU062505
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 18 Dec 2004 19:48:05 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id iBIJm5qo062504;
	Sat, 18 Dec 2004 19:48:05 GMT
	(envelope-from nobody)
Message-Id: <200412181948.iBIJm5qo062504@www.freebsd.org>
Date: Sat, 18 Dec 2004 19:48:05 GMT
From: Christoph Mallon <christoph.mallon@gmx.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: breaking fdformat /dev/fd0 resets device permissions and perhaps causes unkillable process
X-Send-Pr-Version: www-2.3

>Number:         75233
>Category:       kern
>Synopsis:       [fdc] breaking fdformat /dev/fd0 resets device permissions and perhaps causes unkillable process
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          suspended
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 18 19:50:30 GMT 2004
>Closed-Date:    
>Last-Modified:  Wed Feb 13 16:10:00 UTC 2013
>Originator:     Christoph Mallon
>Release:        FreeBSD 6.0-CURRENT
>Organization:
>Environment:
FreeBSD tron.homeunix.org 6.0-CURRENT FreeBSD 6.0-CURRENT #1: Wed Dec 15 10:19:30 CET 2004     root@tron.homeunix.org:/usr/obj/usr/src/sys/KERNEL  i386
>Description:
I formated a bunch of 3.5" floppies the other day to check which have bad
sectors. Every time I heard the typical bad sector sound from the floppy I
stopped fdformat with ^C, after several disks this happend:
%fdformat -y /dev/fd0
Processing VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV^C
[put in next disk]
%fdformat -y /dev/fd0
fdformat: open(/dev/fd0): Permission denied
%ls -l /dev/fd0
crw-r-----  1 root  operator  232,   0 16 Dez 21:41 /dev/fd0
%tail -1 /etc/devfs.conf
perm    fd0     0660

As you can see i set the permissions for fd0 to 660 in devfs.conf and
suddenly they got reset to 640.
/dev/console didn't show anything related to this.

I set the permission back to 660 by hand and continued. A bit later this
happend again and I set the permissions to 660 again.
After that the following happend:
%fdformat -y /dev/fd0
[floppy motor spins up]
[hang for several minutes without any output]
^C
[no reaction]

top on another terminal showed me this:
75741 tron      76    0  1284K   536K GEOM t   0:00  0.00%  0.00% fdformat

The process didn't react on kill -KILL.
The floppy motor was still on.
I tried to shut down my box (shutdown -h now) with the following result:
[usual output]
init: some processes would not die; ps axl advised
[usual output]
All buffers synced
[no more output]

Then the machine just hang without the usual uptime and "press any key to
reboot" message while the floppy motor was still on.
>How-To-Repeat:
1. chmod 660 /dev/fd0
2. fdformat /dev/fd0
3. break via ^C (not sure if a disk with bad sectors is necessary, probably not)
4. ls -l /dev/fd0
doesn't happen always, repeat 2-4 until it happens

The problem with the unkillable process appeared only once and I didn't
try to reproduce it, but i guess it happens after several iterations of
setting the permissions back to proper values and continuing with fdformat.
>Fix:

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: linimon 
State-Changed-When: Wed Nov 23 03:02:59 GMT 2005 
State-Changed-Why:  
Mark suspended while waiting for someone to investigate this edge case. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=75233 

From: Jaakko Heinonen <jh@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/75233: [fdc] breaking fdformat /dev/fd0 resets device
 permissions and perhaps causes unkillable process
Date: Fri, 16 Apr 2010 12:15:22 +0300

 There is another way to reproduce the permission reset problem
 in kern/97517.

From: John Baldwin <jhb@FreeBSD.org>
To: bug-followup@FreeBSD.org, christoph.mallon@gmx.de
Cc:  
Subject: Re: kern/75233: [fdc] breaking fdformat /dev/fd0 resets device permissions
 and perhaps causes unkillable process
Date: Fri, 30 Mar 2012 10:07:15 -0400

 You need to use devfs rules for this instead.  The /dev/fd0 device can
 come and go with media changes.  To make permissions on /dev/fd0
 persistent you need to teach devfs (via a rule) to use the desired
 permissions on each fd0 device.
 
 -- 
 John Baldwin

From: Christoph Mallon <christoph.mallon@gmx.de>
To: John Baldwin <jhb@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/75233: [fdc] breaking fdformat /dev/fd0 resets device permissions
 and perhaps causes unkillable process
Date: Tue, 12 Feb 2013 08:13:16 +0100

 On 30.03.2012 16:07, John Baldwin wrote:
 > You need to use devfs rules for this instead.  The /dev/fd0 device can
 > come and go with media changes.  To make permissions on /dev/fd0
 > persistent you need to teach devfs (via a rule) to use the desired
 > permissions on each fd0 device.
 
 Quote from the description:
 > %ls -l /dev/fd0
 > crw-r----- 1 root operator 232, 0 16 Dez 21:41 /dev/fd0
 > %tail -1 /etc/devfs.conf
 > perm fd0 0660
   ^^^^^^^^^^^^^
 
 Though I haven't used floppy disks in years, I still think there is a bug.
 
 	Christoph

From: John Baldwin <jhb@freebsd.org>
To: Christoph Mallon <christoph.mallon@gmx.de>
Cc: bug-followup@freebsd.org
Subject: Re: kern/75233: [fdc] breaking fdformat /dev/fd0 resets device permissions and perhaps causes unkillable process
Date: Wed, 13 Feb 2013 11:00:00 -0500

 On Tuesday, February 12, 2013 2:13:16 am Christoph Mallon wrote:
 > On 30.03.2012 16:07, John Baldwin wrote:
 > > You need to use devfs rules for this instead.  The /dev/fd0 device can
 > > come and go with media changes.  To make permissions on /dev/fd0
 > > persistent you need to teach devfs (via a rule) to use the desired
 > > permissions on each fd0 device.
 > 
 > Quote from the description:
 > > %ls -l /dev/fd0
 > > crw-r----- 1 root operator 232, 0 16 Dez 21:41 /dev/fd0
 > > %tail -1 /etc/devfs.conf
 > > perm fd0 0660
 >   ^^^^^^^^^^^^^
 > 
 > Though I haven't used floppy disks in years, I still think there is a bug.
 
 No, devfs.conf does not set devfs rules, it only does a single fixup on boot.  
 To have permissions enforced anytime a device node is created requires using a 
 devfs rule such as via /etc/devfs.rules.  See the devfs manpage for more
 info on how to do this.
 
 -- 
 John Baldwin
>Unformatted:
