From: Marcel Holtmann <marcel@holtmann.org>
To: Dave Young <hidave.darkstar@gmail.com>
Cc: davem@davemloft.net, arjan@linux.intel.com,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH][resend] rfcomm deadlock fix
Date: Sun, 1 Jun 2008 09:06:22 +0200 [thread overview]
Message-ID: <11DE897D-FD47-4F22-9F12-FE258B30D000@holtmann.org> (raw)
In-Reply-To: <20080601013410.GA3600@darkstar.domain.name>
Hi Dave,
> There's logic in __rfcomm_dlc_close:
> rfcomm_dlc_lock(d);
> d->state = BT_CLOSED;
> d->state_changed(d, err);
> rfcomm_dlc_unlock(d);
>
> In rfcomm_dev_state_change, it's possible that rfcomm_dev_put try to
> take the
> dlc lock, then we will deadlock.
>
> Here fixed it by unlock dlc before rfcomm_dev_get in
> rfcomm_dev_state_change.
>
> why not unlock just before rfcomm_dev_put? it's because there's
> another problem.
> rfcomm_dev_get/rfcomm_dev_del will take rfcomm_dev_lock, but in
> rfcomm_dev_add
> the lock order is : rfcomm_dev_lock --> dlc lock
>
> so I unlock dlc before the taken of rfcomm_dev_lock.
>
> Actually it's a regression caused by commit
> 1905f6c736cb618e07eca0c96e60e3c024023428, the dlc state_change could
> be two
> callbacks : rfcomm_sk_state_change and rfcomm_dev_state_change. I
> missed the rfcomm_sk_state_change that time.
>
> Thanks Arjan van de Ven <arjan@linux.intel.com> for the effort in
> commit
> 4c8411f8c115def968820a4df6658ccfd55d7f1a
> but he missed the rfcomm_dev_state_change lock issue.
>
> Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
>
> ---
> net/bluetooth/rfcomm/tty.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff -upr linux/net/bluetooth/rfcomm/tty.c linux.new/net/bluetooth/
> rfcomm/tty.c
> --- linux/net/bluetooth/rfcomm/tty.c 2008-05-30 15:46:33.000000000
> +0800
> +++ linux.new/net/bluetooth/rfcomm/tty.c 2008-05-30
> 17:08:30.000000000 +0800
> @@ -566,11 +566,22 @@ static void rfcomm_dev_state_change(stru
> if (dlc->state == BT_CLOSED) {
> if (!dev->tty) {
> if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) {
> - if (rfcomm_dev_get(dev->id) == NULL)
> + /* Drop DLC lock here to avoid deadlock
> + * 1. rfcomm_dev_get will take rfcomm_dev_lock
> + * but in rfcomm_dev_add there's lock order:
> + * rfcomm_dev_lock -> dlc lock
> + * 2. rfcomm_dev_put will deaklock if it's
> + * the last reference
I meant this one :) s/deaklock/deadlock/
Regards
Marcel
next prev parent reply other threads:[~2008-06-01 7:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-01 1:34 [PATCH][resend] rfcomm deadlock fix Dave Young
2008-06-01 7:06 ` Marcel Holtmann [this message]
2008-06-02 1:45 ` Dave Young
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=11DE897D-FD47-4F22-9F12-FE258B30D000@holtmann.org \
--to=marcel@holtmann.org \
--cc=akpm@linux-foundation.org \
--cc=arjan@linux.intel.com \
--cc=davem@davemloft.net \
--cc=hidave.darkstar@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@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.