From: SeungJu Cheon <suunj1331@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: marcel@holtmann.org, luiz.dentz@gmail.com,
johan.hedberg@intel.com, linux-kernel@vger.kernel.org,
me@brighamcampbell.com, shuah@kernel.org,
linux-kernel-mentees@lists.linux.dev,
SeungJu Cheon <suunj1331@gmail.com>
Subject: [PATCH] Bluetooth: hci_event: reject incoming conn request when MASTER conn exists
Date: Fri, 10 Apr 2026 19:42:22 +0900 [thread overview]
Message-ID: <20260410104222.537901-1-suunj1331@gmail.com> (raw)
hci_conn_request_evt() reuses an existing connection without checking
its role. When the existing connection has the MASTER role (outgoing
connection in progress), conn->state is incorrectly overwritten from
BT_CONNECTED or BT_OPEN to BT_CONNECT, causing state machine corruption.
This can lead to use-after-free or state confusion when the connection
is later disconnected.
The issue was observed during VHCI testing:
Thread 1: Local connect() -> conn created (role=MASTER, state=BT_OPEN)
Thread 2: Remote Connection Request received
-> hci_conn_hash_lookup_ba() finds existing MASTER conn
-> conn->state overwritten to BT_CONNECT (no role check!)
Fix by rejecting incoming connection requests when a MASTER connection
to the same address already exists.
Fixes: 70c464256310 ("Bluetooth: Refactor connection request handling")
Signed-off-by: SeungJu Cheon <suunj1331@gmail.com>
---
net/bluetooth/hci_event.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 286529d2e554..3d34cf2e5067 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3327,6 +3327,12 @@ static void hci_conn_request_evt(struct hci_dev *hdev, void *data,
bt_dev_err(hdev, "connection err: %ld", PTR_ERR(conn));
goto unlock;
}
+ } else if (conn->role == HCI_ROLE_MASTER) {
+ /* Reject incoming request when outgoing connection to
+ * the same device is already in progress.
+ */
+ hci_reject_conn(hdev, &ev->bdaddr);
+ goto unlock;
}
memcpy(conn->dev_class, ev->dev_class, 3);
--
2.52.0
reply other threads:[~2026-04-10 10:42 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=20260410104222.537901-1-suunj1331@gmail.com \
--to=suunj1331@gmail.com \
--cc=johan.hedberg@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=me@brighamcampbell.com \
--cc=shuah@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox