From: Pauli Virtanen <pav@iki.fi>
To: linux-bluetooth@vger.kernel.org
Cc: Pauli Virtanen <pav@iki.fi>,
marcel@holtmann.org, luiz.dentz@gmail.com, oss@fourdim.xyz,
linux-kernel@vger.kernel.org
Subject: [PATCH v5 3/7] Bluetooth: hci_sync: hold conn in hci_connect_big_sync() callback
Date: Sat, 25 Jul 2026 12:59:19 +0300 [thread overview]
Message-ID: <ce281a9415e997ae35fbacbd92e73034ca3083ba.1784973264.git.pav@iki.fi> (raw)
In-Reply-To: <cover.1784973264.git.pav@iki.fi>
There is theoretical UAF if the conn is freed while the hci_sync task is
running.
Hold refcount to avoid that. Handle NULL hcon, return 0 + do nothing to
match the previous behavior.
Fixes: 024421cf3992 ("Bluetooth: hci_conn: Fix not setting timeout for BIG Create Sync")
Signed-off-by: Pauli Virtanen <pav@iki.fi>
---
Notes:
v5:
- clear_bit() without hci_conn_valid check, we hold reference
v4:
- check for conn == NULL before hci_conn_get(), since it appears
iso.c may end up calling this with NULL
v3:
- split to multiple patches per different Fixes:
- hold RCU instead of hdev->lock
net/bluetooth/hci_sync.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 83efca415eaf..5610ef00fd0f 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -7498,10 +7498,12 @@ static void create_big_complete(struct hci_dev *hdev, void *data, int err)
bt_dev_dbg(hdev, "err %d", err);
if (err == -ECANCELED)
- return;
+ goto done;
- if (hci_conn_valid(hdev, conn))
- clear_bit(HCI_CONN_CREATE_BIG_SYNC, &conn->flags);
+ clear_bit(HCI_CONN_CREATE_BIG_SYNC, &conn->flags);
+
+done:
+ hci_conn_put(conn);
}
static int hci_le_big_create_sync(struct hci_dev *hdev, void *data)
@@ -7553,8 +7555,14 @@ int hci_connect_big_sync(struct hci_dev *hdev, struct hci_conn *conn)
{
int err;
- err = hci_cmd_sync_queue_once(hdev, hci_le_big_create_sync, conn,
+ if (!conn)
+ return 0;
+
+ err = hci_cmd_sync_queue_once(hdev, hci_le_big_create_sync,
+ hci_conn_get(conn),
create_big_complete);
+ if (err)
+ hci_conn_put(conn);
return (err == -EEXIST) ? 0 : err;
}
--
2.55.0
next prev parent reply other threads:[~2026-07-25 9:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 9:59 [PATCH v5 0/7] Bluetooth: hci_conn: hold conn references in hci_sync tasks Pauli Virtanen
2026-07-25 9:59 ` [PATCH v5 1/7] Bluetooth: hci_conn: hold conn reference in abort_conn_sync() Pauli Virtanen
2026-07-25 9:59 ` [PATCH v5 2/7] Bluetooth: hci_sync: hold conn in hci_connect_acl/le_sync() callbacks Pauli Virtanen
2026-07-25 9:59 ` Pauli Virtanen [this message]
2026-07-25 9:59 ` [PATCH v5 4/7] Bluetooth: hci_sync: hold conn in hci_connect_pa_sync() callback Pauli Virtanen
2026-07-25 9:59 ` [PATCH v5 5/7] Bluetooth: hci_sync: hold conn in hci_past_sync() callback Pauli Virtanen
2026-07-25 9:59 ` [PATCH v5 6/7] Bluetooth: hci_sync: fix hci_conn_del() use in hci_le_create_conn_sync Pauli Virtanen
2026-07-25 9:59 ` [PATCH v5 7/7] Bluetooth: hci_sync: remove unnecessary hci_conn_get in create_conn_sync Pauli Virtanen
2026-07-27 19:00 ` [PATCH v5 0/7] Bluetooth: hci_conn: hold conn references in hci_sync tasks patchwork-bot+bluetooth
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=ce281a9415e997ae35fbacbd92e73034ca3083ba.1784973264.git.pav@iki.fi \
--to=pav@iki.fi \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=oss@fourdim.xyz \
/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®