mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: "Cantavenera,
	Giuseppe (EXT-Other - DE/Ulm)" 
	<giuseppe.cantavenera.ext@nokia.com>
Cc: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"Restelli,
	Lorenzo (EXT-Other - DE/Ulm)"  <lorenzo.restelli.ext@nokia.com>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	"Sverdlin,
	Alexander (Nokia - DE/Ulm)" <alexander.sverdlin@nokia.com>,
	zhangxingcai <zhangxingcai@huawei.com>,
	"fengfuqiu@huawei.com" <fengfuqiu@huawei.com>,
	"tanhaijun@huawei.com" <tanhaijun@huawei.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mtd: fix: avoid race condition when accessing mtd->usecount
Date: Mon, 11 May 2015 15:25:05 -0700	[thread overview]
Message-ID: <20150511222505.GI32500@ld-irv-0074> (raw)
In-Reply-To: <362FEC998FA6CC42BC5BA5B7BA75E0970D5A08FA@DEMUMBX009.nsn-intra.net>

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@gmail.com]
> > Sent: Friday, May 08, 2015 2:27 AM
> > To: Cantavenera, Giuseppe (EXT-Other - DE/Ulm)
> > Cc: linux-mtd@lists.infradead.org; Restelli, Lorenzo (EXT-Other -
> > DE/Ulm); dwmw2@infradead.org; stable@vger.kernel.org; Sverdlin,
> > Alexander (Nokia - DE/Ulm); zhangxingcai; fengfuqiu@huawei.com;
> > tanhaijun@huawei.com; linux-kernel@vger.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

  reply	other threads:[~2015-05-11 22:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1429611622-2652-1-git-send-email-giuseppe.cantavenera.ext@nokia.com>
     [not found] ` <20150508001012.GV32500@ld-irv-0074>
     [not found]   ` <20150508001745.GW32500@ld-irv-0074>
2015-05-08  0:26     ` Brian Norris
2015-05-11  7:44       ` Cantavenera, Giuseppe (EXT-Other - DE/Ulm)
2015-05-11 22:25         ` Brian Norris [this message]
2015-05-12  6:38           ` Cantavenera, Giuseppe (EXT-Other - DE/Ulm)
2015-05-12 18:04             ` Brian Norris
2015-05-12 16:37       ` Alexander Sverdlin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150511222505.GI32500@ld-irv-0074 \
    --to=computersforpeace@gmail.com \
    --cc=alexander.sverdlin@nokia.com \
    --cc=dwmw2@infradead.org \
    --cc=fengfuqiu@huawei.com \
    --cc=giuseppe.cantavenera.ext@nokia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=lorenzo.restelli.ext@nokia.com \
    --cc=stable@vger.kernel.org \
    --cc=tanhaijun@huawei.com \
    --cc=zhangxingcai@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®