Skip to content

Commit 223a7c8

Browse files
committed
Bluetooth: Fix potential use-after-free when clear keys
jira VULN-155796 jira VULN-155795 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 5f174e1 commit 223a7c8

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
@@ -1054,39 +1054,39 @@ void hci_uuids_clear(struct hci_dev *hdev)
10541054

10551055
void hci_link_keys_clear(struct hci_dev *hdev)
10561056
{
1057-
struct link_key *key;
1057+
struct link_key *key, *tmp;
10581058

1059-
list_for_each_entry(key, &hdev->link_keys, list) {
1059+
list_for_each_entry_safe(key, tmp, &hdev->link_keys, list) {
10601060
list_del_rcu(&key->list);
10611061
kfree_rcu(key, rcu);
10621062
}
10631063
}
10641064

10651065
void hci_smp_ltks_clear(struct hci_dev *hdev)
10661066
{
1067-
struct smp_ltk *k;
1067+
struct smp_ltk *k, *tmp;
10681068

1069-
list_for_each_entry(k, &hdev->long_term_keys, list) {
1069+
list_for_each_entry_safe(k, tmp, &hdev->long_term_keys, list) {
10701070
list_del_rcu(&k->list);
10711071
kfree_rcu(k, rcu);
10721072
}
10731073
}
10741074

10751075
void hci_smp_irks_clear(struct hci_dev *hdev)
10761076
{
1077-
struct smp_irk *k;
1077+
struct smp_irk *k, *tmp;
10781078

1079-
list_for_each_entry(k, &hdev->identity_resolving_keys, list) {
1079+
list_for_each_entry_safe(k, tmp, &hdev->identity_resolving_keys, list) {
10801080
list_del_rcu(&k->list);
10811081
kfree_rcu(k, rcu);
10821082
}
10831083
}
10841084

10851085
void hci_blocked_keys_clear(struct hci_dev *hdev)
10861086
{
1087-
struct blocked_key *b;
1087+
struct blocked_key *b, *tmp;
10881088

1089-
list_for_each_entry(b, &hdev->blocked_keys, list) {
1089+
list_for_each_entry_safe(b, tmp, &hdev->blocked_keys, list) {
10901090
list_del_rcu(&b->list);
10911091
kfree_rcu(b, rcu);
10921092
}

0 commit comments

Comments
 (0)