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
76727c02c1e1 ("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: 76727c02c1e1 ("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-06-09 21:53:28 +02:00
2022-05-27 11:05:29 +02:00
2022-07-14 15:27:35 -07:00
2022-04-06 13:45:26 +01:00
2022-04-28 13:08:15 -07:00
2022-06-17 20:34:13 -07:00
2022-05-22 21:51:54 +01:00
2022-07-21 17:05:22 -07:00
2022-06-03 14:53:33 -07:00
2022-02-25 09:36:06 +01:00
2022-07-11 16:40:46 +02:00
2022-04-06 13:45:26 +01:00
2022-07-07 12:07:37 -07:00
2022-05-25 20:45:13 +02:00
2022-07-21 13:03:39 -07:00
2022-03-03 08:01:55 -08:00
2022-06-16 11:07:59 -07:00
2022-06-30 13:14:35 +02:00
2022-07-21 13:03:39 -07:00
2022-04-07 21:04:03 -07:00
2022-06-23 12:33:24 -07:00
2022-03-11 23:17:24 -08:00
2022-04-28 13:08:15 -07:00
2022-07-21 13:03:39 -07:00
2022-07-21 13:03:39 -07:00
2022-06-10 16:21:27 -07:00
2022-06-01 17:44:04 -07:00
2022-07-08 12:14:36 +01:00
2022-04-15 14:27:24 -07:00
2022-06-09 21:52:55 -07:00
2022-07-14 15:27:35 -07:00
2022-04-30 20:29:47 +02:00
2022-05-25 12:22:58 -07:00
2022-04-07 21:06:41 -07:00
2022-07-14 15:27:35 -07:00
2022-06-23 20:51:06 -07:00
2022-07-21 13:03:39 -07:00
2022-03-21 10:59:11 +00:00
2022-05-12 16:15:30 -07:00
2022-04-06 13:45:26 +01:00
2022-05-28 15:28:47 +01:00
2022-06-23 12:33:24 -07:00
2022-06-09 21:52:55 -07:00
2022-04-12 15:00:25 +02:00
2022-04-06 13:45:26 +01:00
2022-05-24 12:40:28 -03:00
2022-03-18 13:09:17 +02:00
2022-07-06 19:49:11 -07:00
2022-07-08 20:15:11 -07:00
2022-07-21 13:03:39 -07:00
2022-07-21 13:03:39 -07:00
2022-07-21 13:03:39 -07:00
2022-07-08 18:38:44 -07:00
2022-07-02 11:20:56 -07:00
2022-06-09 21:52:55 -07:00
2022-06-30 16:31:00 -07:00
2022-07-21 13:03:39 -07:00
2022-07-09 12:24:16 -07:00
2022-05-28 11:39:01 -07:00
2022-07-14 15:27:35 -07:00
2022-05-10 11:59:22 +02:00
2022-07-07 12:07:37 -07:00
2022-07-21 13:03:39 -07:00
2022-07-19 14:20:42 -07:00
2022-03-03 09:55:28 +00:00
2022-06-02 10:15:05 -07:00
2022-07-19 14:22:41 -07:00