lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 12 Apr 2011 10:21:46 +0530
From:	Amit Shah <amit.shah@...hat.com>
To:	Tejun Heo <tj@...nel.org>
Cc:	Stefan Hajnoczi <stefanha@...il.com>, linux-kernel@...r.kernel.org,
	Jens Axboe <axboe@...nel.dk>,
	"James E.J. Bottomley" <James.Bottomley@...e.de>,
	linux-scsi@...r.kernel.org, Markus Armbruster <armbru@...hat.com>
Subject: Re: [PATCH] sr: Ensure disk is revalidated when media changes

On (Fri) 08 Apr 2011 [09:52:07], Tejun Heo wrote:
> Hello,
> 
> On Fri, Apr 08, 2011 at 05:43:16PM +0100, Stefan Hajnoczi wrote:
> > >> I think it would make sense to refresh the inode size on media change
> > >> so that even open file descriptors see the new size and a single
> > >> process cannot force a stale value for all other userspace processes
> > >> on the system.
> > >
> > > Hmmm... I don't know.  Maybe we can but I'm not sure whether there's a
> > > good reason for it.  cdrom is locked while opened after all.  Are
> > > there actual problems?
> > 
> > Yeah, sorry I didn't explain what the use case was.  With QEMU you can
> > pass through the physical CD-ROM into the virtual machine.
> > 
> > QEMU opens /dev/cdrom with O_NONBLOCK | O_RDONLY.  The guest can test
> > if the medium is present and QEMU will do ioctl(fd,
> > CDROM_DRIVE_STATUS, CDSL_CURRENT).  The guest can also lock the tray
> > and eject, again using the respective ioctls.  Read operations are
> > serviced by performing a read on the file descriptor in QEMU.  And
> > finally the medium size is queried by QEMU using lseek(fd, 0,
> > SEEK_END).
> > 
> > Today QEMU cannot keep /dev/cdrom open across media change because it
> > will have an outdated inode size returned from lseek(fd, 0, SEEK_END).
> >  But if the cdrom driver (or sr) refresh the inode size on media
> > change then there is no need to work around this from userspace.
> 
> Hmmm... ISTR there was some discussion about changing inode size on
> the fly quite a while ago.  I didn't follow the discussion but it
> seemed to have rather nasty/delicate implications.

I don't necessarily agree with having to modify inode sizes on the
fly, but the main bug here is that the inode doesn't get invalidated
if a CDROM is ejected while a process has an fd to the CDROM device
opened.  So as in the original case, if a CD is swapped with one
having more data, lseek continues to report the original media's size
in the process that keeps the fd open across eject/insert.

I haven't tried this on physical systems, so can't count out it being
a qemu bug as well.

		Amit
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ