Skip to content

Commit ab4b0b0

Browse files
committed
Bluetooth: Fix potential use-after-free when clear keys
jira LE-4623 cve CVE-2023-53386 Rebuild_History Non-Buildable kernel-4.18.0-553.81.1.el8_10 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 d3cf1f7 commit ab4b0b0

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

10731073
void hci_link_keys_clear(struct hci_dev *hdev)
10741074
{
1075-
struct link_key *key;
1075+
struct link_key *key, *tmp;
10761076

1077-
list_for_each_entry(key, &hdev->link_keys, list) {
1077+
list_for_each_entry_safe(key, tmp, &hdev->link_keys, list) {
10781078
list_del_rcu(&key->list);
10791079
kfree_rcu(key, rcu);
10801080
}
10811081
}
10821082

10831083
void hci_smp_ltks_clear(struct hci_dev *hdev)
10841084
{
1085-
struct smp_ltk *k;
1085+
struct smp_ltk *k, *tmp;
10861086

1087-
list_for_each_entry(k, &hdev->long_term_keys, list) {
1087+
list_for_each_entry_safe(k, tmp, &hdev->long_term_keys, list) {
10881088
list_del_rcu(&k->list);
10891089
kfree_rcu(k, rcu);
10901090
}
10911091
}
10921092

10931093
void hci_smp_irks_clear(struct hci_dev *hdev)
10941094
{
1095-
struct smp_irk *k;
1095+
struct smp_irk *k, *tmp;
10961096

1097-
list_for_each_entry(k, &hdev->identity_resolving_keys, list) {
1097+
list_for_each_entry_safe(k, tmp, &hdev->identity_resolving_keys, list) {
10981098
list_del_rcu(&k->list);
10991099
kfree_rcu(k, rcu);
11001100
}
11011101
}
11021102

11031103
void hci_blocked_keys_clear(struct hci_dev *hdev)
11041104
{
1105-
struct blocked_key *b;
1105+
struct blocked_key *b, *tmp;
11061106

1107-
list_for_each_entry(b, &hdev->blocked_keys, list) {
1107+
list_for_each_entry_safe(b, tmp, &hdev->blocked_keys, list) {
11081108
list_del_rcu(&b->list);
11091109
kfree_rcu(b, rcu);
11101110
}

0 commit comments

Comments
 (0)