From: Cen Zhang <zzzccc427@gmail.com>
To: marcel@holtmann.org, luiz.dentz@gmail.com
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
baijiaju1990@gmail.com, jjzuming@gmail.com, zzzccc427@gmail.com
Subject: [PATCH 0/4] Bluetooth: Keep borrowed keys inside RCU sections
Date: Thu, 29 Oct 2026 21:12:25 +0800 [thread overview]
Message-ID: <pm-bluetooth-objects-candidate-0122-v8-952ad9eb0ef59367ba6a-0@gmail.com> (raw)
hci_find_link_key(), hci_find_ltk() and hci_find_irk_by_addr() return
entries of RCU-protected lists after leaving their read-side sections.
Management clears and reloads these lists under hdev->lock, and
kfree_rcu() frees the old entries after a grace period. A user that
does not hold hdev->lock must therefore keep the returned entry inside
its own RCU read-side section until it has finished reading it.
Two such users have already been fixed this way in bluetooth-next by
commit 817cbcab91fe ("Bluetooth: hci_core: Keep RCU protection through
LTK filtering") and commit 4b76fa362110 ("Bluetooth: hci_sync: Protect
IRK identity reads with RCU").
This series applies the same approach to the remaining users that run
without hdev->lock:
1/4 hci_find_link_key() checks the blocked-key list after leaving
RCU, as hci_find_ltk() did before 817cbcab91fe.
2/4 sc_generate_ltk() derives an LTK from a borrowed link key.
3/4 smp_ltk_encrypt() starts encryption with a borrowed LTK.
4/4 hci_le_add_resolve_list_sync() copies a borrowed IRK, as
hci_le_set_privacy_mode_sync() did before 4b76fa362110.
The other callers either hold hdev->lock, which the management handlers
also take, or only test whether a key exists.
Each change only extends a read-side section over code that does not
sleep. Every section ends before a synchronous HCI command or a
GFP_KERNEL allocation. The patches are independent of each other.
Cen Zhang (4):
Bluetooth: hci_core: Keep link-key filtering inside RCU
Bluetooth: SMP: Protect link keys during LTK derivation
Bluetooth: SMP: Protect LTK encryption with RCU
Bluetooth: hci_sync: Copy the resolving-list IRK under RCU
net/bluetooth/hci_core.c | 5 ++---
net/bluetooth/hci_sync.c | 11 +++++++++--
net/bluetooth/smp.c | 29 +++++++++++++++++++++--------
3 files changed, 32 insertions(+), 13 deletions(-)
---
next reply other threads:[~2026-10-29 13:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 13:12 Cen Zhang [this message]
2026-10-29 13:12 ` [PATCH 1/4] Bluetooth: hci_core: Keep link-key filtering inside RCU Cen Zhang
2026-10-29 14:50 ` Bluetooth: Keep borrowed keys inside RCU sections bluez.test.bot
2026-10-29 13:12 ` [PATCH 2/4] Bluetooth: SMP: Protect link keys during LTK derivation Cen Zhang
2026-10-29 13:12 ` [PATCH 3/4] Bluetooth: SMP: Protect LTK encryption with RCU Cen Zhang
2026-10-29 13:12 ` [PATCH 4/4] Bluetooth: hci_sync: Copy the resolving-list IRK under RCU Cen Zhang
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=pm-bluetooth-objects-candidate-0122-v8-952ad9eb0ef59367ba6a-0@gmail.com \
--to=zzzccc427@gmail.com \
--cc=baijiaju1990@gmail.com \
--cc=jjzuming@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.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