linux-stable/net/bluetooth
Ruihan Li b0167893c0 Bluetooth: Fix UAF in hci_conn_hash_flush again
commit a2ac591cb4 upstream.

Commit 06149746e7 ("Bluetooth: hci_conn: Add support for linking
multiple hcon") reintroduced a previously fixed bug [1] ("KASAN:
slab-use-after-free Read in hci_conn_hash_flush"). This bug was
originally fixed by commit 5dc7d23e16 ("Bluetooth: hci_conn: Fix
possible UAF").

The hci_conn_unlink function was added to avoid invalidating the link
traversal caused by successive hci_conn_del operations releasing extra
connections. However, currently hci_conn_unlink itself also releases
extra connections, resulted in the reintroduced bug.

This patch follows a more robust solution for cleaning up all
connections, by repeatedly removing the first connection until there are
none left. This approach does not rely on the inner workings of
hci_conn_del and ensures proper cleanup of all connections.

Meanwhile, we need to make sure that hci_conn_del never fails. Indeed it
doesn't, as it now always returns zero. To make this a bit clearer, this
patch also changes its return type to void.

Reported-by: syzbot+8bb72f86fc823817bc5d@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-bluetooth/000000000000aa920505f60d25ad@google.com/
Fixes: 06149746e7 ("Bluetooth: hci_conn: Add support for linking multiple hcon")
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
Co-developed-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-06-14 11:17:05 +02:00
..
bnep bluetooth: Use netif_rx(). 2022-03-07 11:40:41 +00:00
cmtp Merge branch 'signal-for-v5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2022-01-17 05:49:30 +02:00
hidp Bluetooth: Fix race condition in hidp_session_thread 2023-04-10 10:22:46 -07:00
rfcomm TTY/Serial driver updates for 6.3-rc1 2023-02-24 12:17:14 -08:00
6lowpan.c iov_iter work; most of that is about getting rid of 2022-12-12 18:29:54 -08:00
Kconfig Bluetooth: Add CONFIG_BT_LE_L2CAP_ECRED 2022-12-12 14:19:24 -08:00
Makefile Bluetooth: Add BTPROTO_ISO socket type 2022-07-22 17:13:39 -07:00
a2mp.c use less confusing names for iov_iter direction initializers 2022-11-25 13:01:55 -05:00
a2mp.h
af_bluetooth.c Bluetooth: Fix not cleanup led when bt_init fails 2022-12-02 13:09:31 -08:00
amp.c
amp.h
aosp.c Bluetooth: Fix null pointer deref on unexpected status event 2022-08-08 17:04:37 -07:00
aosp.h Bluetooth: aosp: Support AOSP Bluetooth Quality Report 2021-11-02 19:37:52 +01:00
ecdh_helper.c Bluetooth: Use crypto_wait_req 2023-02-13 18:34:48 +08:00
ecdh_helper.h
eir.c Bluetooth: Add initial implementation of BIS connections 2022-07-22 17:13:56 -07:00
eir.h Bluetooth: Add initial implementation of BIS connections 2022-07-22 17:13:56 -07:00
hci_codec.c Bluetooth: Fix support for Read Local Supported Codecs V2 2022-12-02 13:09:31 -08:00
hci_codec.h
hci_conn.c Bluetooth: Fix UAF in hci_conn_hash_flush again 2023-06-14 11:17:05 +02:00
hci_core.c Bluetooth: Fix use-after-free in hci_remove_ltk/hci_remove_irk 2023-06-14 11:16:57 +02:00
hci_debugfs.c Bluetooth: hci_sync: Fix not able to set force_static_address 2022-12-12 14:19:23 -08:00
hci_debugfs.h
hci_event.c Bluetooth: ISO: use correct CIS order in Set CIG Parameters event 2023-06-14 11:16:47 +02:00
hci_request.c Bluetooth: silence a dmesg error message in hci_request.c 2022-12-02 13:09:30 -08:00
hci_request.h Bluetooth: Move hci_abort_conn to hci_conn.c 2022-08-31 15:45:56 -07:00
hci_sock.c bluetooth: Add cmd validity checks at the start of hci_sock_ioctl() 2023-06-05 09:29:45 +02:00
hci_sync.c Bluetooth: fix debugfs registration 2023-06-14 11:16:58 +02:00
hci_sysfs.c Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times 2022-09-21 15:00:54 -07:00
iso.c Bluetooth: hci_conn: Add support for linking multiple hcon 2023-06-14 11:16:46 +02:00
l2cap_core.c Bluetooth: L2CAP: Add missing checks for invalid DCID 2023-06-14 11:16:47 +02:00
l2cap_sock.c Bluetooth: L2CAP: Fix potential user-after-free 2023-02-09 14:18:48 -08:00
leds.c
leds.h
lib.c Bluetooth: Fix EALREADY and ELOOP cases in bt_status() 2022-12-12 14:19:24 -08:00
mgmt.c Bluetooth: mgmt: Fix MGMT add advmon with RSSI command 2023-03-23 13:09:38 -07:00
mgmt_config.c
mgmt_config.h
mgmt_util.c Bluetooth: Implement support for Mesh 2022-09-06 13:18:24 -07:00
mgmt_util.h Bluetooth: Fix a buffer overflow in mgmt_mesh_add() 2023-01-17 15:50:10 -08:00
msft.c Bluetooth: Fix null pointer deref on unexpected status event 2022-08-08 17:04:37 -07:00
msft.h Bluetooth: hci_sync: Refactor remove Adv Monitor 2022-07-21 17:14:55 -07:00
sco.c Bluetooth: SCO: Fix possible circular locking dependency sco_sock_getsockopt 2023-04-10 10:23:45 -07:00
selftest.c
selftest.h
smp.c use less confusing names for iov_iter direction initializers 2022-11-25 13:01:55 -05:00
smp.h