Schspa Shi
877afadad2
Bluetooth: When HCI work queue is drained, only queue chained work
The HCI command, event, and data packet processing workqueue is drained
to avoid deadlock in commit
76727c02c1 ("Bluetooth: Call drain_workqueue() before resetting state").
There is another delayed work, which will queue command to this drained
workqueue. Which results in the following error report:
Bluetooth: hci2: command 0x040f tx timeout
WARNING: CPU: 1 PID: 18374 at kernel/workqueue.c:1438 __queue_work+0xdad/0x1140
Workqueue: events hci_cmd_timeout
RIP: 0010:__queue_work+0xdad/0x1140
RSP: 0000:ffffc90002cffc60 EFLAGS: 00010093
RAX: 0000000000000000 RBX: ffff8880b9d3ec00 RCX: 0000000000000000
RDX: ffff888024ba0000 RSI: ffffffff814e048d RDI: ffff8880b9d3ec08
RBP: 0000000000000008 R08: 0000000000000000 R09: 00000000b9d39700
R10: ffffffff814f73c6 R11: 0000000000000000 R12: ffff88807cce4c60
R13: 0000000000000000 R14: ffff8880796d8800 R15: ffff8880796d8800
FS: 0000000000000000(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000c0174b4000 CR3: 000000007cae9000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
? queue_work_on+0xcb/0x110
? lockdep_hardirqs_off+0x90/0xd0
queue_work_on+0xee/0x110
process_one_work+0x996/0x1610
? pwq_dec_nr_in_flight+0x2a0/0x2a0
? rwlock_bug.part.0+0x90/0x90
? _raw_spin_lock_irq+0x41/0x50
worker_thread+0x665/0x1080
? process_one_work+0x1610/0x1610
kthread+0x2e9/0x3a0
? kthread_complete_and_exit+0x40/0x40
ret_from_fork+0x1f/0x30
</TASK>
To fix this, we can add a new HCI_DRAIN_WQ flag, and don't queue the
timeout workqueue while command workqueue is draining.
Fixes: 76727c02c1 ("Bluetooth: Call drain_workqueue() before resetting state")
Reported-by: syzbot+63bed493aebbf6872647@syzkaller.appspotmail.com
Signed-off-by: Schspa Shi <schspa@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2022-07-21 17:05:22 -07:00
..
2022-01-10 10:00:09 +09:00
2022-07-21 17:05:22 -07:00
2021-11-19 11:52:25 +00:00
2022-07-20 18:05:51 -07:00
2022-07-20 18:05:51 -07:00
2021-11-17 20:17:05 -08:00
2022-04-12 15:00:25 +02:00
2022-05-12 16:15:30 -07:00
2022-04-08 13:45:43 +01:00
2022-02-18 21:20:06 -08:00
2022-06-22 12:59:43 +01:00
2022-03-11 23:14:19 -08:00
2022-07-19 12:37:02 +02:00
2022-02-21 11:44:30 +00:00
2022-06-02 10:37:57 +02:00
2021-12-13 12:34:09 +00:00
2022-02-15 14:35:18 +00:00
2021-12-03 14:16:48 +00:00
2022-06-24 11:27:59 +01:00
2022-06-24 11:27:59 +01:00
2021-12-03 14:15:49 +00:00
2022-07-14 15:27:35 -07:00
2022-05-22 21:51:54 +01:00
2022-03-11 10:57:22 +00:00
2021-12-22 15:03:47 -08:00
2021-12-22 15:03:51 -08:00
2021-12-22 15:03:51 -08:00
2022-07-18 20:10:48 -07:00
2022-06-07 12:51:41 +02:00
2022-07-02 16:34:05 +01:00
2021-11-29 19:50:45 -08:00
2022-02-09 11:41:47 +00:00
2021-12-06 16:05:10 -08:00
2022-04-13 10:16:11 +02:00
2021-12-06 16:06:02 -08:00
2021-12-16 07:18:35 -08:00
2022-07-13 12:16:56 +01:00
2022-07-13 12:16:56 +01:00
2022-03-15 20:20:02 -07:00
2022-07-11 19:49:38 -07:00
2021-10-18 12:54:41 +01:00
2022-02-18 11:00:25 +00:00
2022-03-11 08:28:27 -08:00
2022-02-04 16:25:21 +01:00
2022-04-06 22:09:39 -07:00
2022-05-16 10:31:06 +01:00
2022-06-16 11:07:59 -07:00
2022-02-07 20:12:45 -08:00
2022-03-03 14:38:48 +00:00
2022-07-15 11:49:55 +01:00
2022-07-15 11:49:55 +01:00
2022-05-13 12:24:12 +01:00
2022-02-17 07:00:39 -06:00
2021-11-16 13:16:54 +00:00
2022-02-17 11:44:20 -08:00
2021-11-19 20:09:55 -08:00
2022-04-25 11:40:45 +01:00
2022-04-11 17:37:50 -07:00
2022-06-09 21:53:11 -07:00
2022-07-20 10:14:49 +01:00
2022-02-04 14:15:11 -08:00
2021-11-22 15:44:49 +00:00
2022-06-08 10:56:43 -07:00
2021-12-07 20:44:59 -08:00
2021-11-07 19:25:29 +00:00
2022-07-14 15:27:35 -07:00
2022-04-25 20:51:12 +02:00
2022-04-01 12:04:15 +01:00
2021-10-29 13:23:51 +01:00
2022-07-09 12:19:23 +01:00
2022-03-03 11:55:12 -08:00
2022-06-30 13:14:35 +02:00
2022-05-11 12:43:10 +01:00
2022-07-11 16:25:14 +02:00
2021-12-10 06:38:26 -08:00
2021-11-16 18:02:46 +01:00
2022-04-15 10:43:47 +01:00
2022-04-12 15:00:25 +02:00
2022-07-13 14:46:59 +01:00
2022-07-05 17:50:38 -07:00
2022-07-15 18:50:35 -07:00
2022-07-14 15:27:35 -07:00
2022-06-19 10:00:02 +01:00
2022-02-02 14:45:18 +00:00
2022-07-21 13:03:39 -07:00
2022-04-13 12:46:26 +01:00
2022-07-19 17:14:55 -07:00
2022-05-04 19:22:20 -07:00
2022-01-04 12:17:35 +00:00
2022-07-14 15:27:35 -07:00
2022-07-18 11:24:10 +01:00
2022-06-29 20:37:36 -07:00
2022-07-21 13:03:39 -07:00
2022-07-18 11:24:11 +01:00
2022-07-21 13:03:39 -07:00
2022-01-27 13:53:27 +00:00
2022-03-01 08:38:02 +00:00
2021-12-14 00:24:24 +01:00
2022-01-27 17:25:32 +01:00
2021-12-29 08:48:14 -08:00
2022-03-17 20:33:52 +01:00
2022-07-11 13:39:56 +01:00
2022-04-26 16:19:54 +02:00