Message ID | 20250114174532.3263274-1-luiz.dentz@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 1f2ae3fb1cdc552b38e625fa807800ffbb858ce3 |
Headers | show |
Series | [v1] Bluetooth: MGMT: Fix slab-use-after-free Read in mgmt_remove_adv_monitor_sync | expand |
Hello: This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>: On Tue, 14 Jan 2025 12:45:32 -0500 you wrote: > From: Mazin Al Haddad <mazin@getstate.dev> > > This fixes the following crash: > > ================================================================== > BUG: KASAN: slab-use-after-free in mgmt_remove_adv_monitor_sync+0x3a/0xd0 net/bluetooth/mgmt.c:5543 > Read of size 8 at addr ffff88814128f898 by task kworker/u9:4/5961 > > [...] Here is the summary with links: - [v1] Bluetooth: MGMT: Fix slab-use-after-free Read in mgmt_remove_adv_monitor_sync https://git.kernel.org/bluetooth/bluetooth-next/c/1f2ae3fb1cdc You are awesome, thank you!
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5e46f3764440..09bac3c9c2d5 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -5388,10 +5388,16 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev, { struct mgmt_rp_remove_adv_monitor rp; struct mgmt_pending_cmd *cmd = data; - struct mgmt_cp_remove_adv_monitor *cp = cmd->param; + struct mgmt_cp_remove_adv_monitor *cp; + + if (status == -ECANCELED || + cmd != pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev)) + return; hci_dev_lock(hdev); + cp = cmd->param; + rp.monitor_handle = cp->monitor_handle; if (!status) @@ -5409,6 +5415,10 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev, static int mgmt_remove_adv_monitor_sync(struct hci_dev *hdev, void *data) { struct mgmt_pending_cmd *cmd = data; + + if (cmd != pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev)) + return -ECANCELED; + struct mgmt_cp_remove_adv_monitor *cp = cmd->param; u16 handle = __le16_to_cpu(cp->monitor_handle);