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]
Message-Id: <20060907152037.a4e1437b.akpm@osdl.org>
Date:	Thu, 7 Sep 2006 15:20:37 -0700
From:	Andrew Morton <akpm@...l.org>
To:	Alexey Dobriyan <adobriyan@...il.com>
Cc:	linux-kernel@...r.kernel.org, Al Viro <viro@...iv.linux.org.uk>,
	Christoph Hellwig <hch@....de>, Greg KH <greg@...ah.com>
Subject: Re: Naughty ramdrives

On Fri, 8 Sep 2006 02:08:53 +0400
Alexey Dobriyan <adobriyan@...il.com> wrote:

> > So I assume udev is still madly crunching on its message backlog while
> > this is happening?
> >
> > If so, ug.
> 
> OK. I'll let it stabilize, sorry.

You shouldn't have to.

> > > This was noticed while investigating #4899
> > > http://bugme.osdl.org/show_bug.cgi?id=4899
> > > where /dev/ram0 when opened, pins module indefinitely. It seems that
> > > adding ->release() which undoes
> > >
> > > 	inode = igrab(bdev->bd_inode);
> > >
> > > should do the trick. Am I right?
> 
> > Looks right.
> >
> > I'm not sure that igrab() is needed though.  Probably bd_openers is
> > sufficient.
> >
> > I'm also not sure that rd_open() needs to play with bd_openers.
> > fs/block_dev.c:do_open() already does that.
> 
> Maybe start with closing open/open race?
> That's what drivers/char/raw.c does...
> ------------------------------------------------
> [PATCH 1/2] rd: protect rd_bdev[] with mutex
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
> ---
> 
>  drivers/block/rd.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> --- a/drivers/block/rd.c
> +++ b/drivers/block/rd.c
> @@ -56,6 +56,7 @@ #include <linux/buffer_head.h>		/* for i
>  #include <linux/backing-dev.h>
>  #include <linux/blkpg.h>
>  #include <linux/writeback.h>
> +#include <linux/mutex.h>
>  
>  #include <asm/uaccess.h>
>  
> @@ -63,6 +64,7 @@ #include <asm/uaccess.h>
>   */
>  
>  static struct gendisk *rd_disks[CONFIG_BLK_DEV_RAM_COUNT];
> +static DEFINE_MUTEX(rd_mutex);

This could be static to rd_open().

>  static struct block_device *rd_bdev[CONFIG_BLK_DEV_RAM_COUNT];/* Protected device data */
>  static struct request_queue *rd_queue[CONFIG_BLK_DEV_RAM_COUNT];
>  
> @@ -343,6 +345,7 @@ static int rd_open(struct inode *inode, 
>  {
>  	unsigned unit = iminor(inode);
>  
> +	mutex_lock(&rd_mutex);

I suspect that we've inherited enough locking from the caller to not need
this.  That's if fs/block_dev.c:do_open() is the only caller.  Not sure if
that's true if someone goes and partitions a ramdisk (is that possible?).

All this gendisk/blockdev/contains/partitions/bd_inode stuff is quite
ghastly.  Every six months I spend long enough staring at it to
half-understand it and then promptly forget how it all works.


-
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