Skip to content

Commit bff6dd6

Browse files
Bluetooth: Fix potential use-after-free when clear keys
jira VULN-155798 cve CVE-2023-53386 commit-author Min Li <[email protected]> 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 <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]> (cherry picked from commit 3673952) Signed-off-by: Shreeya Patel <[email protected]>
1 parent 4dd33aa commit bff6dd6

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

10751075
void hci_link_keys_clear(struct hci_dev *hdev)
10761076
{
1077-
struct link_key *key;
1077+
struct link_key *key, *tmp;
10781078

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

10851085
void hci_smp_ltks_clear(struct hci_dev *hdev)
10861086
{
1087-
struct smp_ltk *k;
1087+
struct smp_ltk *k, *tmp;
10881088

1089-
list_for_each_entry(k, &hdev->long_term_keys, list) {
1089+
list_for_each_entry_safe(k, tmp, &hdev->long_term_keys, list) {
10901090
list_del_rcu(&k->list);
10911091
kfree_rcu(k, rcu);
10921092
}
10931093
}
10941094

10951095
void hci_smp_irks_clear(struct hci_dev *hdev)
10961096
{
1097-
struct smp_irk *k;
1097+
struct smp_irk *k, *tmp;
10981098

1099-
list_for_each_entry(k, &hdev->identity_resolving_keys, list) {
1099+
list_for_each_entry_safe(k, tmp, &hdev->identity_resolving_keys, list) {
11001100
list_del_rcu(&k->list);
11011101
kfree_rcu(k, rcu);
11021102
}
11031103
}
11041104

11051105
void hci_blocked_keys_clear(struct hci_dev *hdev)
11061106
{
1107-
struct blocked_key *b;
1107+
struct blocked_key *b, *tmp;
11081108

1109-
list_for_each_entry(b, &hdev->blocked_keys, list) {
1109+
list_for_each_entry_safe(b, tmp, &hdev->blocked_keys, list) {
11101110
list_del_rcu(&b->list);
11111111
kfree_rcu(b, rcu);
11121112
}

0 commit comments

Comments
 (0)