In the Linux kernel, the following vulnerability has been resolved:
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 queuework+0xdad/0x1140 Workqueue: events hcicmdtimeout RIP: 0010:queuework+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> ? queueworkon+0xcb/0x110 ? lockdephardirqsoff+0x90/0xd0 queueworkon+0xee/0x110 processonework+0x996/0x1610 ? pwqdecnrinflight+0x2a0/0x2a0 ? rwlockbug.part.0+0x90/0x90 ? _rawspinlockirq+0x41/0x50 workerthread+0x665/0x1080 ? processonework+0x1610/0x1610 kthread+0x2e9/0x3a0 ? kthreadcompleteandexit+0x40/0x40 retfromfork+0x1f/0x30 </TASK>
To fix this, we can add a new HCIDRAINWQ flag, and don't queue the timeout workqueue while command workqueue is draining.
[
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4bf367fa1fefabdf14938d0ac9ed60020389112e",
"id": "CVE-2022-50166-00dc657d",
"deprecated": false,
"signature_version": "v1",
"target": {
"function": "hci_cmd_work",
"file": "net/bluetooth/hci_core.c"
},
"digest": {
"length": 894.0,
"function_hash": "257518447988808350207318989562596230190"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@877afadad2dce8aae1f2aad8ce47e072d4f6165e",
"id": "CVE-2022-50166-115f25d3",
"deprecated": false,
"signature_version": "v1",
"target": {
"function": "hci_dev_do_reset",
"file": "net/bluetooth/hci_core.c"
},
"digest": {
"length": 520.0,
"function_hash": "144135601343006505313117936446615682189"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3b382555706558f5c0587862b6dc03e96a252bba",
"id": "CVE-2022-50166-33c240c4",
"deprecated": false,
"signature_version": "v1",
"target": {
"function": "hci_dev_do_reset",
"file": "net/bluetooth/hci_core.c"
},
"digest": {
"length": 520.0,
"function_hash": "144135601343006505313117936446615682189"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3b382555706558f5c0587862b6dc03e96a252bba",
"id": "CVE-2022-50166-3a2c926b",
"deprecated": false,
"signature_version": "v1",
"target": {
"file": "net/bluetooth/hci_event.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"298813293868886859514745344798933259469",
"300600680245530625079093757460050561605",
"92391027321936649602219980064911021975",
"107957302026127153209846263830591235615",
"143843955281711743296374900648421634852"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3b382555706558f5c0587862b6dc03e96a252bba",
"id": "CVE-2022-50166-49082ede",
"deprecated": false,
"signature_version": "v1",
"target": {
"file": "include/net/bluetooth/hci.h"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"132593684018331660663331178722641145623",
"120667111050393162459976311001198937268",
"19855078100547446904234493143941541294",
"126964939899418083666355583488575929931"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@877afadad2dce8aae1f2aad8ce47e072d4f6165e",
"id": "CVE-2022-50166-4951c342",
"deprecated": false,
"signature_version": "v1",
"target": {
"file": "net/bluetooth/hci_core.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"215689567160586635353936353189166886929",
"256496434343241608840112733376569186170",
"284410392486052775243610958670779163690",
"265961021621483561569220838342860054336",
"83303557863509254461739091128180501316",
"302705192227592996511805174849857853200",
"1830592253822661292996947604998412433",
"206086635450207000340557044159757938533",
"333679623362593137547654825798625450192",
"97611935165721941957721845355791986827"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4bf367fa1fefabdf14938d0ac9ed60020389112e",
"id": "CVE-2022-50166-4e125f14",
"deprecated": false,
"signature_version": "v1",
"target": {
"function": "handle_cmd_cnt_and_timer",
"file": "net/bluetooth/hci_event.c"
},
"digest": {
"length": 312.0,
"function_hash": "286877488051970081752606841944560535560"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3b382555706558f5c0587862b6dc03e96a252bba",
"id": "CVE-2022-50166-51ddc14e",
"deprecated": false,
"signature_version": "v1",
"target": {
"function": "hci_cmd_work",
"file": "net/bluetooth/hci_core.c"
},
"digest": {
"length": 894.0,
"function_hash": "257518447988808350207318989562596230190"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4bf367fa1fefabdf14938d0ac9ed60020389112e",
"id": "CVE-2022-50166-552a7770",
"deprecated": false,
"signature_version": "v1",
"target": {
"function": "hci_dev_do_reset",
"file": "net/bluetooth/hci_core.c"
},
"digest": {
"length": 520.0,
"function_hash": "144135601343006505313117936446615682189"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3b382555706558f5c0587862b6dc03e96a252bba",
"id": "CVE-2022-50166-75e79e66",
"deprecated": false,
"signature_version": "v1",
"target": {
"file": "net/bluetooth/hci_core.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"215689567160586635353936353189166886929",
"256496434343241608840112733376569186170",
"284410392486052775243610958670779163690",
"265961021621483561569220838342860054336",
"83303557863509254461739091128180501316",
"302705192227592996511805174849857853200",
"1830592253822661292996947604998412433",
"206086635450207000340557044159757938533",
"333679623362593137547654825798625450192",
"97611935165721941957721845355791986827"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@877afadad2dce8aae1f2aad8ce47e072d4f6165e",
"id": "CVE-2022-50166-8218a5a2",
"deprecated": false,
"signature_version": "v1",
"target": {
"file": "net/bluetooth/hci_event.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"298813293868886859514745344798933259469",
"300600680245530625079093757460050561605",
"92391027321936649602219980064911021975",
"107957302026127153209846263830591235615",
"143843955281711743296374900648421634852"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@877afadad2dce8aae1f2aad8ce47e072d4f6165e",
"id": "CVE-2022-50166-9328b2dc",
"deprecated": false,
"signature_version": "v1",
"target": {
"function": "hci_cmd_work",
"file": "net/bluetooth/hci_core.c"
},
"digest": {
"length": 894.0,
"function_hash": "257518447988808350207318989562596230190"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3b382555706558f5c0587862b6dc03e96a252bba",
"id": "CVE-2022-50166-9d01b066",
"deprecated": false,
"signature_version": "v1",
"target": {
"function": "handle_cmd_cnt_and_timer",
"file": "net/bluetooth/hci_event.c"
},
"digest": {
"length": 312.0,
"function_hash": "286877488051970081752606841944560535560"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4bf367fa1fefabdf14938d0ac9ed60020389112e",
"id": "CVE-2022-50166-caa70f5a",
"deprecated": false,
"signature_version": "v1",
"target": {
"file": "net/bluetooth/hci_event.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"298813293868886859514745344798933259469",
"300600680245530625079093757460050561605",
"92391027321936649602219980064911021975",
"107957302026127153209846263830591235615",
"143843955281711743296374900648421634852"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4bf367fa1fefabdf14938d0ac9ed60020389112e",
"id": "CVE-2022-50166-e3aa1921",
"deprecated": false,
"signature_version": "v1",
"target": {
"file": "include/net/bluetooth/hci.h"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"132593684018331660663331178722641145623",
"120667111050393162459976311001198937268",
"19855078100547446904234493143941541294",
"126964939899418083666355583488575929931"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@877afadad2dce8aae1f2aad8ce47e072d4f6165e",
"id": "CVE-2022-50166-f41b9a3d",
"deprecated": false,
"signature_version": "v1",
"target": {
"file": "include/net/bluetooth/hci.h"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"132593684018331660663331178722641145623",
"120667111050393162459976311001198937268",
"19855078100547446904234493143941541294",
"126964939899418083666355583488575929931"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@877afadad2dce8aae1f2aad8ce47e072d4f6165e",
"id": "CVE-2022-50166-fa97a6fa",
"deprecated": false,
"signature_version": "v1",
"target": {
"function": "handle_cmd_cnt_and_timer",
"file": "net/bluetooth/hci_event.c"
},
"digest": {
"length": 312.0,
"function_hash": "286877488051970081752606841944560535560"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@4bf367fa1fefabdf14938d0ac9ed60020389112e",
"id": "CVE-2022-50166-fdb1a4e8",
"deprecated": false,
"signature_version": "v1",
"target": {
"file": "net/bluetooth/hci_core.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"215689567160586635353936353189166886929",
"256496434343241608840112733376569186170",
"284410392486052775243610958670779163690",
"265961021621483561569220838342860054336",
"83303557863509254461739091128180501316",
"302705192227592996511805174849857853200",
"1830592253822661292996947604998412433",
"206086635450207000340557044159757938533",
"333679623362593137547654825798625450192",
"97611935165721941957721845355791986827"
]
},
"signature_type": "Line"
}
]