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:	Mon, 11 May 2015 15:25:05 -0700
From:	Brian Norris <computersforpeace@...il.com>
To:	"Cantavenera, Giuseppe (EXT-Other - DE/Ulm)" 
	<giuseppe.cantavenera.ext@...ia.com>
Cc:	"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
	"Restelli, Lorenzo (EXT-Other - DE/Ulm)" 
	<lorenzo.restelli.ext@...ia.com>,
	"dwmw2@...radead.org" <dwmw2@...radead.org>,
	"stable@...r.kernel.org" <stable@...r.kernel.org>,
	"Sverdlin, Alexander (Nokia - DE/Ulm)" <alexander.sverdlin@...ia.com>,
	zhangxingcai <zhangxingcai@...wei.com>,
	"fengfuqiu@...wei.com" <fengfuqiu@...wei.com>,
	"tanhaijun@...wei.com" <tanhaijun@...wei.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mtd: fix: avoid race condition when accessing
 mtd->usecount

On Mon, May 11, 2015 at 07:44:26AM +0000, Cantavenera, Giuseppe (EXT-Other - DE/Ulm) wrote:
> > -----Original Message-----
> > From: ext Brian Norris [mailto:computersforpeace@...il.com]
> > Sent: Friday, May 08, 2015 2:27 AM
> > To: Cantavenera, Giuseppe (EXT-Other - DE/Ulm)
> > Cc: linux-mtd@...ts.infradead.org; Restelli, Lorenzo (EXT-Other -
> > DE/Ulm); dwmw2@...radead.org; stable@...r.kernel.org; Sverdlin,
> > Alexander (Nokia - DE/Ulm); zhangxingcai; fengfuqiu@...wei.com;
> > tanhaijun@...wei.com; linux-kernel@...r.kernel.org
> > Subject: Re: [PATCH] mtd: fix: avoid race condition when accessing mtd-
> > >usecount
> > 
> > On Thu, May 07, 2015 at 05:17:45PM -0700, Brian Norris wrote:
> > > On Thu, May 07, 2015 at 05:10:12PM -0700, Brian Norris wrote:
> > > > On Tue, Apr 21, 2015 at 12:20:22PM +0200, Giuseppe Cantavenera
> > wrote:
> > > > > @@ -484,7 +486,7 @@ int del_mtd_blktrans_dev(struct
> > mtd_blktrans_dev *old)
> > > > >  	if (old->open) {
> > > > >  		if (old->tr->release)
> > > > >  			old->tr->release(old);
> > > > > -		__put_mtd_device(old->mtd);
> > > > > +		put_mtd_device(old->mtd);
> > > >
> > > > This looks wrong. See:
> > > [...]
> > > > deregister_mtd_blktrans()
> > > > |_ mutex_lock(&mtd_table_mutex)
> > > > |_ tr->remove_dev() -> inftl_remove_dev()
> > > >    |_ del_mtd_blktrans_dev()
> > > >       |_ put_mtd_device()
> > > >          |_ mutex_lock(&mtd_table_mutex) <--- AA deadlock
> > >
> > > What's more, this code in del_mtd_blktrans_dev() makes it obvious
> > that
> > > this hunk is wrong:
> > >
> > > int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
> > > {
> > >         unsigned long flags;
> > >
> > >         if (mutex_trylock(&mtd_table_mutex)) {
> > >                 mutex_unlock(&mtd_table_mutex);
> > >                 BUG();
> > >         }
> > > 	...
> > >
> > > So rather than a comment, the code is showing that it's a BUG() to
> > not
> > > be holding mtd_table_mutex already.
> > 
> 
> Hello,
> Thanks for your comments and for pointing this out.
> Definitely yes.. we shouldn't change  del_mtd_blktrans_dev().
> 
> > As an alternative to your patch, how about the following?
> 
> I think it's the right way to go now.

Can I get a 'Tested-by', or at least an 'Acked-by' for the patch? I
tested it, but I don't think I can reproduce your original problem very
easily.

Brian
--
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