Commit a239110
Bluetooth: hci_sync: always check if connection is alive before deleting
In hci_abort_conn_sync it is possible that conn is deleted concurrently
by something else, also e.g. when waiting for hdev->lock. This causes
double deletion of the conn, so UAF or conn_hash.list corruption.
Fix by having all code paths check that the connection is still in
conn_hash before deleting it, while holding hdev->lock which prevents
any races.
Log (when powering off while BAP streaming, occurs rarely):
=======================================================================
kernel BUG at lib/list_debug.c:56!
...
? __list_del_entry_valid (lib/list_debug.c:56)
hci_conn_del (net/bluetooth/hci_conn.c:154) bluetooth
hci_abort_conn_sync (net/bluetooth/hci_sync.c:5415) bluetooth
? __pfx_hci_abort_conn_sync+0x10/0x10 [bluetooth]
? lock_release+0x1d5/0x3c0
? hci_disconnect_all_sync.constprop.0+0xb2/0x230 [bluetooth]
? __pfx_lock_release+0x10/0x10
? __kmem_cache_free+0x14d/0x2e0
hci_disconnect_all_sync.constprop.0+0xda/0x230 [bluetooth]
? __pfx_hci_disconnect_all_sync.constprop.0+0x10/0x10 [bluetooth]
? hci_clear_adv_sync+0x14f/0x170 [bluetooth]
? __pfx_set_powered_sync+0x10/0x10 [bluetooth]
hci_set_powered_sync+0x293/0x450 [bluetooth]
=======================================================================
Fixes: 94d9ba9 ("Bluetooth: hci_sync: Fix UAF in hci_disconnect_all_sync")
Signed-off-by: Pauli Virtanen <pav@iki.fi>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>1 parent 1ffc6f8 commit a239110
1 file changed
Lines changed: 12 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5369 | 5369 | | |
5370 | 5370 | | |
5371 | 5371 | | |
| 5372 | + | |
5372 | 5373 | | |
5373 | 5374 | | |
5374 | 5375 | | |
| |||
5399 | 5400 | | |
5400 | 5401 | | |
5401 | 5402 | | |
5402 | | - | |
5403 | | - | |
5404 | | - | |
5405 | | - | |
| 5403 | + | |
5406 | 5404 | | |
5407 | | - | |
5408 | | - | |
5409 | | - | |
5410 | | - | |
5411 | | - | |
5412 | | - | |
| 5405 | + | |
| 5406 | + | |
5413 | 5407 | | |
5414 | 5408 | | |
5415 | 5409 | | |
5416 | 5410 | | |
5417 | | - | |
5418 | | - | |
5419 | | - | |
| 5411 | + | |
5420 | 5412 | | |
5421 | 5413 | | |
5422 | 5414 | | |
| |||
5428 | 5420 | | |
5429 | 5421 | | |
5430 | 5422 | | |
5431 | | - | |
| 5423 | + | |
| 5424 | + | |
| 5425 | + | |
| 5426 | + | |
| 5427 | + | |
| 5428 | + | |
| 5429 | + | |
5432 | 5430 | | |
5433 | 5431 | | |
5434 | 5432 | | |
| |||
0 commit comments