mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
Bluetooth: msft: fix slab-use-after-free in msft_do_close()
[ Upstream commit 10f9f426ac6e752c8d87bf4346930ba347aaabac ]
Tying the msft->data lifetime to hdev by freeing it in
hci_release_dev() to fix the following case:
[use]
msft_do_close()
msft = hdev->msft_data;
if (!msft) ...(1) <- passed.
return;
mutex_lock(&msft->filter_lock); ...(4) <- used after freed.
[free]
msft_unregister()
msft = hdev->msft_data;
hdev->msft_data = NULL; ...(2)
kfree(msft); ...(3) <- msft is freed.
==================================================================
BUG: KASAN: slab-use-after-free in __mutex_lock_common
kernel/locking/mutex.c:587 [inline]
BUG: KASAN: slab-use-after-free in __mutex_lock+0x8f/0xc30
kernel/locking/mutex.c:752
Read of size 8 at addr ffff888106cbbca8 by task kworker/u5:2/309
Fixes: bf6a4e30ff
("Bluetooth: disable advertisement filters during suspend")
Signed-off-by: Sungwoo Kim <iam@sung-woo.kim>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
012363cb1b
commit
a85a60e623
3 changed files with 4 additions and 5 deletions
|
@ -2736,8 +2736,6 @@ void hci_unregister_dev(struct hci_dev *hdev)
|
||||||
|
|
||||||
hci_unregister_suspend_notifier(hdev);
|
hci_unregister_suspend_notifier(hdev);
|
||||||
|
|
||||||
msft_unregister(hdev);
|
|
||||||
|
|
||||||
hci_dev_do_close(hdev);
|
hci_dev_do_close(hdev);
|
||||||
|
|
||||||
if (!test_bit(HCI_INIT, &hdev->flags) &&
|
if (!test_bit(HCI_INIT, &hdev->flags) &&
|
||||||
|
@ -2791,6 +2789,7 @@ void hci_release_dev(struct hci_dev *hdev)
|
||||||
hci_discovery_filter_clear(hdev);
|
hci_discovery_filter_clear(hdev);
|
||||||
hci_blocked_keys_clear(hdev);
|
hci_blocked_keys_clear(hdev);
|
||||||
hci_codec_list_clear(&hdev->local_codecs);
|
hci_codec_list_clear(&hdev->local_codecs);
|
||||||
|
msft_release(hdev);
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock(hdev);
|
||||||
|
|
||||||
ida_destroy(&hdev->unset_handle_ida);
|
ida_destroy(&hdev->unset_handle_ida);
|
||||||
|
|
|
@ -769,7 +769,7 @@ void msft_register(struct hci_dev *hdev)
|
||||||
mutex_init(&msft->filter_lock);
|
mutex_init(&msft->filter_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void msft_unregister(struct hci_dev *hdev)
|
void msft_release(struct hci_dev *hdev)
|
||||||
{
|
{
|
||||||
struct msft_data *msft = hdev->msft_data;
|
struct msft_data *msft = hdev->msft_data;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
bool msft_monitor_supported(struct hci_dev *hdev);
|
bool msft_monitor_supported(struct hci_dev *hdev);
|
||||||
void msft_register(struct hci_dev *hdev);
|
void msft_register(struct hci_dev *hdev);
|
||||||
void msft_unregister(struct hci_dev *hdev);
|
void msft_release(struct hci_dev *hdev);
|
||||||
void msft_do_open(struct hci_dev *hdev);
|
void msft_do_open(struct hci_dev *hdev);
|
||||||
void msft_do_close(struct hci_dev *hdev);
|
void msft_do_close(struct hci_dev *hdev);
|
||||||
void msft_vendor_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb);
|
void msft_vendor_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb);
|
||||||
|
@ -35,7 +35,7 @@ static inline bool msft_monitor_supported(struct hci_dev *hdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void msft_register(struct hci_dev *hdev) {}
|
static inline void msft_register(struct hci_dev *hdev) {}
|
||||||
static inline void msft_unregister(struct hci_dev *hdev) {}
|
static inline void msft_release(struct hci_dev *hdev) {}
|
||||||
static inline void msft_do_open(struct hci_dev *hdev) {}
|
static inline void msft_do_open(struct hci_dev *hdev) {}
|
||||||
static inline void msft_do_close(struct hci_dev *hdev) {}
|
static inline void msft_do_close(struct hci_dev *hdev) {}
|
||||||
static inline void msft_vendor_evt(struct hci_dev *hdev, void *data,
|
static inline void msft_vendor_evt(struct hci_dev *hdev, void *data,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue