Subject: CVE-2024-36012: Bluetooth: msft: fix slab-use-after-free in msft_do_close()

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

Bluetooth: msft: fix slab-use-after-free in msft_do_close()

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

The Linux kernel CVE team has assigned CVE-2024-36012 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 5.12 with commit bf6a4e30ffbd and fixed in 6.1.91 with commit e3880b531b68
	Issue introduced in 5.12 with commit bf6a4e30ffbd and fixed in 6.6.31 with commit a85a60e62355
	Issue introduced in 5.12 with commit bf6a4e30ffbd and fixed in 6.8.10 with commit 4f1de02de077
	Issue introduced in 5.12 with commit bf6a4e30ffbd and fixed in 6.9 with commit 10f9f426ac6e

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2024-36012
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	net/bluetooth/hci_core.c
	net/bluetooth/msft.c
	net/bluetooth/msft.h

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/e3880b531b68f98d3941d83f2f6dd11cf4fd6b76
	https://git.kernel.org/stable/c/a85a60e62355e3bf4802dead7938966824b23940
	https://git.kernel.org/stable/c/4f1de02de07748da80a8178879bc7a1df37fdf56
	https://git.kernel.org/stable/c/10f9f426ac6e752c8d87bf4346930ba347aaabac