From: Takashi Iwai <tiwai@suse.de>
To: linux-bluetooth@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Nicolai Stange <nstange@suse.de>
Subject: Possible sleep-in-atomic in BT SCO code
Date: Fri, 10 Sep 2021 13:00:00 +0200 [thread overview]
Message-ID: <s5hilz8n1an.wl-tiwai@suse.de> (raw)
Hi,
while investigation of the recent BT fixes, Nicolai found out that the
change in the commit 27c24fda62b6 ("Bluetooth: switch to lock_sock in
SCO") may cause a sleep-in-atomic.
The commit replaced bh_lock_sock() with lock_sock(), which can sleep.
Meanwhile, in sco_conn_ready(), this is called after sco_conn_lock(),
and sco_conn_lock() is a simple spinlock. So this may lead to a
sleep-in-atomic.
I can imagine a fix like the below, but this also made us wonder
whether the sco_conn_lock() would be needed at all. In the code path,
conn->hcon won't be changed, right?
thanks,
Takashi
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -1118,18 +1118,22 @@ static void sco_conn_ready(struct sco_conn *conn)
return;
}
+ sock_hold(parent);
+ sco_conn_unlock(conn);
+
lock_sock(parent);
sk = sco_sock_alloc(sock_net(parent), NULL,
BTPROTO_SCO, GFP_ATOMIC, 0);
if (!sk) {
release_sock(parent);
- sco_conn_unlock(conn);
+ sock_put(parent);
return;
}
sco_sock_init(sk, parent);
+ sco_conn_lock(conn);
bacpy(&sco_pi(sk)->src, &conn->hcon->src);
bacpy(&sco_pi(sk)->dst, &conn->hcon->dst);
@@ -1143,10 +1147,10 @@ static void sco_conn_ready(struct sco_conn *conn)
/* Wake up parent */
parent->sk_data_ready(parent);
+ sco_conn_unlock(conn);
release_sock(parent);
-
- sco_conn_unlock(conn);
+ sock_put(parent);
}
}
reply other threads:[~2021-09-10 11:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=s5hilz8n1an.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nstange@suse.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 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®