| 0/0 |
2026/09/29 03:15 |
flow |
moderation |
32m
Results: map[Actionable:true Explanation:The bug report is **actionable** and **self-consistent**.
### Analysis:
1. **Stack Traces Presence & Subsystem Consistency:**
The report contains all 3 necessary stack traces (plus auxiliary work
creation stacks), all belonging to the USB core / USB HCD subsystem:
- **Access stack:** A worker task (`ksoftirqd`) executing
`usb_giveback_urb_bh()` at `drivers/usb/core/hcd.c:1692` performs an 8-byte
write (`bh->completing_ep = NULL;`).
- **Allocation stack:** `struct usb_hcd` is allocated by `__usb_create_hcd()`
at `drivers/usb/core/hcd.c:2566` during `vhci_hcd_probe()`.
- **Free stack:** `struct usb_hcd` is released by `usb_put_hcd()` /
`hcd_release()` at `drivers/usb/core/hcd.c:2690` during error handling in
`vhci_hcd_probe()`.
2. **Memory Layout and Field Offset Verification:**
- Object base address: `0xffff888022a54000`
- Access address: `0xffff888022a54300` (offset `+768` bytes / `0x300`)
- In `struct usb_hcd`, the member `high_prio_bh` (of type `struct
giveback_urb_bh`) begins at offset `4864` bits (`608` bytes).
- In `struct giveback_urb_bh`, the field `completing_ep` is located at offset
`1280` bits (`160` bytes).
- `608 + 160 = 768` bytes, which matches the offset `0x300` exactly.
- The operation `bh->completing_ep = NULL;` is a pointer write of 8 bytes,
which precisely matches the report's `Write of size 8 at addr
ffff888022a54300`.
3. **Root Cause Analysis:**
- During `vhci_hcd_probe()`, `usb_add_hcd()` is called, which initializes the
bottom-half giveback work structures (`high_prio_bh` and `low_prio_bh`)
embedded in `struct usb_hcd`.
- During `register_root_hub()`, URB activity occurs and URB giveback work is
queued to the BH workqueue (`usb_hcd_giveback_urb()` queues
`&hcd->high_prio_bh.bh`).
- If an error occurs during root hub registration / probe, `usb_add_hcd()`
fails and unwinds to `vhci_hcd_probe()`'s error exit path, which calls
`usb_put_hcd()`.
- β Because the pending BH works (`high_prio_bh` / `low_prio_bh`) were neither
flushed nor cancelled before `hcd` was freed, the workqueue executes
`usb_giveback_urb_bh()` asynchronously after `hcd` has already been freed,
resulting in a use-after-free write.]
|
| 1/1 |
2026/09/29 03:15 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/7bbbe98fc7e7403fc6601ec214a3d473bdb106e5]
|
| 2/1 |
2026/09/29 03:15 |
action |
kernel-builder |
18m
Results: map[KernelObj:/app/workdir/cache/build/d60893ab690d2162cda1e5eb73988e3e93b021d8]
|
| 3/1 |
2026/09/29 03:33 |
action |
codesearch-prepare |
13m
Results: map[Index:codesearch-index]
|
| 4/1 |
2026/09/29 03:46 |
agent |
expert |
1m
Model:
Results:
Instruction: You are an experienced Linux kernel developer tasked with determining if the given kernel bug
report is actionable or not. Actionable means that it contains enough info to root cause
the underlying bug, and that the report is self-consistent and makes sense, rather than
e.g. a one-off nonsensical crash induced by a previous memory corruption.
The bug report is about a use-after-free bug generated by KASAN tool.
It should contain 3 stack traces: the bad memory access stack, the heap block allocation stack,
and the heap block free stack. If the report does not contain 3 stacks, it's not actionable.
All 3 stack traces should be related to the same object type,
and usually be in the same kernel subsystem (at least leaf stack frames).
An example of an actionable and consistent report would be: first access stack relates
to an access to a field of struct Foo, allocation/free stacks relate to allocation/free
of the struct Foo.
In inconsistent/nonsensical reports an access may be to a struct Foo, but allocation
stack allocates a different structure in a different subsystem.
Look for other suspicious signals/inconsistencies that can make this report hard to
debug/understand.
In the final reply explain why you think the report is self-consistent and actionable,
or why it's inconsistent and/or not actionable.
Use the provided tools to confirm any assumptions, variables/fields being accessed, etc.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The bug report is:
==================================================================
BUG: KASAN: slab-use-after-free in usb_giveback_urb_bh+0x441/0x560 drivers/usb/core/hcd.c:1692
Write of size 8 at addr ffff888022a54300 by task ksoftirqd/1/30
CPU: 1 UID: 0 PID: 30 Comm: ksoftirqd/1 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0x13d/0x4b0 mm/kasan/report.c:482
kasan_report+0xdf/0x1c0 mm/kasan/report.c:595
usb_giveback_urb_bh+0x441/0x560 drivers/usb/core/hcd.c:1692
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
process_scheduled_works kernel/workqueue.c:3479 [inline]
bh_worker+0x6a5/0x8f0 kernel/workqueue.c:3782
workqueue_softirq_action+0x14a/0x1b0 kernel/workqueue.c:3810
tasklet_hi_action+0x17/0x70 kernel/softirq.c:994
handle_softirqs+0x1e6/0x9d0 kernel/softirq.c:645
run_ksoftirqd kernel/softirq.c:1099 [inline]
run_ksoftirqd+0x38/0x60 kernel/softirq.c:1091
smpboot_thread_fn+0x3d3/0xab0 kernel/smpboot.c:160
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Allocated by task 1:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__do_kmalloc_node mm/slub.c:5414 [inline]
__kmalloc_noprof+0x32f/0x840 mm/slub.c:5439
_kmalloc_noprof include/linux/slab.h:995 [inline]
_kzalloc_noprof include/linux/slab.h:1312 [inline]
__usb_create_hcd+0x5e/0xac0 drivers/usb/core/hcd.c:2566
vhci_hcd_probe+0xf3/0x4e0 drivers/usb/usbip/vhci_hcd.c:1378
platform_probe+0x106/0x1d0 drivers/base/platform.c:1507
call_driver_probe drivers/base/dd.c:628 [inline]
really_probe+0x241/0xa60 drivers/base/dd.c:706
__driver_probe_device+0x210/0x460 drivers/base/dd.c:868
driver_probe_device+0x4a/0x140 drivers/base/dd.c:898
__device_attach_driver+0x1df/0x320 drivers/base/dd.c:1026
bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:500
__device_attach+0x1e4/0x4d0 drivers/base/dd.c:1098
device_initial_probe+0xaf/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x64/0x160 drivers/base/bus.c:620
device_add+0x121d/0x1970 drivers/base/core.c:3776
platform_device_add+0x35a/0x800 drivers/base/platform.c:833
platform_device_register_full+0x507/0x720 drivers/base/platform.c:970
vhci_hcd_init+0x1a1/0x2f0 drivers/usb/usbip/vhci_hcd.c:1557
do_one_initcall+0x11c/0x6f0 init/main.c:1362
do_initcall_level init/main.c:1424 [inline]
do_initcalls init/main.c:1440 [inline]
do_basic_setup init/main.c:1460 [inline]
kernel_init_freeable+0x6ea/0x7b0 init/main.c:1675
kernel_init+0x21/0x1e0 init/main.c:1565
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
Freed by task 1:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
kasan_save_free_info+0x3b/0x70 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5f/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2748 [inline]
slab_free mm/slub.c:6508 [inline]
kfree+0x22b/0x6d0 mm/slub.c:6801
hcd_release drivers/usb/core/hcd.c:2690 [inline]
kref_put include/linux/kref.h:65 [inline]
usb_put_hcd drivers/usb/core/hcd.c:2704 [inline]
usb_put_hcd+0x149/0x1f0 drivers/usb/core/hcd.c:2701
vhci_hcd_probe+0x342/0x4e0 drivers/usb/usbip/vhci_hcd.c:1415
platform_probe+0x106/0x1d0 drivers/base/platform.c:1507
call_driver_probe drivers/base/dd.c:628 [inline]
really_probe+0x241/0xa60 drivers/base/dd.c:706
__driver_probe_device+0x210/0x460 drivers/base/dd.c:868
driver_probe_device+0x4a/0x140 drivers/base/dd.c:898
__device_attach_driver+0x1df/0x320 drivers/base/dd.c:1026
bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:500
__device_attach+0x1e4/0x4d0 drivers/base/dd.c:1098
device_initial_probe+0xaf/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x64/0x160 drivers/base/bus.c:620
device_add+0x121d/0x1970 drivers/base/core.c:3776
platform_device_add+0x35a/0x800 drivers/base/platform.c:833
platform_device_register_full+0x507/0x720 drivers/base/platform.c:970
vhci_hcd_init+0x1a1/0x2f0 drivers/usb/usbip/vhci_hcd.c:1557
do_one_initcall+0x11c/0x6f0 init/main.c:1362
do_initcall_level init/main.c:1424 [inline]
do_initcalls init/main.c:1440 [inline]
do_basic_setup init/main.c:1460 [inline]
kernel_init_freeable+0x6ea/0x7b0 init/main.c:1675
kernel_init+0x21/0x1e0 init/main.c:1565
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
Last potentially related work creation:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_record_aux_stack+0xa7/0xc0 mm/kasan/generic.c:556
insert_work+0x36/0x230 kernel/workqueue.c:2272
__queue_work+0xa60/0x1370 kernel/workqueue.c:2448
queue_work_on+0x1a9/0x1e0 kernel/workqueue.c:2501
queue_work include/linux/workqueue.h:700 [inline]
usb_hcd_giveback_urb+0x330/0x4a0 drivers/usb/core/hcd.c:1758
usb_rh_urb_dequeue drivers/usb/core/hcd.c:845 [inline]
unlink1+0x418/0x510 drivers/usb/core/hcd.c:1580
usb_hcd_unlink_urb+0x131/0x210 drivers/usb/core/hcd.c:1617
usb_kill_urb drivers/usb/core/urb.c:716 [inline]
usb_kill_urb+0x121/0x320 drivers/usb/core/urb.c:703
hub_quiesce+0x1e9/0x320 drivers/usb/core/hub.c:1417
hub_suspend+0x4ab/0x9e0 drivers/usb/core/hub.c:4021
usb_suspend_interface drivers/usb/core/driver.c:1327 [inline]
usb_suspend_both+0x288/0x950 drivers/usb/core/driver.c:1450
usb_runtime_suspend+0x49/0x120 drivers/usb/core/driver.c:2004
__rpm_callback+0xc8/0x620 drivers/base/power/runtime.c:406
rpm_callback+0x11f/0x150 drivers/base/power/runtime.c:460
rpm_suspend+0x2f4/0x1220 drivers/base/power/runtime.c:695
__pm_runtime_suspend+0xba/0x1a0 drivers/base/power/runtime.c:1167
pm_runtime_put_sync_autosuspend include/linux/pm_runtime.h:740 [inline]
usb_new_device.part.0+0x1653/0x1686 drivers/usb/core/hub.c:2740
register_root_hub+0x4e6/0x639 drivers/usb/core/hcd.c:990
usb_add_hcd.cold+0xccd/0x1158 drivers/usb/core/hcd.c:2987
vhci_hcd_probe+0x14b/0x4e0 drivers/usb/usbip/vhci_hcd.c:1388
platform_probe+0x106/0x1d0 drivers/base/platform.c:1507
call_driver_probe drivers/base/dd.c:628 [inline]
really_probe+0x241/0xa60 drivers/base/dd.c:706
__driver_probe_device+0x210/0x460 drivers/base/dd.c:868
driver_probe_device+0x4a/0x140 drivers/base/dd.c:898
__device_attach_driver+0x1df/0x320 drivers/base/dd.c:1026
bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:500
__device_attach+0x1e4/0x4d0 drivers/base/dd.c:1098
device_initial_probe+0xaf/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x64/0x160 drivers/base/bus.c:620
device_add+0x121d/0x1970 drivers/base/core.c:3776
platform_device_add+0x35a/0x800 drivers/base/platform.c:833
platform_device_register_full+0x507/0x720 drivers/base/platform.c:970
vhci_hcd_init+0x1a1/0x2f0 drivers/usb/usbip/vhci_hcd.c:1557
do_one_initcall+0x11c/0x6f0 init/main.c:1362
do_initcall_level init/main.c:1424 [inline]
do_initcalls init/main.c:1440 [inline]
do_basic_setup init/main.c:1460 [inline]
kernel_init_freeable+0x6ea/0x7b0 init/main.c:1675
kernel_init+0x21/0x1e0 init/main.c:1565
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
Second to last potentially related work creation:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_record_aux_stack+0xa7/0xc0 mm/kasan/generic.c:556
insert_work+0x36/0x230 kernel/workqueue.c:2272
__queue_work+0xa60/0x1370 kernel/workqueue.c:2448
queue_work_on+0x1a9/0x1e0 kernel/workqueue.c:2501
queue_work include/linux/workqueue.h:700 [inline]
usb_hcd_giveback_urb+0x3b8/0x4a0 drivers/usb/core/hcd.c:1760
rh_call_control drivers/usb/core/hcd.c:706 [inline]
rh_urb_enqueue drivers/usb/core/hcd.c:817 [inline]
usb_hcd_submit_urb+0xab7/0x2150 drivers/usb/core/hcd.c:1538
usb_submit_urb+0x827/0x19b0 drivers/usb/core/urb.c:586
usb_start_wait_urb+0x10e/0x580 drivers/usb/core/message.c:62
usb_internal_control_msg drivers/usb/core/message.c:117 [inline]
usb_control_msg+0x328/0x4b0 drivers/usb/core/message.c:167
get_port_status drivers/usb/core/hub.c:607 [inline]
hub_ext_port_status+0x14e/0x690 drivers/usb/core/hub.c:624
usb_hub_port_status drivers/usb/core/hub.c:674 [inline]
hub_activate+0x6e5/0x1c40 drivers/usb/core/hub.c:1190
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
process_scheduled_works kernel/workqueue.c:3479 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
The buggy address belongs to the object at ffff888022a54000
which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 768 bytes inside of
freed 8192-byte region [ffff888022a54000, ffff888022a56000)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x22a50
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88801c043180 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000020002 00000000f5000000 0000000000000000
head: 00fff00000000040 ffff88801c043180 dead000000000100 dead000000000122
head: 0000000000000000 0000000000020002 00000000f5000000 0000000000000000
head: 00fff00000000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, tgid 1 (swapper/0), ts 7221018769
set_page_owner include/linux/page_owner.h:33 [inline]
post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1871
prep_new_page mm/page_alloc.c:1879 [inline]
get_page_from_freelist+0x110d/0x35d0 mm/page_alloc.c:3943
__alloc_frozen_pages_noprof+0x2eb/0x3300 mm/page_alloc.c:5436
alloc_slab_page mm/slub.c:3347 [inline]
allocate_slab mm/slub.c:3462 [inline]
new_slab+0xa9/0x6e0 mm/slub.c:3513
refill_objects+0xe3/0x410 mm/slub.c:7417
refill_sheaf mm/slub.c:2885 [inline]
__pcs_replace_empty_main+0x35e/0x650 mm/slub.c:4774
alloc_from_pcs mm/slub.c:4850 [inline]
slab_alloc_node mm/slub.c:4984 [inline]
__do_kmalloc_node mm/slub.c:5413 [inline]
__kmalloc_noprof+0x67c/0x840 mm/slub.c:5439
_kmalloc_noprof include/linux/slab.h:995 [inline]
acpi_ut_initialize_buffer+0x144/0x220 drivers/acpi/acpica/utalloc.c:327
acpi_rs_create_pci_routing_table+0x135/0xe00 drivers/acpi/acpica/rscreate.c:212
acpi_rs_get_prt_method_data+0xc1/0x150 drivers/acpi/acpica/rsutils.c:456
acpi_get_irq_routing_table+0xb8/0x140 drivers/acpi/acpica/rsxface.c:137
acpi_pci_irq_find_prt_entry+0x179/0xdd0 drivers/acpi/pci_irq.c:215
acpi_pci_irq_lookup+0x8e/0x6b0 drivers/acpi/pci_irq.c:299
acpi_pci_irq_disable+0x1a8/0x360 drivers/acpi/pci_irq.c:499
pcibios_disable_device arch/x86/pci/common.c:706 [inline]
pcibios_disable_device+0x89/0xb0 arch/x86/pci/common.c:703
do_pci_disable_device+0x9f/0x100 drivers/pci/pci.c:2203
page_owner free stack trace missing
Memory state around the buggy address:
ffff888022a54200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888022a54280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888022a54300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888022a54380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888022a54400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Reply: The bug report is **actionable** and **self-consistent**.
### Analysis:
1. **Stack Traces Presence & Subsystem Consistency:**
The report contains all 3 necessary stack traces (plus auxiliary work creation stacks), all belonging to the USB core / USB HCD subsystem:
- **Access stack:** A worker task (`ksoftirqd`) executing `usb_giveback_urb_bh()` at `drivers/usb/core/hcd.c:1692` performs an 8-byte write (`bh->completing_ep = NULL;`).
- **Allocation stack:** `struct usb_hcd` is allocated by `__usb_create_hcd()` at `drivers/usb/core/hcd.c:2566` during `vhci_hcd_probe()`.
- **Free stack:** `struct usb_hcd` is released by `usb_put_hcd()` / `hcd_release()` at `drivers/usb/core/hcd.c:2690` during error handling in `vhci_hcd_probe()`.
2. **Memory Layout and Field Offset Verification:**
- Object base address: `0xffff888022a54000`
- Access address: `0xffff888022a54300` (offset `+768` bytes / `0x300`)
- In `struct usb_hcd`, the member `high_prio_bh` (of type `struct giveback_urb_bh`) begins at offset `4864` bits (`608` bytes).
- In `struct giveback_urb_bh`, the field `completing_ep` is located at offset `1280` bits (`160` bytes).
- `608 + 160 = 768` bytes, which matches the offset `0x300` exactly.
- The operation `bh->completing_ep = NULL;` is a pointer write of 8 bytes, which precisely matches the report's `Write of size 8 at addr ffff888022a54300`.
3. **Root Cause Analysis:**
- During `vhci_hcd_probe()`, `usb_add_hcd()` is called, which initializes the bottom-half giveback work structures (`high_prio_bh` and `low_prio_bh`) embedded in `struct usb_hcd`.
- During `register_root_hub()`, URB activity occurs and URB giveback work is queued to the BH workqueue (`usb_hcd_giveback_urb()` queues `&hcd->high_prio_bh.bh`).
- If an error occurs during root hub registration / probe, `usb_add_hcd()` fails and unwinds to `vhci_hcd_probe()`'s error exit path, which calls `usb_put_hcd()`.
- β Because the pending BH works (`high_prio_bh` / `low_prio_bh`) were neither flushed nor cancelled before `hcd` was freed, the workqueue executes `usb_giveback_urb_bh()` asynchronously after `hcd` has already been freed, resulting in a use-after-free write.
|
| 5/2 |
2026/09/29 03:46 |
llm |
expert |
0m
Model:
Tokens:
input: 10845
output: 117
thoughts: 1050
Thoughts: **KASAN Report Analysis: Actionable or Not?**
Alright, let's dive into this KASAN slab-use-after-free report. My primary goal is to determine if it's actionable β meaning, can I reasonably pinpoint the root cause from the information provided? I need to verify its self-consistency and overall coherence. The provided guidelines are clear: I'm looking for three stack traces (access, allocation, and free), all pointing to the *same* object type, ideally within the same kernel subsystem. Inconsistencies will immediately raise a red flag. Nonsense reports are a complete waste of time, so I'll be thorough.
First, I see the report describes a "slab-use-after-free" in `usb_giveback_urb_bh`. Good start β a very specific bug class reported by KASAN. Now, let's examine the evidence:
1. **Access Stack:** I have a write access at `usb_giveback_urb_bh` in `drivers/usb/core/hcd.c`. The reported address is `ffff888022a54300`. This corresponds to a write of 8 bytes.
2. **Allocation Stack:** The allocation stack points to `__usb_create_hcd` and then to `vhci_hcd_probe` in `drivers/usb/usbip/vhci_hcd.c`. So, a `vhci_hcd` (Virtual Host Controller Interface) is apparently being created at some point.
3. **Free Stack:** The free stack is also interesting, pointing to `kfree`, and includes the freeing of the HCD via `hcd_release` and `usb_put_hcd` in `drivers/usb/core/hcd.c`, and again in `vhci_hcd_probe`.
So far, it looks promising. All three stacks appear related to USB/HCD management, specifically the `vhci` implementation. I need to make sure this aligns with the object description.
The object in question is at `ffff888022a54000` from the `kmalloc-8k` cache, with the buggy access happening at an offset of 768 bytes (0x300) from the start. That should definitely be checked, though!
Now, I'm going to consult the code. I'll need to use `read-file` or `codesearch-definition-source` on `drivers/usb/core/hcd.c` and `drivers/usb/usbip/vhci_hcd.c` to confirm my assumptions and get some context, check if the allocation stack relates to the freeing stack.
Once I've verified the object type and allocation/free relationship, I will be able to make a final conclusion about actionability and generate a reply.
|
| 6/2 |
2026/09/29 03:46 |
tool |
read-file |
0m
Args: map[File:drivers/usb/core/hcd.c FirstLine:1680 LineCount:40]
Results: map[Contents:1680: spin_lock_irq(&bh->lock);
1681: bh->running = true;
1682: list_replace_init(&bh->head, &local_list);
1683: spin_unlock_irq(&bh->lock);
1684:
1685: while (!list_empty(&local_list)) {
1686: struct urb *urb;
1687:
1688: urb = list_entry(local_list.next, struct urb, urb_list);
1689: list_del_init(&urb->urb_list);
1690: bh->completing_ep = urb->ep;
1691: __usb_hcd_giveback_urb(urb);
1692: bh->completing_ep = NULL;
1693: }
1694:
1695: /*
1696: * giveback new URBs next time to prevent this function
1697: * from not exiting for a long time.
1698: */
1699: spin_lock_irq(&bh->lock);
1700: if (!list_empty(&bh->head)) {
1701: if (bh->high_prio)
1702: queue_work(system_bh_highpri_wq, &bh->bh);
1703: else
1704: queue_work(system_bh_wq, &bh->bh);
1705: }
1706: bh->running = false;
1707: spin_unlock_irq(&bh->lock);
1708: }
1709:
1710: /**
1711: * usb_hcd_giveback_urb - return URB from HCD to device driver
1712: * @hcd: host controller returning the URB
1713: * @urb: urb being returned to the USB device driver.
1714: * @status: completion status code for the URB.
1715: *
1716: * Context: atomic. The completion callback is invoked either in a work queue
1717: * (BH) context or in the caller's context, depending on whether the HCD_BH
1718: * flag is set in the @hcd structure, except that URBs submitted to the
1719: * root hub always complete in BH context.
]
|
| 7/2 |
2026/09/29 03:46 |
tool |
read-file |
0m
Args: map[File:drivers/usb/core/hcd.c FirstLine:2555 LineCount:40]
Results: map[Contents:2555: spin_lock_init(&bh->lock);
2556: INIT_LIST_HEAD(&bh->head);
2557: INIT_WORK(&bh->bh, usb_giveback_urb_bh);
2558: }
2559:
2560: struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
2561: struct device *sysdev, struct device *dev, const char *bus_name,
2562: struct usb_hcd *primary_hcd)
2563: {
2564: struct usb_hcd *hcd;
2565:
2566: hcd = kzalloc(sizeof(*hcd) + driver->hcd_priv_size, GFP_KERNEL);
2567: if (!hcd)
2568: return NULL;
2569: if (primary_hcd == NULL) {
2570: hcd->address0_mutex = kmalloc_obj(*hcd->address0_mutex);
2571: if (!hcd->address0_mutex) {
2572: kfree(hcd);
2573: dev_dbg(dev, "hcd address0 mutex alloc failed\n");
2574: return NULL;
2575: }
2576: mutex_init(hcd->address0_mutex);
2577: hcd->bandwidth_mutex = kmalloc_obj(*hcd->bandwidth_mutex);
2578: if (!hcd->bandwidth_mutex) {
2579: kfree(hcd->address0_mutex);
2580: kfree(hcd);
2581: dev_dbg(dev, "hcd bandwidth mutex alloc failed\n");
2582: return NULL;
2583: }
2584: mutex_init(hcd->bandwidth_mutex);
2585: dev_set_drvdata(dev, hcd);
2586: } else {
2587: mutex_lock(&usb_port_peer_mutex);
2588: hcd->address0_mutex = primary_hcd->address0_mutex;
2589: hcd->bandwidth_mutex = primary_hcd->bandwidth_mutex;
2590: hcd->primary_hcd = primary_hcd;
2591: primary_hcd->primary_hcd = primary_hcd;
2592: hcd->shared_hcd = primary_hcd;
2593: primary_hcd->shared_hcd = hcd;
2594: mutex_unlock(&usb_port_peer_mutex);
]
|
| 8/2 |
2026/09/29 03:46 |
tool |
read-file |
0m
Args: map[File:drivers/usb/core/hcd.c FirstLine:2680 LineCount:35]
Results: map[Contents:2680: if (hcd->shared_hcd) {
2681: struct usb_hcd *peer = hcd->shared_hcd;
2682:
2683: peer->shared_hcd = NULL;
2684: peer->primary_hcd = NULL;
2685: } else {
2686: kfree(hcd->address0_mutex);
2687: kfree(hcd->bandwidth_mutex);
2688: }
2689: mutex_unlock(&usb_port_peer_mutex);
2690: kfree(hcd);
2691: }
2692:
2693: struct usb_hcd *usb_get_hcd(struct usb_hcd *hcd)
2694: {
2695: if (hcd)
2696: kref_get(&hcd->kref);
2697: return hcd;
2698: }
2699: EXPORT_SYMBOL_GPL(usb_get_hcd);
2700:
2701: void usb_put_hcd(struct usb_hcd *hcd)
2702: {
2703: if (hcd)
2704: kref_put(&hcd->kref, hcd_release);
2705: }
2706: EXPORT_SYMBOL_GPL(usb_put_hcd);
2707:
2708: int usb_hcd_is_primary_hcd(struct usb_hcd *hcd)
2709: {
2710: if (!hcd->primary_hcd)
2711: return 1;
2712: return hcd == hcd->primary_hcd;
2713: }
2714: EXPORT_SYMBOL_GPL(usb_hcd_is_primary_hcd);
]
|
| 9/2 |
2026/09/29 03:46 |
llm |
expert |
0m
Model:
Tokens:
input: 14514
output: 39
thoughts: 23
Thoughts: Okay, let's dive into this code.
**Investigating `usb_giveback_urb_bh`**
Right, so I'm looking at this code and I need to understand how this USB device driver is handling URBs. The function name `usb_giveback_urb_bh` immediately suggests it's related to returning a URB, likely in a bottom-half context, which implies it's deferred from an interrupt or something similar. Line 1670... that's a pretty specific reference. Time to zoom in on that line and the surrounding code. I need to see what's going on *around* that definition. What's the context? What other data structures or functions is it interacting with? Understanding the surrounding code will likely unlock the purpose of this function in terms of URB completions. I'll need to examine the interactions with device state, queue management and how it impacts the overall USB transaction. Let's get to it.
|
| 10/2 |
2026/09/29 03:46 |
tool |
read-file |
0m
Args: map[File:drivers/usb/core/hcd.c FirstLine:1660 LineCount:40]
Results: map[Contents:1660: usb_anchor_resume_wakeups(anchor);
1661: atomic_dec(&urb->use_count);
1662: /*
1663: * Order the write of urb->use_count above before the read
1664: * of urb->reject below. Pairs with the memory barriers in
1665: * usb_kill_urb() and usb_poison_urb().
1666: */
1667: smp_mb__after_atomic();
1668:
1669: if (unlikely(atomic_read(&urb->reject)))
1670: wake_up(&usb_kill_urb_queue);
1671: usb_put_urb(urb);
1672: }
1673:
1674: static void usb_giveback_urb_bh(struct work_struct *work)
1675: {
1676: struct giveback_urb_bh *bh =
1677: container_of(work, struct giveback_urb_bh, bh);
1678: struct list_head local_list;
1679:
1680: spin_lock_irq(&bh->lock);
1681: bh->running = true;
1682: list_replace_init(&bh->head, &local_list);
1683: spin_unlock_irq(&bh->lock);
1684:
1685: while (!list_empty(&local_list)) {
1686: struct urb *urb;
1687:
1688: urb = list_entry(local_list.next, struct urb, urb_list);
1689: list_del_init(&urb->urb_list);
1690: bh->completing_ep = urb->ep;
1691: __usb_hcd_giveback_urb(urb);
1692: bh->completing_ep = NULL;
1693: }
1694:
1695: /*
1696: * giveback new URBs next time to prevent this function
1697: * from not exiting for a long time.
1698: */
1699: spin_lock_irq(&bh->lock);
]
|
| 11/2 |
2026/09/29 03:46 |
llm |
expert |
0m
Model:
Tokens:
input: 15396
output: 46
thoughts: 94
Thoughts: Here's my thought process, as it stands:
**Dissecting the `usb_giveback_urb_bh` Function**
Okay, diving into this `usb_giveback_urb_bh` function, let's see what's happening. Right away, on line 1692, I see `bh->completing_ep = NULL;`. My first question is, what is `bh`? It seems like a core element here. I need to understand its context. Where is this `bh` variable defined? I need to track down the declaration of `giveback_urb_bh bh`. Is it a local variable? A member of a larger structure, maybe within `struct usb_hcd`? Time to trace its definition. I'll search for `giveback_urb_bh` or, failing that, I'll examine the members of the `struct usb_hcd` to see if it's nested in there somewhere. Understanding `bh` is key to understanding this particular function.
|
| 12/2 |
2026/09/29 03:46 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:drivers/usb/core/hcd.c IncludeSnippetLines:5 Name:giveback_urb_bh]
Results: map[References:[map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:init_giveback_urb_bh SourceFile:drivers/usb/core/hcd.c SourceLine:2552 SourceSnippet:2552: static void init_giveback_urb_bh(struct giveback_urb_bh *bh)
2553: {
2554:
2555: spin_lock_init(&bh->lock);
2556: INIT_LIST_HEAD(&bh->head);
2557: INIT_WORK(&bh->bh, usb_giveback_urb_bh);
] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:usb_giveback_urb_bh SourceFile:drivers/usb/core/hcd.c SourceLine:1676 SourceSnippet:1674: static void usb_giveback_urb_bh(struct work_struct *work)
1675: {
1676: struct giveback_urb_bh *bh =
1677: container_of(work, struct giveback_urb_bh, bh);
1678: struct list_head local_list;
1679:
1680: spin_lock_irq(&bh->lock);
1681: bh->running = true;
] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:usb_giveback_urb_bh SourceFile:drivers/usb/core/hcd.c SourceLine:1677 SourceSnippet:1674: static void usb_giveback_urb_bh(struct work_struct *work)
1675: {
1676: struct giveback_urb_bh *bh =
1677: container_of(work, struct giveback_urb_bh, bh);
1678: struct list_head local_list;
1679:
1680: spin_lock_irq(&bh->lock);
1681: bh->running = true;
1682: list_replace_init(&bh->head, &local_list);
] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:usb_giveback_urb_bh SourceFile:drivers/usb/core/hcd.c SourceLine:1677 SourceSnippet:1674: static void usb_giveback_urb_bh(struct work_struct *work)
1675: {
1676: struct giveback_urb_bh *bh =
1677: container_of(work, struct giveback_urb_bh, bh);
1678: struct list_head local_list;
1679:
1680: spin_lock_irq(&bh->lock);
1681: bh->running = true;
1682: list_replace_init(&bh->head, &local_list);
] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:usb_giveback_urb_bh SourceFile:drivers/usb/core/hcd.c SourceLine:1677 SourceSnippet:1674: static void usb_giveback_urb_bh(struct work_struct *work)
1675: {
1676: struct giveback_urb_bh *bh =
1677: container_of(work, struct giveback_urb_bh, bh);
1678: struct list_head local_list;
1679:
1680: spin_lock_irq(&bh->lock);
1681: bh->running = true;
1682: list_replace_init(&bh->head, &local_list);
] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:usb_hcd_giveback_urb SourceFile:drivers/usb/core/hcd.c SourceLine:1733 SourceSnippet:1728: * @urb->unlinked. Erroneous short transfers are detected in case
1729: * the HCD hasn't checked for them.
1730: */
1731: void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
1732: {
1733: struct giveback_urb_bh *bh;
1734: bool running;
1735:
1736: /* pass status to BH via unlinked */
1737: if (likely(!urb->unlinked))
1738: urb->unlinked = status;
]] TruncatedOutput:false]
|
| 13/2 |
2026/09/29 03:46 |
llm |
expert |
0m
Model:
Tokens:
input: 16991
output: 40
thoughts: 24
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience and presented in the first person:
**Diving into the USB HCD Structures**
Alright, let's get down to brass tacks. I'm thinking I need to refresh my memory on the specifics of `struct giveback_urb_bh` and `struct usb_hcd`. While I've worked with these structures countless times, a quick review is always a good idea, especially when I'm dealing with particularly thorny USB host controller driver issues. I need to make sure I'm crystal clear on how they interact. Specifically, I want to confirm how the giveback behavior is handled within the context of the HCD. What's the exact flow and data associated with that callback? It's easy to get lost in the weeds on this, and ensuring I know the precise mechanics of the structures is going to be key to debugging. Let me pull up those definitions and confirm my understanding.
|
| 14/2 |
2026/09/29 03:46 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/core/hcd.c Name:giveback_urb_bh]
Results: map[SourceCode: 53: struct giveback_urb_bh {
54: bool running;
55: bool high_prio;
56: spinlock_t lock;
57: struct list_head head;
58: struct work_struct bh;
59: struct usb_host_endpoint *completing_ep;
60: };
SourceFile:include/linux/usb/hcd.h]
|
| 15/2 |
2026/09/29 03:46 |
llm |
expert |
0m
Model:
Tokens:
input: 17389
output: 38
thoughts: 91
Thoughts: **Analyzing USB Host Controller Data Structures**
Okay, so I'm looking at this `struct giveback_urb_bh` and immediately I notice it contains a `struct usb_host_endpoint *completing_ep`. That's interesting, as this is a core structure in USB handling, and this pointer is how we track which endpoint the URB is associated with. Then, I see on line 1692, the code is setting `bh->completing_ep` to `NULL`. This is a straightforward 8-byte write, typically on a pointer, signifying the completion endpoint has been cleared.
The next question I have is about how and where `struct giveback_urb_bh` is allocated and used. To understand that, I need to see how it's embedded or allocated. Time to dive into the `struct usb_hcd` layout and see how this is all connected. I have a feeling the answer lies there. Let's see...
|
| 16/2 |
2026/09/29 03:46 |
tool |
codesearch-struct-layout |
0m
Args: map[ContextFile:drivers/usb/core/hcd.c Name:usb_hcd]
Results: map[Fields:[map[Name:self OffsetBits:0 SizeBits:1984] map[Name:kref OffsetBits:1984 SizeBits:32] map[Name:product_desc OffsetBits:2048 SizeBits:64] map[Name:speed OffsetBits:2112 SizeBits:32] map[Name:irq_descr OffsetBits:2144 SizeBits:192] map[Name:rh_timer OffsetBits:2368 SizeBits:640] map[Name:status_urb OffsetBits:3008 SizeBits:64] map[Name:wakeup_work OffsetBits:3072 SizeBits:576] map[Name:died_work OffsetBits:3648 SizeBits:576] map[Name:driver OffsetBits:4224 SizeBits:64] map[Name:usb_phy OffsetBits:4288 SizeBits:64] map[Name:phy_roothub OffsetBits:4352 SizeBits:64] map[Name:flags OffsetBits:4416 SizeBits:64] map[Name:dev_policy OffsetBits:4480 SizeBits:32] map[Name:rh_registered OffsetBits:4512 SizeBits:1] map[Name:rh_pollable OffsetBits:4513 SizeBits:1] map[Name:msix_enabled OffsetBits:4514 SizeBits:1] map[Name:msi_enabled OffsetBits:4515 SizeBits:1] map[Name:skip_phy_initialization OffsetBits:4516 SizeBits:1] map[Name:uses_new_polling OffsetBits:4517 SizeBits:1] map[Name:has_tt OffsetBits:4518 SizeBits:1] map[Name:amd_resume_bug OffsetBits:4519 SizeBits:1] map[Name:can_do_streams OffsetBits:4520 SizeBits:1] map[Name:tpl_support OffsetBits:4521 SizeBits:1] map[Name:cant_recv_wakeups OffsetBits:4522 SizeBits:1] map[Name:irq OffsetBits:4544 SizeBits:32] map[Name:regs OffsetBits:4608 SizeBits:64] map[Name:rsrc_start OffsetBits:4672 SizeBits:64] map[Name:rsrc_len OffsetBits:4736 SizeBits:64] map[Name:power_budget OffsetBits:4800 SizeBits:32] map[Name:high_prio_bh OffsetBits:4864 SizeBits:1344] map[Name:low_prio_bh OffsetBits:6208 SizeBits:1344] map[Name:address0_mutex OffsetBits:7552 SizeBits:64] map[Name:bandwidth_mutex OffsetBits:7616 SizeBits:64] map[Name:shared_hcd OffsetBits:7680 SizeBits:64] map[Name:primary_hcd OffsetBits:7744 SizeBits:64] map[Name:pool OffsetBits:7808 SizeBits:256] map[Name:state OffsetBits:8064 SizeBits:32] map[Name:localmem_pool OffsetBits:8128 SizeBits:64] map[Name:hcd_priv OffsetBits:8192 SizeBits:0]]]
|
| 17/2 |
2026/09/29 03:46 |
llm |
expert |
0m
Model:
Tokens:
input: 18629
output: 40
thoughts: 120
Thoughts: Okay, here's what's going through my mind as I analyze this:
**Analyzing `usb_hcd` Field Offsets**
Alright, let's dive into these `OffsetBits` for the fields in `usb_hcd`. Hmm, specifically, I'm looking at `high_prio_bh` and `low_prio_bh`. Okay, `high_prio_bh` is at offset 4864 bits, which is 608 bytes. And `low_prio_bh` is at 6208 bits, or 776 bytes. Interesting. Now, I'm wondering about the *structure* of these variables. What exactly is the layout of `high_prio_bh` and `low_prio_bh`? I need more context to understand what's happening. I know I have seen giveback_urb_bh before, so let me start there...
|
| 18/2 |
2026/09/29 03:47 |
tool |
codesearch-struct-layout |
0m
Args: map[ContextFile:drivers/usb/core/hcd.c Name:giveback_urb_bh]
Results: map[Fields:[map[Name:running OffsetBits:0 SizeBits:8] map[Name:high_prio OffsetBits:8 SizeBits:8] map[Name:lock OffsetBits:64 SizeBits:512] map[Name:head OffsetBits:576 SizeBits:128] map[Name:bh OffsetBits:704 SizeBits:576] map[Name:completing_ep OffsetBits:1280 SizeBits:64]]]
|
| 19/2 |
2026/09/29 03:47 |
llm |
expert |
0m
Model:
Tokens:
input: 19128
output: 43
thoughts: 516
Thoughts: **Analyzing a USB HCD Crash**
Okay, let's break down this crash report. The key here seems to be a memory corruption issue within the USB host controller driver (`usb_hcd`). The crash dump pinpoints a write of 8 bytes at address `ffff888022a54300`. This address is 768 bytes into a freed 8192-byte region, and we know `ksoftirqd/1/30` is the culprit.
First, let's confirm the offset calculation. I see `completing_ep` is at OffsetBits 1280 bits, or 160 bytes within `giveback_urb_bh`. And `high_prio_bh` in `usb_hcd` sits at 4864 bits, which is 608 bytes. Adding these gives me 608 + 160 = 768 bytes, or 0x300 in hex. Exactly what the crash report indicates! This aligns perfectly with `ffff888022a54000 + 768 = ffff888022a54300`, the address the crash report flagged.
Now, the crucial clue. This 8-byte write corresponds to `bh->completing_ep = NULL;` at `drivers/usb/core/hcd.c:1692`. This means we are attempting to nullify the `completing_ep` pointer within the `high_prio_bh` structure, which we've confirmed is offset at 768.
Where does this `hcd` structure live? `__usb_create_hcd+0x5e/0xac0 drivers/usb/core/hcd.c:2566` allocates `hcd` using `kzalloc` (and adds the `hcd_priv_size` to the allocation!). And it's freed via `kfree(hcd)` in `hcd_release drivers/usb/core/hcd.c:2690` which is in turn called via `usb_put_hcd` at `drivers/usb/usbip/vhci_hcd.c:1415`!
So, the issue is clear: we're writing to a freed `usb_hcd` structure. The question now is why is this write happening *after* the `hcd` has been freed? We need to investigate the `vhci_hcd` code, specifically around lines 1378 and 1415 in `drivers/usb/usbip/vhci_hcd.c`. This is where the `hcd` is being released. We need to identify any potential race conditions, delayed work or improper synchronization. The core of the problem lies in the timing of the freeing of `hcd` relative to other code still attempting to use parts of it, specifically the `high_prio_bh`. I need to understand the control flow in that section of `vhci_hcd.c` better.
|
| 20/2 |
2026/09/29 03:47 |
tool |
read-file |
0m
Args: map[File:drivers/usb/usbip/vhci_hcd.c FirstLine:1370 LineCount:60]
Results: map[Contents:1370: int ret;
1371:
1372: usbip_dbg_vhci_hc("name %s id %d\n", pdev->name, pdev->id);
1373:
1374: /*
1375: * Allocate and initialize hcd.
1376: * Our private data is also allocated automatically.
1377: */
1378: hcd_hs = usb_create_hcd(&vhci_hc_driver, &pdev->dev, dev_name(&pdev->dev));
1379: if (!hcd_hs)
1380: return dev_err_probe(&pdev->dev, -ENOMEM, "create primary hcd failed\n");
1381:
1382: hcd_hs->has_tt = 1;
1383:
1384: /*
1385: * Finish generic HCD structure initialization and register.
1386: * Call the driver's reset() and start() routines.
1387: */
1388: ret = usb_add_hcd(hcd_hs, 0, 0);
1389: if (ret) {
1390: dev_err_probe(&pdev->dev, ret, "usb_add_hcd hs failed\n");
1391: goto put_usb2_hcd;
1392: }
1393:
1394: hcd_ss = usb_create_shared_hcd(&vhci_hc_driver, &pdev->dev,
1395: dev_name(&pdev->dev), hcd_hs);
1396: if (!hcd_ss) {
1397: ret = dev_err_probe(&pdev->dev, -ENOMEM, "create shared hcd failed\n");
1398: goto remove_usb2_hcd;
1399: }
1400:
1401: ret = usb_add_hcd(hcd_ss, 0, 0);
1402: if (ret) {
1403: dev_err_probe(&pdev->dev, ret, "usb_add_hcd ss failed\n");
1404: goto put_usb3_hcd;
1405: }
1406:
1407: usbip_dbg_vhci_hc("bye\n");
1408: return 0;
1409:
1410: put_usb3_hcd:
1411: usb_put_hcd(hcd_ss);
1412: remove_usb2_hcd:
1413: usb_remove_hcd(hcd_hs);
1414: put_usb2_hcd:
1415: usb_put_hcd(hcd_hs);
1416: vhci->vhci_hcd_hs = NULL;
1417: vhci->vhci_hcd_ss = NULL;
1418: return ret;
1419: }
1420:
1421: static void vhci_hcd_remove(struct platform_device *pdev)
1422: {
1423: struct vhci *vhci = *((void **)dev_get_platdata(&pdev->dev));
1424:
1425: /*
1426: * Disconnects the root hub,
1427: * then reverses the effects of usb_add_hcd(),
1428: * invoking the HCD's stop() methods.
1429: */
]
|
| 21/2 |
2026/09/29 03:47 |
llm |
expert |
0m
Model:
Tokens:
input: 21345
output: 39
thoughts: 627
Thoughts: **Analyzing the USB Host Controller Driver Probe Failure**
Okay, let's break this down. I'm looking at `vhci_hcd_probe`, specifically line 1388 where `usb_add_hcd(hcd_hs, 0, 0);` is called. The crash report's aux work creation trace is pointing me towards the failure being tied to the `usb_add_hcd` call. The trace shows a sequence: `usb_add_hcd.cold`, `register_root_hub`, `usb_new_device`, down to `pm_runtime_put_sync_autosuspend`, and then ultimately leading to `unlink1` and `usb_hcd_giveback_urb` and finally `queue_work(...)`. The call to `usb_add_hcd` (or possibly `usb_create_shared_hcd` followed by another `usb_add_hcd`) failed.
The report also shows that task 1 freed some resources at `vhci_hcd_probe+0x342/0x4e0`, specifically at line 1415, with `usb_put_hcd(hcd_hs);`. This is important, as it confirms that the failure, whatever the root cause, causes the code to jump to cleaning up after the initial add call. The code jumps there *because* `usb_add_hcd(hcd_hs)` or `usb_create_shared_hcd` failed!
I see that if `usb_add_hcd(hcd_hs)` returned an error (perhaps during the `register_root_hub` operation, or a suspend related failure within `usb_add_hcd`), the code directly branches to `goto put_usb2_hcd;` at line 1391. This leads to line 1415, which is `usb_put_hcd(hcd_hs);` (or if we're at line 1413, to `remove_usb2_hcd:` `usb_remove_hcd(hcd_hs)`). The crash, therefore, is directly related to a failure in the initial setup, immediately triggering the cleanup procedure.
My next step is to examine the `usb_add_hcd` and `usb_remove_hcd` functions more closely, focusing on line 2987 in `usb_add_hcd` and the `usb_remove_hcd` function. I need to understand exactly what might be going wrong in `register_root_hub` or during the hub interactions, which are called from `usb_add_hcd`, and which error causes the quick exit to cleanup.
|
| 22/2 |
2026/09/29 03:47 |
tool |
read-file |
0m
Args: map[File:drivers/usb/core/hcd.c FirstLine:2980 LineCount:40]
Results: map[Contents:2980:
2981: if (shared_hcd->uses_new_polling && HCD_POLL_RH(shared_hcd))
2982: usb_hcd_poll_rh_status(shared_hcd);
2983: }
2984:
2985: /* starting here, usbcore will pay attention to this root hub */
2986: if (!HCD_DEFER_RH_REGISTER(hcd)) {
2987: retval = register_root_hub(hcd);
2988: if (retval != 0)
2989: goto err_register_root_hub;
2990:
2991: if (hcd->uses_new_polling && HCD_POLL_RH(hcd))
2992: usb_hcd_poll_rh_status(hcd);
2993: }
2994:
2995: return retval;
2996:
2997: err_register_root_hub:
2998: usb_stop_hcd(hcd);
2999: err_hcd_driver_start:
3000: if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0)
3001: free_irq(irqnum, hcd);
3002: err_request_irq:
3003: err_hcd_driver_setup:
3004: err_set_rh_speed:
3005: usb_put_invalidate_rhdev(hcd);
3006: err_allocate_root_hub:
3007: usb_deregister_bus(&hcd->self);
3008: err_register_bus:
3009: hcd_buffer_destroy(hcd);
3010: err_create_buf:
3011: usb_phy_roothub_power_off(hcd->phy_roothub);
3012: err_usb_phy_roothub_power_on:
3013: usb_phy_roothub_exit(hcd->phy_roothub);
3014:
3015: return retval;
3016: }
3017: EXPORT_SYMBOL_GPL(usb_add_hcd);
3018:
3019: /**
]
|
| 23/2 |
2026/09/29 03:47 |
llm |
expert |
0m
Model:
Tokens:
input: 23250
output: 41
thoughts: 102
Thoughts: Okay, here's my take on those thoughts, framed from my perspective as an expert in this area:
**Analyzing USB Host Controller Driver (HCD) Shutdown**
Alright, let's dive into this `err_register_root_hub:` function. Specifically, I'm focusing on the `usb_stop_hcd(hcd);` call. This is the critical point where the HCD is being shut down. My immediate concern is ensuring a clean and safe shutdown, preventing potential resource leaks or race conditions.
My primary focus here is the workqueue behavior. I need to absolutely confirm that the high and low priority bottom halves (`hcd->high_prio_bh.bh` and `hcd->low_prio_bh.bh`, respectively) are *properly* handled during this shutdown sequence. The key question is whether `cancel_work_sync` is being invoked on them. If not, we have a significant problem β potentially stale work items continuing to run or incomplete transactions causing corruption.
Therefore, my next step is a targeted code search. I'm going to look for all instances where `high_prio_bh` or `low_prio_bh` are cancelled or flushed. This is crucial to understanding the precise flow control during the shutdown and verifying that everything is handled correctly, and the corresponding work queues are properly cleaned up. A robust HCD is absolutely predicated on its clean shutdown procedure, and the bottom halves are critical to that procedure.
|
| 24/2 |
2026/09/29 03:47 |
tool |
grepper |
0m
Args: map[Expression:(high_prio_bh|low_prio_bh) PathPrefix:drivers/usb/core/]
Results: map[Output:drivers/usb/core/hcd.c=1731=void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
--
drivers/usb/core/hcd.c-1745- if (usb_pipeisoc(urb->pipe) || usb_pipeint(urb->pipe))
drivers/usb/core/hcd.c:1746: bh = &hcd->high_prio_bh;
drivers/usb/core/hcd.c-1747- else
drivers/usb/core/hcd.c:1748: bh = &hcd->low_prio_bh;
drivers/usb/core/hcd.c-1749-
--
drivers/usb/core/hcd.c=2802=int usb_add_hcd(struct usb_hcd *hcd,
--
drivers/usb/core/hcd.c-2953- /* initialize BHs */
drivers/usb/core/hcd.c:2954: init_giveback_urb_bh(&hcd->high_prio_bh);
drivers/usb/core/hcd.c:2955: hcd->high_prio_bh.high_prio = true;
drivers/usb/core/hcd.c:2956: init_giveback_urb_bh(&hcd->low_prio_bh);
drivers/usb/core/hcd.c-2957-
]
|
| 25/2 |
2026/09/29 03:47 |
llm |
expert |
0m
Model:
Tokens:
input: 24089
output: 45
thoughts: 143
Thoughts: Okay, let's dive into this USB host controller (HCD) code.
**Investigating USB Backlog Handler Cancellation**
Alright, my initial observation is that `high_prio_bh` and `low_prio_bh` are indeed initialized during `usb_add_hcd`. Specifically, I can see they are instantiated and their structures populated within that function: `init_giveback_urb_bh(&hcd->high_prio_bh)` and `init_giveback_urb_bh(&hcd->low_prio_bh)`. I can also see the assignment of the `high_prio` variable. Excellent, that's what I expected.
Now, where are these backlog handlers actually getting queued? Aha, they are used with `usb_hcd_giveback_urb`. Now my attention focuses on their lifecycle. I need to determine if there are scenarios where these backlog handlers get canceled gracefully. Specifically, I need to know if `cancel_work_sync` is ever called on either `hcd->high_prio_bh` or `hcd->low_prio_bh`. If not, is that a problem? Are they always executed to completion, or are they potentially left dangling? This is where my deeper analysis needs to focus. I'll need to trace the call paths to identify where cancellation might occur and assess the implications if it doesn't.
|
| 26/2 |
2026/09/29 03:47 |
tool |
grepper |
0m
Args: map[Expression:(usb_giveback_urb_bh|init_giveback_urb_bh) PathPrefix:drivers/usb/core/]
Results: map[Output:drivers/usb/core/hcd.c=1630=static void __usb_hcd_giveback_urb(struct urb *urb)
--
drivers/usb/core/hcd.c-1673-
drivers/usb/core/hcd.c:1674:static void usb_giveback_urb_bh(struct work_struct *work)
drivers/usb/core/hcd.c-1675-{
--
drivers/usb/core/hcd.c=2548=EXPORT_SYMBOL_GPL (usb_hc_died);
--
drivers/usb/core/hcd.c-2551-
drivers/usb/core/hcd.c:2552:static void init_giveback_urb_bh(struct giveback_urb_bh *bh)
drivers/usb/core/hcd.c-2553-{
--
drivers/usb/core/hcd.c-2556- INIT_LIST_HEAD(&bh->head);
drivers/usb/core/hcd.c:2557: INIT_WORK(&bh->bh, usb_giveback_urb_bh);
drivers/usb/core/hcd.c-2558-}
--
drivers/usb/core/hcd.c=2802=int usb_add_hcd(struct usb_hcd *hcd,
--
drivers/usb/core/hcd.c-2953- /* initialize BHs */
drivers/usb/core/hcd.c:2954: init_giveback_urb_bh(&hcd->high_prio_bh);
drivers/usb/core/hcd.c-2955- hcd->high_prio_bh.high_prio = true;
drivers/usb/core/hcd.c:2956: init_giveback_urb_bh(&hcd->low_prio_bh);
drivers/usb/core/hcd.c-2957-
]
|
| 27/2 |
2026/09/29 03:47 |
llm |
expert |
0m
Model:
Tokens:
input: 25070
output: 41
thoughts: 81
Thoughts: Here's my analysis of the situation:
**Investigating Potential Race Conditions in USB Host Controller (HCD) Code**
Okay, so I'm digging into this HCD code, and I'm immediately noticing a potential red flag. I'm searching the `hcd.c` file *very* carefully for any occurrences of `cancel_work_sync` targeting the `high_prio_bh` or `low_prio_bh` workqueues. And... nothing. Absolutely nothing. That's a bit unsettling. It strongly suggests that a planned graceful shutdown or cleanup might be missing, or that these workqueues are not being synchronized properly.
Now, before I jump to conclusions, I need to be methodical. Maybe this cancellation logic isn't directly within the `hcd.c` file itself. Perhaps it's handled differently elsewhere, especially considering there might be some refactoring going on, or changes to tasklets being migrated to workqueues. Time to hit the `git log`. I need to review the commit history related to `usb_giveback_urb_bh`. I'll also need to check for commits that mention the conversion of tasklets to workqueues, since that would be a natural place to look for subtle changes to how these workqueues are managed. This could be where the cancellation logic got moved, or perhaps overlooked altogether. Gotta trace the evolution of this code to see what's actually happening. I'm hoping I find something, otherwise, we have a serious issue on our hands, and it's time to start thinking about proposing a fix.
|
| 28/2 |
2026/09/29 03:47 |
tool |
git-log |
0m
Args: map[CodeRegexp:usb_giveback_urb_bh PathPrefix:drivers/usb/core/hcd.c]
Results: map[Output:8fea0c8fda30 usb: core: hcd: Convert from tasklet to BH workqueue
e71ea55a5b6f usb: hcd: convert tasklets to use new tasklet_setup() API
94dfd7edfd5c USB: HCD: support giveback of URB in tasklet context
]
|
| 29/2 |
2026/09/29 03:47 |
llm |
expert |
0m
Model:
Tokens:
input: 25621
output: 23
thoughts: 17
Thoughts: Okay, here's my interpretation of that prompt, and my response:
**Initial Assessment of Commit 8fea0c8fda30**
Alright, let's dive in. The instruction is to examine commit `8fea0c8fda30`. My immediate thought is, "Okay, show me the code, the diffs, the context." I'm mentally parsing this as a request to delve into a specific piece of work. I'm already anticipating the typical things I'll be looking for: what changed, why it changed, and what the implications of those modifications are within the larger scope of the project. I'm immediately running through a mental checklist: What's the file structure? What's the language? Are there any obvious red flags? Does the commit message provide enough context, or do I need to dig deeper into the issue tracker or pull request history? This is a starting point, and I'm ready to move forward.
|
| 30/2 |
2026/09/29 03:47 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 8fea0c8fda30129b4168464975505d5dc9735ac1
Author: Tejun Heo <tj@kernel.org>
Date: Sun Feb 4 11:34:34 2024 -1000
usb: core: hcd: Convert from tasklet to BH workqueue
The only generic interface to execute asynchronously in the BH context is
tasklet; however, it's marked deprecated and has some design flaws. To
replace tasklets, BH workqueue support was recently added. A BH workqueue
behaves similarly to regular workqueues except that the queued work items
are executed in the BH context.
This patch converts usb hcd from tasklet to BH workqueue.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 12b6dfeaf658..edf74458474a 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1664,9 +1664,10 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
usb_put_urb(urb);
}
-static void usb_giveback_urb_bh(struct tasklet_struct *t)
+static void usb_giveback_urb_bh(struct work_struct *work)
{
- struct giveback_urb_bh *bh = from_tasklet(bh, t, bh);
+ struct giveback_urb_bh *bh =
+ container_of(work, struct giveback_urb_bh, bh);
struct list_head local_list;
spin_lock_irq(&bh->lock);
@@ -1691,9 +1692,9 @@ static void usb_giveback_urb_bh(struct tasklet_struct *t)
spin_lock_irq(&bh->lock);
if (!list_empty(&bh->head)) {
if (bh->high_prio)
- tasklet_hi_schedule(&bh->bh);
+ queue_work(system_bh_highpri_wq, &bh->bh);
else
- tasklet_schedule(&bh->bh);
+ queue_work(system_bh_wq, &bh->bh);
}
bh->running = false;
spin_unlock_irq(&bh->lock);
@@ -1706,7 +1707,7 @@ static void usb_giveback_urb_bh(struct tasklet_struct *t)
* @status: completion status code for the URB.
*
* Context: atomic. The completion callback is invoked in caller's context.
- * For HCDs with HCD_BH flag set, the completion callback is invoked in tasklet
+ * For HCDs with HCD_BH flag set, the completion callback is invoked in BH
* context (except for URBs submitted to the root hub which always complete in
* caller's context).
*
@@ -1725,7 +1726,7 @@ void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
struct giveback_urb_bh *bh;
bool running;
- /* pass status to tasklet via unlinked */
+ /* pass status to BH via unlinked */
if (likely(!urb->unlinked))
urb->unlinked = status;
@@ -1747,9 +1748,9 @@ void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
if (running)
;
else if (bh->high_prio)
- tasklet_hi_schedule(&bh->bh);
+ queue_work(system_bh_highpri_wq, &bh->bh);
else
- tasklet_schedule(&bh->bh);
+ queue_work(system_bh_wq, &bh->bh);
}
EXPORT_SYMBOL_GPL(usb_hcd_giveback_urb);
@@ -2540,7 +2541,7 @@ static void init_giveback_urb_bh(struct giveback_urb_bh *bh)
spin_lock_init(&bh->lock);
INIT_LIST_HEAD(&bh->head);
- tasklet_setup(&bh->bh, usb_giveback_urb_bh);
+ INIT_WORK(&bh->bh, usb_giveback_urb_bh);
}
struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
@@ -2926,7 +2927,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
&& device_can_wakeup(&hcd->self.root_hub->dev))
dev_dbg(hcd->self.controller, "supports USB remote wakeup\n");
- /* initialize tasklets */
+ /* initialize BHs */
init_giveback_urb_bh(&hcd->high_prio_bh);
hcd->high_prio_bh.high_prio = true;
init_giveback_urb_bh(&hcd->low_prio_bh);
@@ -3036,7 +3037,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
mutex_unlock(&usb_bus_idr_lock);
/*
- * tasklet_kill() isn't needed here because:
+ * flush_work() isn't needed here because:
* - driver's disconnect() called from usb_disconnect() should
* make sure its URBs are completed during the disconnect()
* callback
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 00724b4f6e12..f698aac71de3 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -55,7 +55,7 @@ struct giveback_urb_bh {
bool high_prio;
spinlock_t lock;
struct list_head head;
- struct tasklet_struct bh;
+ struct work_struct bh;
struct usb_host_endpoint *completing_ep;
};
]
|
| 31/2 |
2026/09/29 03:47 |
llm |
expert |
0m
Model:
Tokens:
input: 27590
output: 39
thoughts: 108
Thoughts: **Analyzing USB Disconnect Handling**
Okay, so I'm diving into `drivers/usb/core/hcd.c`, specifically around lines 3030 to 3050. I need to understand why `flush_work()` isn't necessary in this particular context. According to the comment starting at line 3036, the disconnect path is already handled correctly. The driver's `disconnect()` function, which is called by `usb_disconnect()`, should make sure all its URBs (USB Request Blocks) are completed as part of the disconnection process. This means there's no need for an explicit `flush_work()` call because the driver has taken responsibility for ensuring that pending operations are cleaned up during the disconnect callback. I'll need to verify that this is indeed the case within the relevant driver code and that the assumptions hold up.
|
| 32/2 |
2026/09/29 03:47 |
tool |
read-file |
0m
Args: map[File:drivers/usb/core/hcd.c FirstLine:3030 LineCount:40]
Results: map[Contents:3030: struct usb_device *rhdev;
3031: bool rh_registered;
3032:
3033: if (!hcd) {
3034: pr_debug("%s: hcd is NULL\n", __func__);
3035: return;
3036: }
3037: rhdev = hcd->self.root_hub;
3038:
3039: dev_info(hcd->self.controller, "remove, state %x\n", hcd->state);
3040:
3041: usb_get_dev(rhdev);
3042: clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags);
3043: if (HC_IS_RUNNING (hcd->state))
3044: hcd->state = HC_STATE_QUIESCING;
3045:
3046: dev_dbg(hcd->self.controller, "roothub graceful disconnect\n");
3047: spin_lock_irq (&hcd_root_hub_lock);
3048: rh_registered = hcd->rh_registered;
3049: hcd->rh_registered = 0;
3050: spin_unlock_irq (&hcd_root_hub_lock);
3051:
3052: #ifdef CONFIG_PM
3053: cancel_work_sync(&hcd->wakeup_work);
3054: #endif
3055: cancel_work_sync(&hcd->died_work);
3056:
3057: mutex_lock(&usb_bus_idr_lock);
3058: if (rh_registered)
3059: usb_disconnect(&rhdev); /* Sets rhdev to NULL */
3060: mutex_unlock(&usb_bus_idr_lock);
3061:
3062: /*
3063: * flush_work() isn't needed here because:
3064: * - driver's disconnect() called from usb_disconnect() should
3065: * make sure its URBs are completed during the disconnect()
3066: * callback
3067: *
3068: * - it is too late to run complete() here since driver may have
3069: * been removed already now
]
|
| 33/2 |
2026/09/29 03:47 |
llm |
expert |
0m
Model:
Tokens:
input: 28562
output: 15
thoughts: 1677
Thoughts: **Analysis of a USB Core Use-After-Free Vulnerability**
Okay, let's break this down. Initially, I was looking at `usb_remove_hcd` and thinking about work flushing. But that's not the critical path here. The crux of the issue lies in the error handling within `usb_add_hcd` and `vhci_hcd_probe`. Specifically, when `register_root_hub` fails inside `usb_add_hcd`, the code jumps to an error path that *doesn't* call `usb_remove_hcd`.
The real problem surfaces when `usb_add_hcd` itself fails, as happens in `vhci_hcd_probe`. Here, `usb_put_hcd` is called directly, immediately freeing the `usb_hcd` structure. The vulnerability lies in the fact that during the `register_root_hub` execution, URBs might get queued, dequeued, and the `usb_giveback_urb_bh` work might be scheduled, via workqueue.
Now, let's consider the sequence. We have a failure in `usb_add_hcd`, leading to the free of `hcd` via `usb_put_hcd`, which immediately frees the `hcd_hs` while `usb_giveback_urb_bh(&hcd->high_prio_bh.bh)` is pending or executing! Then, `ksoftirqd` executes `bh_worker` which then calls `usb_giveback_urb_bh`. Inside this function, it tries to access `bh->completing_ep` (which is inside `hcd->high_prio_bh`). But the `hcd` has already been freed! This results in a write to a memory location that is no longer valid, a classic use-after-free situation.
The KASAN report confirms this perfectly. Itβs a slab use-after-free, with a clear write of 8 bytes to an address within the freed `usb_hcd` structure. The provided stack traces (access, allocation, and free) are all consistent and show the same `usb_hcd` object. The allocation occurs in `__usb_create_hcd`, the free happens via `usb_put_hcd`, and the illegal access during `usb_giveback_urb_bh`. The offsets are also precise: the write occurs at 768 bytes offset of the base address, and the structure layout matches up perfectly, confirming the write to `completing_ep` is the cause.
The root cause is clear: when `usb_add_hcd` (specifically during the `register_root_hub` stage) or `vhci_hcd_probe` fails, giveback work items might have been queued to the BH workqueues. The current error handling path does not properly cancel or flush the pending `usb_giveback_urb_bh` work on the `high_prio_bh` before `struct usb_hcd` is freed via `usb_put_hcd()`. This is totally actionable and self-consistent!
|
| 34/2 |
2026/09/29 03:47 |
tool |
set-results |
0m
Args:
Results:
|
| 35/2 |
2026/09/29 03:47 |
llm |
expert |
0m
Model:
Tokens:
input: 30939
output: 744
thoughts: 155
Thoughts: Okay, here's my understanding, distilled into a first-person summary, keeping in mind I'm an expert in this field:
**Final Reply Preparation - Deep Dive**
Alright, I've confirmed everything. This is definitely actionable. We've got a tricky memory management bug on our hands. The core issue is this: a `struct usb_hcd` object is getting freed prematurely. Let me break down the critical details.
We're looking at three stack traces here: an access, an allocation, and a free, all related to the `struct usb_hcd`. The "access" trace shows us where we're trying to use memory that's already gone. The "allocation" trace reveals where the `usb_hcd` was initially set up. The "free" trace pinpoints where the fatal deallocation occurs, which is, of course, the heart of the problem. What makes this so insidious is that the free happens *before* certain cleanup procedures finish, leaving dangling pointers behind.
Now, focusing on the memory layout, my analysis points to an offset of 768 bytes. This corresponds directly to `hcd->high_prio_bh.completing_ep`. We're seeing an 8-byte write happening, which strongly suggests that a pointer write is happening. The trace describes it as `bh->completing_ep = NULL`, so we are nullifying a pointer to an endpoint. The write to this address would appear valid, but is not since the struct has been deallocated.
The root cause, as I see it, stems from an error unwinding scenario. Specifically, when `usb_add_hcd` or root hub registration fails during a probe operation, the system attempts to clean up. The problem is that during this cleanup process, the `usb_hcd` is being freed prematurely. Crucially, the queued BH (Bottom Half) work associated with the `usb_hcd` is *not* being properly canceled or flushed before the memory is released. This means there's a race condition. The BH might still be trying to access or modify data within the `usb_hcd` even though the underlying memory has been returned to the system, thus the crash. This is a classic double-free or use-after-free scenario. We need to focus on ensuring proper synchronization and cancellation of the BH work during these error paths to resolve this.
|
| 36/1 |
2026/09/29 03:47 |
action |
format-explanation |
0m
Results: map[Explanation:The bug report is **actionable** and **self-consistent**.
### Analysis:
1. **Stack Traces Presence & Subsystem Consistency:**
The report contains all 3 necessary stack traces (plus auxiliary work
creation stacks), all belonging to the USB core / USB HCD subsystem:
- **Access stack:** A worker task (`ksoftirqd`) executing
`usb_giveback_urb_bh()` at `drivers/usb/core/hcd.c:1692` performs an 8-byte
write (`bh->completing_ep = NULL;`).
- **Allocation stack:** `struct usb_hcd` is allocated by `__usb_create_hcd()`
at `drivers/usb/core/hcd.c:2566` during `vhci_hcd_probe()`.
- **Free stack:** `struct usb_hcd` is released by `usb_put_hcd()` /
`hcd_release()` at `drivers/usb/core/hcd.c:2690` during error handling in
`vhci_hcd_probe()`.
2. **Memory Layout and Field Offset Verification:**
- Object base address: `0xffff888022a54000`
- Access address: `0xffff888022a54300` (offset `+768` bytes / `0x300`)
- In `struct usb_hcd`, the member `high_prio_bh` (of type `struct
giveback_urb_bh`) begins at offset `4864` bits (`608` bytes).
- In `struct giveback_urb_bh`, the field `completing_ep` is located at offset
`1280` bits (`160` bytes).
- `608 + 160 = 768` bytes, which matches the offset `0x300` exactly.
- The operation `bh->completing_ep = NULL;` is a pointer write of 8 bytes,
which precisely matches the report's `Write of size 8 at addr
ffff888022a54300`.
3. **Root Cause Analysis:**
- During `vhci_hcd_probe()`, `usb_add_hcd()` is called, which initializes the
bottom-half giveback work structures (`high_prio_bh` and `low_prio_bh`)
embedded in `struct usb_hcd`.
- During `register_root_hub()`, URB activity occurs and URB giveback work is
queued to the BH workqueue (`usb_hcd_giveback_urb()` queues
`&hcd->high_prio_bh.bh`).
- If an error occurs during root hub registration / probe, `usb_add_hcd()`
fails and unwinds to `vhci_hcd_probe()`'s error exit path, which calls
`usb_put_hcd()`.
- β Because the pending BH works (`high_prio_bh` / `low_prio_bh`) were neither
flushed nor cancelled before `hcd` was freed, the workqueue executes
`usb_giveback_urb_bh()` asynchronously after `hcd` has already been freed,
resulting in a use-after-free write.]
|