Skip to content

Commit 139c55f

Browse files
committed
Bluetooth: Fix potential use-after-free when clear keys
jira VULN-155797 cve CVE-2023-53386 commit-author Min Li <lm0963hack@gmail.com> commit 3673952 Similar to commit c5d2b6f ("Bluetooth: Fix use-after-free in hci_remove_ltk/hci_remove_irk"). We can not access k after kfree_rcu() call. Fixes: d7d4168 ("Bluetooth: Fix Suspicious RCU usage warnings") Signed-off-by: Min Li <lm0963hack@gmail.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> (cherry picked from commit 3673952) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 1591bb6 commit 139c55f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

net/bluetooth/hci_core.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,39 +2346,39 @@ void hci_uuids_clear(struct hci_dev *hdev)
23462346

23472347
void hci_link_keys_clear(struct hci_dev *hdev)
23482348
{
2349-
struct link_key *key;
2349+
struct link_key *key, *tmp;
23502350

2351-
list_for_each_entry(key, &hdev->link_keys, list) {
2351+
list_for_each_entry_safe(key, tmp, &hdev->link_keys, list) {
23522352
list_del_rcu(&key->list);
23532353
kfree_rcu(key, rcu);
23542354
}
23552355
}
23562356

23572357
void hci_smp_ltks_clear(struct hci_dev *hdev)
23582358
{
2359-
struct smp_ltk *k;
2359+
struct smp_ltk *k, *tmp;
23602360

2361-
list_for_each_entry(k, &hdev->long_term_keys, list) {
2361+
list_for_each_entry_safe(k, tmp, &hdev->long_term_keys, list) {
23622362
list_del_rcu(&k->list);
23632363
kfree_rcu(k, rcu);
23642364
}
23652365
}
23662366

23672367
void hci_smp_irks_clear(struct hci_dev *hdev)
23682368
{
2369-
struct smp_irk *k;
2369+
struct smp_irk *k, *tmp;
23702370

2371-
list_for_each_entry(k, &hdev->identity_resolving_keys, list) {
2371+
list_for_each_entry_safe(k, tmp, &hdev->identity_resolving_keys, list) {
23722372
list_del_rcu(&k->list);
23732373
kfree_rcu(k, rcu);
23742374
}
23752375
}
23762376

23772377
void hci_blocked_keys_clear(struct hci_dev *hdev)
23782378
{
2379-
struct blocked_key *b;
2379+
struct blocked_key *b, *tmp;
23802380

2381-
list_for_each_entry(b, &hdev->blocked_keys, list) {
2381+
list_for_each_entry_safe(b, tmp, &hdev->blocked_keys, list) {
23822382
list_del_rcu(&b->list);
23832383
kfree_rcu(b, rcu);
23842384
}

0 commit comments

Comments
 (0)