mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
Bluetooth: Fix use-after-free in hci_remove_ltk/hci_remove_irk
commitc5d2b6fa26upstream. Similar to commit0f7d9b31ce("netfilter: nf_tables: fix use-after-free in nft_set_catchall_destroy()"). We can not access k after kfree_rcu() call. Cc: stable@vger.kernel.org Signed-off-by: Min Li <lm0963hack@gmail.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
76b40319a1
commit
2270e32bd1
@@ -2685,10 +2685,10 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
|
|||||||
|
|
||||||
int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type)
|
int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type)
|
||||||
{
|
{
|
||||||
struct smp_ltk *k;
|
struct smp_ltk *k, *tmp;
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
|
|
||||||
list_for_each_entry_rcu(k, &hdev->long_term_keys, list) {
|
list_for_each_entry_safe(k, tmp, &hdev->long_term_keys, list) {
|
||||||
if (bacmp(bdaddr, &k->bdaddr) || k->bdaddr_type != bdaddr_type)
|
if (bacmp(bdaddr, &k->bdaddr) || k->bdaddr_type != bdaddr_type)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -2704,9 +2704,9 @@ int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type)
|
|||||||
|
|
||||||
void hci_remove_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type)
|
void hci_remove_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type)
|
||||||
{
|
{
|
||||||
struct smp_irk *k;
|
struct smp_irk *k, *tmp;
|
||||||
|
|
||||||
list_for_each_entry_rcu(k, &hdev->identity_resolving_keys, list) {
|
list_for_each_entry_safe(k, tmp, &hdev->identity_resolving_keys, list) {
|
||||||
if (bacmp(bdaddr, &k->bdaddr) || k->addr_type != addr_type)
|
if (bacmp(bdaddr, &k->bdaddr) || k->addr_type != addr_type)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user