Bug 28166

Summary: Mounted CD-ROM can be ejected in some cases
Product: Base System Reporter: Eugene Grosbein <ports>
Component: kernAssignee: Søren Schmidt <sos>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-STABLE   
Hardware: Any   
OS: Any   

Description Eugene Grosbein 2001-06-15 07:50:01 UTC
	This is possible to eject mounted CD-ROM

Fix: 

Unknown for me.
How-To-Repeat: 
Insert any CD-ROM in drive. Then type:

	export CDROM=/dev/acd0c
	mount /cdrom
	cd /cdrom

Now CD-ROM is locked. 'Eject' button on the front panel of drive does not
work. Now type:
	umount /cdrom; cdcontrol eject

Filesystem is busy so umount failed. cdcontrol failed as well. But now
'Eject' button on the front panel of drive DOES work and CD-ROM is
ejected when you press 'Eject'. Note, that filesystem is still mounted.
Comment 1 ru freebsd_committer freebsd_triage 2001-06-15 08:31:07 UTC
This is also reproduceable on a recent 5.0-CURRENT system with
ATAPI CD-ROM drive mounted on /cdrom except holding a reference
on a top-level mount point (cd /cdrom) is not considered a BUSY
condition, and ``cd /cdrom; umount /cdrom'' succeeds.  Also, an
assorted bug that is only reproduceable in -CURRENT:

(mount /cdrom; cd /cdrom/foo; while :; do umount /cdrom; done)
panics within a few seconds.

> Insert any CD-ROM in drive. Then type:
> 
> 	export CDROM=/dev/acd0c
> 	mount /cdrom
> 	cd /cdrom
> 
> Now CD-ROM is locked. 'Eject' button on the front panel of drive does not
> work. Now type:
> 	umount /cdrom; cdcontrol eject
> 
> Filesystem is busy so umount failed. cdcontrol failed as well. But now
> 'Eject' button on the front panel of drive DOES work and CD-ROM is
> ejected when you press 'Eject'. Note, that filesystem is still mounted.


Cheers,
-- 
Ruslan Ermilov		Oracle Developer/DBA,
ru@sunbay.com		Sunbay Software AG,
ru@FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age
Comment 2 ru freebsd_committer freebsd_triage 2001-06-15 08:31:33 UTC
Responsible Changed
From-To: freebsd-bugs->sos

Over to Mr. ATA.
Comment 3 Bruce Evans 2001-06-15 10:56:27 UTC
On Fri, 15 Jun 2001, Eugene B. Grosbein wrote:

> >How-To-Repeat:
> 
> Insert any CD-ROM in drive. Then type:
> 
> 	export CDROM=/dev/acd0c

This should be

	export CDROM=/dev/cdrom

to avoid inadvertently demonstating the bug that /dev/acd0c can be ejected
while /dev/acd0a is mounted.

> 	mount /cdrom
> 	cd /cdrom
> 
> Now CD-ROM is locked. 'Eject' button on the front panel of drive does not
> work. Now type:
> 	umount /cdrom; cdcontrol eject
> 
> Filesystem is busy so umount failed. cdcontrol failed as well. But now

I think you need to "cd /cdrom/subdir" to make the filesystem busy.  After
only "cd /cdrom", the umount works for me.

> 'Eject' button on the front panel of drive DOES work and CD-ROM is
> ejected when you press 'Eject'. Note, that filesystem is still mounted.

This is caused by cdcontrol issuing a CDIOCALLOW ioctl for 'Eject',
and the acd driver permitting CDIOCALLOW on mounted drives.  I think
CDIOCALLOW should be limited in the same way as CDIOCEJECT.

The (scsi) cd driver understands these ioctls even less than the acd
driver.  It always permits them.

Bruce
Comment 4 Bruce Evans 2001-06-15 11:07:23 UTC
On Fri, 15 Jun 2001, I wrote:

> This is caused by cdcontrol issuing a CDIOCALLOW ioctl for 'Eject',
> and the acd driver permitting CDIOCALLOW on mounted drives.  I think
> CDIOCALLOW should be limited in the same way as CDIOCEJECT.
> 
> The (scsi) cd driver understands these ioctls even less than the acd
> driver.  It always permits them.

PS: However, the cd driver understands the implicit CDIOCALLOW at last-close
time.  With the acd driver, just opening and closing an alias is sufficient
to break the locking of the eject button:

    mount /dev/acd0a /mnt
    # Eject button does not work now.
    dd if=/dev/acd0c of=/dev/null bs=2k count=1
    # Eject button works now.

Bruce
Comment 5 Eugene Grosbein 2001-06-15 11:58:27 UTC
Bruce Evans wrote:

> >       mount /cdrom
> >       cd /cdrom
> >
> > Now CD-ROM is locked. 'Eject' button on the front panel of drive does not
> > work. Now type:
> >       umount /cdrom; cdcontrol eject
> >
> > Filesystem is busy so umount failed. cdcontrol failed as well. But now
> 
> I think you need to "cd /cdrom/subdir" to make the filesystem busy.  After
> only "cd /cdrom", the umount works for me.

It fails for me. My 4.3-STABLE is a bit old.

Eugene Grosbein
Comment 6 Søren Schmidt freebsd_committer freebsd_triage 2001-12-12 14:02:48 UTC
State Changed
From-To: open->closed

Fixed in -current, MFC will follow.
Comment 7 Jens Schweikhardt freebsd_committer freebsd_triage 2003-08-07 17:38:42 UTC
State Changed
From-To: closed->patched

Apparently the MFC has not yet happened (see also PR 55344)
Comment 8 Søren Schmidt freebsd_committer freebsd_triage 2003-10-25 20:36:29 UTC
State Changed
From-To: patched->closed
Comment 9 Eugene Grosbein 2003-10-26 04:26:57 UTC
"Søren Schmidt" wrote:

> Synopsis: Mounted CD-ROM can be ejected in some cases
> 
> State-Changed-From-To: patched->closed
> State-Changed-By: sos
> State-Changed-When: Sat Oct 25 12:36:29 PDT 2003
> State-Changed-Why:
> 
> http://www.freebsd.org/cgi/query-pr.cgi?pr=28166

Is this PR closed because MFC has appeared? Thank you then!

Eugene Grosbein