
Arseniy KrasnovandGreg Kroah-Hartman
86f3dcd1f3
Bluetooth: hci_sync: fix double free in 'hci_discovery_filter_clear()'
[ Upstream commit 2935e55685 ]
Function 'hci_discovery_filter_clear()' frees 'uuids' array and then
sets it to NULL. There is a tiny chance of the following race:
'hci_cmd_sync_work()'
'update_passive_scan_sync()'
'hci_update_passive_scan_sync()'
'hci_discovery_filter_clear()'
kfree(uuids);
<-------------------------preempted-------------------------------->
'start_service_discovery()'
'hci_discovery_filter_clear()'
kfree(uuids); // DOUBLE FREE
<-------------------------preempted-------------------------------->
uuids = NULL;
To fix it let's add locking around 'kfree()' call and NULL pointer
assignment. Otherwise the following backtrace fires:
[ ] ------------[ cut here ]------------
[ ] kernel BUG at mm/slub.c:547!
[ ] Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
[ ] CPU: 3 UID: 0 PID: 246 Comm: bluetoothd Tainted: G O 6.12.19-kernel #1
[ ] Tainted: [O]=OOT_MODULE
[ ] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ ] pc : __slab_free+0xf8/0x348
[ ] lr : __slab_free+0x48/0x348
...
[ ] Call trace:
[ ] __slab_free+0xf8/0x348
[ ] kfree+0x164/0x27c
[ ] start_service_discovery+0x1d0/0x2c0
[ ] hci_sock_sendmsg+0x518/0x924
[ ] __sock_sendmsg+0x54/0x60
[ ] sock_write_iter+0x98/0xf8
[ ] do_iter_readv_writev+0xe4/0x1c8
[ ] vfs_writev+0x128/0x2b0
[ ] do_writev+0xfc/0x118
[ ] __arm64_sys_writev+0x20/0x2c
[ ] invoke_syscall+0x68/0xf0
[ ] el0_svc_common.constprop.0+0x40/0xe0
[ ] do_el0_svc+0x1c/0x28
[ ] el0_svc+0x30/0xd0
[ ] el0t_64_sync_handler+0x100/0x12c
[ ] el0t_64_sync+0x194/0x198
[ ] Code: 8b0002e6 eb17031f 54fffbe1 d503201f (d4210000)
[ ] ---[ end trace 0000000000000000 ]---
Fixes: ad383c2c65 ("Bluetooth: hci_sync: Enable advertising when LL privacy is enabled")
Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Minor context change fixed. ]
Signed-off-by: Alva Lan <alvalan9@foxmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-12-07 06:12:34 +09:00
..
2025-12-07 06:12:34 +09:00
2025-07-24 08:51:53 +02:00
2023-10-25 12:03:06 +02:00
2025-12-07 06:12:21 +09:00
2025-04-25 10:43:43 +02:00
2025-12-07 06:12:33 +09:00
2024-04-17 11:18:24 +02:00
2025-06-04 14:40:24 +02:00
2023-10-10 22:00:42 +02:00
2025-02-21 13:49:02 +01:00
2025-08-28 16:26:18 +02:00
2023-05-11 23:03:41 +09:00
2025-08-28 16:26:18 +02:00
2025-08-28 16:26:18 +02:00
2024-09-04 13:25:02 +02:00
2025-08-28 16:25:56 +02:00
2024-04-03 15:19:31 +02:00
2025-06-27 11:07:38 +01:00
2025-12-07 06:12:24 +09:00
2025-05-02 07:46:50 +02:00
2024-06-16 13:41:40 +02:00
2025-03-07 16:56:46 +01:00
2025-05-18 08:21:21 +02:00
2024-11-01 01:56:00 +01:00
2023-12-20 17:00:15 +01:00
2024-06-12 11:03:12 +02:00
2024-06-12 11:03:53 +02:00
2025-01-17 13:34:38 +01:00
2024-06-12 11:03:12 +02:00
2024-01-31 16:17:04 -08:00
2024-08-29 17:30:44 +02:00
2025-02-21 13:49:01 +01:00
2023-09-19 12:28:10 +02:00
2024-08-14 13:53:02 +02:00
2024-08-03 08:49:24 +02:00
2025-10-29 14:04:33 +01:00
2023-05-24 17:32:39 +01:00
2025-03-07 16:56:44 +01:00
2024-03-06 14:45:20 +00:00
2023-09-19 12:28:10 +02:00
2024-08-29 17:30:44 +02:00
2025-02-21 13:49:56 +01:00
2024-12-19 18:08:53 +01:00
2024-01-31 16:17:04 -08:00
2023-09-13 09:42:33 +02:00
2025-08-28 16:25:56 +02:00
2024-05-02 16:29:32 +02:00
2024-10-17 15:22:23 +02:00
2023-01-07 11:11:44 +01:00
2022-12-31 13:33:02 +01:00
2023-10-10 22:00:42 +02:00
2025-08-28 16:25:57 +02:00
2025-02-21 13:50:06 +01:00
2024-11-01 01:56:04 +01:00
2023-10-10 22:00:44 +02:00
2023-10-10 22:00:46 +02:00
2023-06-05 09:26:20 +02:00
2023-06-14 11:15:16 +02:00
2025-12-07 06:12:09 +09:00
2023-04-13 16:55:23 +02:00
2023-07-19 16:21:10 +02:00
2025-09-04 15:26:28 +02:00
2025-05-18 08:21:21 +02:00
2023-06-14 11:15:20 +02:00
2024-10-17 15:22:23 +02:00
2025-05-22 14:10:02 +02:00
2025-06-04 14:40:24 +02:00
2025-09-19 16:29:55 +02:00
2025-03-07 16:56:37 +01:00
2024-03-01 13:26:35 +01:00
2025-03-07 16:56:37 +01:00
2024-02-23 09:12:31 +01:00
2024-01-10 17:10:28 +01:00
2025-08-15 12:05:10 +02:00
2023-08-11 12:08:17 +02:00
2025-12-07 06:12:17 +09:00
2025-06-04 14:40:19 +02:00
2023-05-11 23:03:21 +09:00