All of lore.kernel.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: Richard Weinberger <richard@nod.at>
Cc: linux-mtd@lists.infradead.org, computersforpeace@gmail.com,
	dwmw2@infradead.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] UBI: Fix possible deadlock in erase_worker()
Date: Wed, 17 Sep 2014 11:28:27 +0300	[thread overview]
Message-ID: <1410942507.28850.78.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <1410853702-11616-1-git-send-email-richard@nod.at>

On Tue, 2014-09-16 at 09:48 +0200, Richard Weinberger wrote:
> If sync_erase() failes with EINTR, ENOMEM, EAGAIN or
> EBUSY erase_worker() re-schedules the failed work.
> This will lead to a deadlock because erase_worker() is called
> with work_sem held in read mode. And schedule_erase() will take
> this lock again.

IIRC, the assumption was that the R/W semaphore may be taken in read
mode many times, so it wouldn't hurt to do:

down_read()
down_read()
up_read()
up_read()

If this is right, then the lockdep warning is incorrect.

-- 
Best Regards,
Artem Bityutskiy

WARNING: multiple messages have this Message-ID (diff)
From: Artem Bityutskiy <dedekind1@gmail.com>
To: Richard Weinberger <richard@nod.at>
Cc: dwmw2@infradead.org, computersforpeace@gmail.com,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] UBI: Fix possible deadlock in erase_worker()
Date: Wed, 17 Sep 2014 11:28:27 +0300	[thread overview]
Message-ID: <1410942507.28850.78.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <1410853702-11616-1-git-send-email-richard@nod.at>

On Tue, 2014-09-16 at 09:48 +0200, Richard Weinberger wrote:
> If sync_erase() failes with EINTR, ENOMEM, EAGAIN or
> EBUSY erase_worker() re-schedules the failed work.
> This will lead to a deadlock because erase_worker() is called
> with work_sem held in read mode. And schedule_erase() will take
> this lock again.

IIRC, the assumption was that the R/W semaphore may be taken in read
mode many times, so it wouldn't hurt to do:

down_read()
down_read()
up_read()
up_read()

If this is right, then the lockdep warning is incorrect.

-- 
Best Regards,
Artem Bityutskiy


  reply	other threads:[~2014-09-17  8:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16  7:48 [PATCH] UBI: Fix possible deadlock in erase_worker() Richard Weinberger
2014-09-16  7:48 ` Richard Weinberger
2014-09-17  8:28 ` Artem Bityutskiy [this message]
2014-09-17  8:28   ` Artem Bityutskiy
2014-09-17  8:40   ` Richard Weinberger
2014-09-17  8:40     ` Richard Weinberger
2014-09-17  8:43     ` Artem Bityutskiy
2014-09-17  8:43       ` Artem Bityutskiy
2014-09-17  9:35 ` Artem Bityutskiy
2014-09-17  9:35   ` Artem Bityutskiy
2014-09-19  9:46   ` Richard Weinberger
2014-09-19  9:46     ` Richard Weinberger
2014-09-19 10:47     ` Artem Bityutskiy
2014-09-19 10:47       ` Artem Bityutskiy
2014-09-19 11:01       ` Richard Weinberger
2014-09-19 11:01         ` Richard Weinberger

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=1410942507.28850.78.camel@sauron.fi.intel.com \
    --to=dedekind1@gmail.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.