mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
Bluetooth: hci_conn: hold conn reference in abort_conn_sync()
[ Upstream commit5761d003da] There is theoretical UAF if the conn is freed while the hci_sync task is running. Hold refcount to avoid that. Fixes:227a0cdf4a("Bluetooth: MGMT: Fix not generating command complete for MGMT_OP_DISCONNECT") Signed-off-by: Pauli Virtanen <pav@iki.fi> 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:
committed by
Greg Kroah-Hartman
parent
759303b001
commit
64d1645f26
@@ -2896,6 +2896,13 @@ static int abort_conn_sync(struct hci_dev *hdev, void *data)
|
||||
return hci_abort_conn_sync(hdev, conn, conn->abort_reason);
|
||||
}
|
||||
|
||||
static void abort_conn_destroy(struct hci_dev *hdev, void *data, int err)
|
||||
{
|
||||
struct hci_conn *conn = data;
|
||||
|
||||
hci_conn_put(conn);
|
||||
}
|
||||
|
||||
int hci_abort_conn(struct hci_conn *conn, u8 reason)
|
||||
{
|
||||
struct hci_dev *hdev = conn->hdev;
|
||||
@@ -2921,6 +2928,9 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason)
|
||||
* as a result to MGMT_OP_DISCONNECT/MGMT_OP_UNPAIR which does
|
||||
* already queue its callback on cmd_sync_work.
|
||||
*/
|
||||
err = hci_cmd_sync_run_once(hdev, abort_conn_sync, conn, NULL);
|
||||
err = hci_cmd_sync_run_once(hdev, abort_conn_sync, hci_conn_get(conn),
|
||||
abort_conn_destroy);
|
||||
if (err)
|
||||
hci_conn_put(conn);
|
||||
return (err == -EEXIST) ? 0 : err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user