From: Mart van de Wege <mvdwege@gmail.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Marcel Holtmann <marcel@holtmann.org>,
Johan Hedberg <johan.hedberg@intel.com>,
Gustavo Padovan <gustavo@padovan.org>,
linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rt-users@vger.kernel.org, tglx@linutronix.de,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] Bluetooth: avoid recursive locking in hci_send_to_channel()
Date: Sun, 24 Sep 2017 16:53:54 +0200 [thread overview]
Message-ID: <20170924165354.33a5da4d@gmail.com> (raw)
In-Reply-To: <20170921135123.rgzacdgfonqftlu7@linutronix.de>
Confirm that 4.11.12-rt14 with this fix boots normally.
On Thu, 21 Sep 2017 15:51:23 +0200
Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> Mart reported a deadlock in -RT in the call path:
> hci_send_monitor_ctrl_event() -> hci_send_to_channel()
>
> because both functions acquire the same read lock hci_sk_list.lock.
> This is also a mainline issue because the qrwlock implementation is
> writer fair (the traditional rwlock implementation is reader biased).
>
> To avoid the deadlock there is now __hci_send_to_channel() which
> expects the readlock to be held.
>
> Cc: Marcel Holtmann <marcel@holtmann.org>
> Cc: Johan Hedberg <johan.hedberg@intel.com>
> Fixes: 38ceaa00d02d ("Bluetooth: Add support for sending MGMT
> commands and events to monitor") Reported-by: Mart van de Wege
> <mvdwege@gmail.com> Signed-off-by: Sebastian Andrzej Siewior
> <bigeasy@linutronix.de> ---
> net/bluetooth/hci_sock.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
> index 638bf0e1a2e3..f1ee820d871c 100644
> --- a/net/bluetooth/hci_sock.c
> +++ b/net/bluetooth/hci_sock.c
> @@ -251,15 +251,13 @@ void hci_send_to_sock(struct hci_dev *hdev,
> struct sk_buff *skb) }
>
> /* Send frame to sockets with specific channel */
> -void hci_send_to_channel(unsigned short channel, struct sk_buff *skb,
> - int flag, struct sock *skip_sk)
> +static void __hci_send_to_channel(unsigned short channel, struct
> sk_buff *skb,
> + int flag, struct sock *skip_sk)
> {
> struct sock *sk;
>
> BT_DBG("channel %u len %d", channel, skb->len);
>
> - read_lock(&hci_sk_list.lock);
> -
> sk_for_each(sk, &hci_sk_list.head) {
> struct sk_buff *nskb;
>
> @@ -285,6 +283,13 @@ void hci_send_to_channel(unsigned short channel,
> struct sk_buff *skb, kfree_skb(nskb);
> }
>
> +}
> +
> +void hci_send_to_channel(unsigned short channel, struct sk_buff *skb,
> + int flag, struct sock *skip_sk)
> +{
> + read_lock(&hci_sk_list.lock);
> + __hci_send_to_channel(channel, skb, flag, skip_sk);
> read_unlock(&hci_sk_list.lock);
> }
>
> @@ -388,8 +393,8 @@ void hci_send_monitor_ctrl_event(struct hci_dev
> *hdev, u16 event, hdr->index = index;
> hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE);
>
> - hci_send_to_channel(HCI_CHANNEL_MONITOR, skb,
> - HCI_SOCK_TRUSTED, NULL);
> + __hci_send_to_channel(HCI_CHANNEL_MONITOR, skb,
> + HCI_SOCK_TRUSTED, NULL);
> kfree_skb(skb);
> }
>
WARNING: multiple messages have this Message-ID (diff)
From: Mart van de Wege <mvdwege-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Sebastian Andrzej Siewior
<bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Cc: Marcel Holtmann <marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>,
Johan Hedberg
<johan.hedberg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Gustavo Padovan <gustavo-THi1TnShQwVAfugRpC6u6w@public.gmane.org>,
linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rt-users-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
Peter Zijlstra <peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
Subject: Re: [PATCH] Bluetooth: avoid recursive locking in hci_send_to_channel()
Date: Sun, 24 Sep 2017 16:53:54 +0200 [thread overview]
Message-ID: <20170924165354.33a5da4d@gmail.com> (raw)
In-Reply-To: <20170921135123.rgzacdgfonqftlu7-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Confirm that 4.11.12-rt14 with this fix boots normally.
On Thu, 21 Sep 2017 15:51:23 +0200
Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> wrote:
> Mart reported a deadlock in -RT in the call path:
> hci_send_monitor_ctrl_event() -> hci_send_to_channel()
>
> because both functions acquire the same read lock hci_sk_list.lock.
> This is also a mainline issue because the qrwlock implementation is
> writer fair (the traditional rwlock implementation is reader biased).
>
> To avoid the deadlock there is now __hci_send_to_channel() which
> expects the readlock to be held.
>
> Cc: Marcel Holtmann <marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>
> Cc: Johan Hedberg <johan.hedberg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Fixes: 38ceaa00d02d ("Bluetooth: Add support for sending MGMT
> commands and events to monitor") Reported-by: Mart van de Wege
> <mvdwege-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Signed-off-by: Sebastian Andrzej Siewior
> <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> ---
> net/bluetooth/hci_sock.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
> index 638bf0e1a2e3..f1ee820d871c 100644
> --- a/net/bluetooth/hci_sock.c
> +++ b/net/bluetooth/hci_sock.c
> @@ -251,15 +251,13 @@ void hci_send_to_sock(struct hci_dev *hdev,
> struct sk_buff *skb) }
>
> /* Send frame to sockets with specific channel */
> -void hci_send_to_channel(unsigned short channel, struct sk_buff *skb,
> - int flag, struct sock *skip_sk)
> +static void __hci_send_to_channel(unsigned short channel, struct
> sk_buff *skb,
> + int flag, struct sock *skip_sk)
> {
> struct sock *sk;
>
> BT_DBG("channel %u len %d", channel, skb->len);
>
> - read_lock(&hci_sk_list.lock);
> -
> sk_for_each(sk, &hci_sk_list.head) {
> struct sk_buff *nskb;
>
> @@ -285,6 +283,13 @@ void hci_send_to_channel(unsigned short channel,
> struct sk_buff *skb, kfree_skb(nskb);
> }
>
> +}
> +
> +void hci_send_to_channel(unsigned short channel, struct sk_buff *skb,
> + int flag, struct sock *skip_sk)
> +{
> + read_lock(&hci_sk_list.lock);
> + __hci_send_to_channel(channel, skb, flag, skip_sk);
> read_unlock(&hci_sk_list.lock);
> }
>
> @@ -388,8 +393,8 @@ void hci_send_monitor_ctrl_event(struct hci_dev
> *hdev, u16 event, hdr->index = index;
> hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE);
>
> - hci_send_to_channel(HCI_CHANNEL_MONITOR, skb,
> - HCI_SOCK_TRUSTED, NULL);
> + __hci_send_to_channel(HCI_CHANNEL_MONITOR, skb,
> + HCI_SOCK_TRUSTED, NULL);
> kfree_skb(skb);
> }
>
next prev parent reply other threads:[~2017-09-24 14:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-30 21:25 kernel BUG at kernel/locking/rtmutex.c:1059 Mart van de Wege
2017-08-31 10:59 ` Pratyush Patel
2017-08-31 14:54 ` Sebastian Andrzej Siewior
2017-08-31 16:02 ` Pratyush Patel
2017-08-31 14:52 ` Possible BT deadlock due to recursive read locking (Was: Re: kernel BUG at kernel/locking/rtmutex.c:1059) Sebastian Andrzej Siewior
2017-08-31 14:56 ` Thomas Gleixner
2017-09-01 8:51 ` Mart van de Wege
2017-09-02 7:27 ` Mart van de Wege
2017-09-02 7:27 ` Mart van de Wege
2017-09-02 7:27 ` Mart van de Wege
2017-09-21 13:51 ` [PATCH] Bluetooth: avoid recursive locking in hci_send_to_channel() Sebastian Andrzej Siewior
2017-09-24 14:53 ` Mart van de Wege [this message]
2017-09-24 14:53 ` Mart van de Wege
2017-10-30 8:05 ` Marcel Holtmann
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=20170924165354.33a5da4d@gmail.com \
--to=mvdwege@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=gustavo@padovan.org \
--cc=johan.hedberg@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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.