| 0/0 |
2026/06/29 00:02 |
flow |
assessment-security |
37m
Results: map[DenialOfService:true Explanation:**Analysis of the Bug:**
The bug is a Use-After-Free (UAF) in the `ueagle-atm` USB driver, specifically
in the `uea_upload_pre_firmware` function.
When a pre-firmware USB device is plugged in, the `uea_probe` function is
called. It allocates a `struct completion` (`fw_done`), sets it as the interface
data (`usb_set_intfdata(intf, fw_done)`), and schedules an asynchronous firmware
load via `request_firmware_nowait`. The firmware load work item eventually
executes `uea_upload_pre_firmware`, which expects the `struct usb_interface`
pointer as its context.
If an attacker plugs in a malicious USB device that matches the pre-firmware
device ID (e.g., `VID=0x1110`, `PID=0x9010`) but presents multiple interfaces
(`bNumInterfaces > 1`), `uea_probe` will be called for each interface.
When the device is subsequently disconnected, `uea_disconnect` is invoked. The
disconnect handler contains the following logic:
```c
if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
mutex_lock(&uea_mutex);
usbatm_usb_disconnect(intf);
mutex_unlock(&uea_mutex);
} else if (usb->config->desc.bNumInterfaces == 1) {
struct completion *fw_done = usb_get_intfdata(intf);
wait_for_completion(fw_done);
kfree(fw_done);
}
```
If `bNumInterfaces != 1` and `ifnum != 0` (e.g., for the second interface),
`uea_disconnect` falls through and does **nothing**. It does not wait for the
asynchronous firmware load to complete. Consequently, the USB core frees the
`struct usb_interface` object.
When the scheduled `request_firmware_work_func` runs, it calls
`uea_upload_pre_firmware`, which accesses the now-freed `intf` to retrieve the
`struct usb_device` pointer (`interface_to_usbdev(intf)` accesses
`intf->dev.parent`). This results in a Use-After-Free.
*(Note: For `ifnum == 0`, `usbatm_usb_disconnect` is called, which incorrectly
casts the 32-byte `fw_done` completion object to a large `struct usbatm_data`
and accesses out-of-bounds memory at offset 136, leading to another severe
memory corruption / DoS).*
**Exploitability:**
The UAF is highly exploitable. The `struct usb_interface` is allocated in the
`kmalloc-2k` cache. An attacker can spray this cache to overwrite the freed
interface and control the `intf->dev.parent` pointer, effectively forging a fake
`struct usb_device`.
The `uea_upload_pre_firmware` function then passes this controlled `usb_device`
to `uea_send_modem_cmd`, which calls `usb_control_msg`. The USB core will use
the fake `usb_device` to submit an URB (`usb_submit_urb` -> `usb_hcd_submit_urb`
-> `hcd->driver->urb_enqueue`). By crafting the fake `usb_device` and its
associated `usb_bus` and `usb_hcd` structures, the attacker can hijack the
`urb_enqueue` function pointer, achieving arbitrary kernel code execution and
privilege escalation.
**Trigger Vectors:**
* **Peripheral Trigger:** The bug can be triggered by physically plugging a
malicious USB device into the system.
* **VM Host Trigger (Confidential Computing):** A malicious hypervisor can
emulate and hotplug this crafted USB device into a Confidential VM (e.g., AMD
SEV, Intel TDX) to compromise the guest kernel.
* **Unprivileged / Remote:** The bug cannot be triggered remotely or by
unprivileged users, as emulating USB devices (e.g., via Dummy HCD or Raw Gadget)
or attaching USB/IP devices requires root privileges (`CAP_SYS_ADMIN` or
`CAP_NET_ADMIN` + sysfs write access). Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:true]
|
| 1/1 |
2026/06/29 00:02 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/06/29 00:02 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/989f2c1470bb52d2e2adc875e32f0bacc3d4967a]
|
| 3/1 |
2026/06/29 00:04 |
action |
kernel-builder |
22m
Results: map[KernelObj:/app/workdir/cache/build/b9c4641bef7883289ad3f26d3f5d3360f86f3314]
|
| 4/1 |
2026/06/29 00:27 |
action |
codesearch-prepare |
10m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/06/29 00:37 |
agent |
expert |
3m
Model:
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:true]
Instruction: You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption, elevated privileges, or an information leak.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completely wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control transfers, that also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Information leaks are exploitable on their own and should be classified as such. A bug that copies kernel
memory contents to userspace (e.g. an out-of-bounds read whose result is returned to the caller, or
uninitialized stack/heap bytes written to a user buffer) is exploitable: it can reveal kernel pointer
values and defeat KASLR, expose sensitive data such as cryptographic keys or other processes' memory, and
serves as a necessary building block in most modern kernel privilege-escalation exploit chains. Do not classify
an information leak as non-exploitable solely because it does not directly cause a memory write or control-flow
hijack; the leak itself is the exploit primitive.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
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 kernel bug report is:
==================================================================
BUG: KASAN: slab-use-after-free in __intf_to_usbdev include/linux/usb.h:752 [inline]
BUG: KASAN: slab-use-after-free in uea_upload_pre_firmware+0x8d/0x640 drivers/usb/atm/ueagle-atm.c:598
Read of size 8 at addr ffff888062b260b8 by task kworker/0:4/12640
CPU: 0 UID: 0 PID: 12640 Comm: kworker/0:4 Tainted: G L syzkaller #0 PREEMPT_{RT,(full)}
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/09/2026
Workqueue: events request_firmware_work_func
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_address_description+0x55/0x1e0 mm/kasan/report.c:378
print_report+0x58/0x70 mm/kasan/report.c:482
kasan_report+0x117/0x150 mm/kasan/report.c:595
__intf_to_usbdev include/linux/usb.h:752 [inline]
uea_upload_pre_firmware+0x8d/0x640 drivers/usb/atm/ueagle-atm.c:598
request_firmware_work_func+0xf7/0x2d0 drivers/base/firmware_loader/main.c:1164
process_one_work+0x93a/0x12b0 kernel/workqueue.c:3326
process_scheduled_works kernel/workqueue.c:3409 [inline]
worker_thread+0xb05/0x10d0 kernel/workqueue.c:3490
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Allocated by task 5805:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__kmalloc_cache_noprof+0x3d2/0x6b0 mm/slub.c:5515
_kmalloc_noprof include/linux/slab.h:969 [inline]
_kzalloc_noprof include/linux/slab.h:1290 [inline]
usb_set_configuration+0x3cc/0x2180 drivers/usb/core/message.c:2096
usb_generic_driver_probe+0x8d/0x150 drivers/usb/core/generic.c:250
usb_probe_device+0x1c3/0x3b0 drivers/usb/core/driver.c:291
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x25b/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c7/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12d/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_new_device+0x98d/0x1610 drivers/usb/core/hub.c:2695
hub_port_connect drivers/usb/core/hub.c:5567 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
port_event drivers/usb/core/hub.c:5871 [inline]
hub_event+0x28cf/0x4cf0 drivers/usb/core/hub.c:5953
process_one_work+0x93a/0x12b0 kernel/workqueue.c:3326
process_scheduled_works kernel/workqueue.c:3409 [inline]
worker_thread+0xb05/0x10d0 kernel/workqueue.c:3490
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
Freed by task 5805:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2705 [inline]
slab_free mm/slub.c:6405 [inline]
kfree+0x1c5/0x6c0 mm/slub.c:6720
device_release+0xc4/0x1f0 drivers/base/core.c:-1
kobject_cleanup lib/kobject.c:689 [inline]
kobject_release lib/kobject.c:720 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x222/0x550 lib/kobject.c:737
usb_disable_device+0x611/0x8d0 drivers/usb/core/message.c:1485
usb_disconnect+0x32d/0x990 drivers/usb/core/hub.c:2345
hub_port_connect drivers/usb/core/hub.c:5407 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
port_event drivers/usb/core/hub.c:5871 [inline]
hub_event+0x1bb7/0x4cf0 drivers/usb/core/hub.c:5953
process_one_work+0x93a/0x12b0 kernel/workqueue.c:3326
process_scheduled_works kernel/workqueue.c:3409 [inline]
worker_thread+0xb3c/0x10d0 kernel/workqueue.c:3490
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 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 ffff888062b26000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 184 bytes inside of
freed 2048-byte region [ffff888062b26000, ffff888062b26800)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff888062b25000 pfn:0x62b20
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x80000000000240(workingset|head|node=0|zone=1)
page_type: f5(slab)
raw: 0080000000000240 ffff88813fe25000 ffffea000187d610 ffffea0000ec0410
raw: ffff888062b25000 0000000800080007 00000000f5000000 0000000000000000
head: 0080000000000240 ffff88813fe25000 ffffea000187d610 ffffea0000ec0410
head: ffff888062b25000 0000000800080007 00000000f5000000 0000000000000000
head: 0080000000000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff
head: 0000000000000000 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 822, tgid 822 (kworker/0:2), ts 87027586885, free_ts 0
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x1f9/0x250 mm/page_alloc.c:1859
prep_new_page mm/page_alloc.c:1867 [inline]
get_page_from_freelist+0x2639/0x26b0 mm/page_alloc.c:3946
__alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5304
alloc_slab_page mm/slub.c:3294 [inline]
allocate_slab+0x79/0x5e0 mm/slub.c:3408
new_slab mm/slub.c:3454 [inline]
refill_objects+0x2d8/0x350 mm/slub.c:7338
refill_sheaf mm/slub.c:2832 [inline]
__pcs_replace_empty_main+0x330/0x690 mm/slub.c:4703
alloc_from_pcs mm/slub.c:4801 [inline]
slab_alloc_node mm/slub.c:4933 [inline]
__do_kmalloc_node mm/slub.c:5361 [inline]
__kmalloc_node_track_caller_noprof+0x62d/0x7c0 mm/slub.c:5497
kmalloc_reserve net/core/skbuff.c:637 [inline]
__alloc_skb+0x2bd/0x7a0 net/core/skbuff.c:715
alloc_skb include/linux/skbuff.h:1384 [inline]
mld_newpack+0x165/0xcb0 net/ipv6/mcast.c:1773
add_grhead net/ipv6/mcast.c:1884 [inline]
add_grec+0x119f/0x19d0 net/ipv6/mcast.c:2023
mld_send_cr net/ipv6/mcast.c:2148 [inline]
mld_ifc_work+0x6ea/0xe70 net/ipv6/mcast.c:2694
process_one_work+0x93a/0x12b0 kernel/workqueue.c:3326
process_scheduled_works kernel/workqueue.c:3409 [inline]
worker_thread+0xb05/0x10d0 kernel/workqueue.c:3490
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
page_owner free stack trace missing
Memory state around the buggy address:
ffff888062b25f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888062b26000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888062b26080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888062b26100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888062b26180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Reply: **Analysis of the Bug:**
The bug is a Use-After-Free (UAF) in the `ueagle-atm` USB driver, specifically in the `uea_upload_pre_firmware` function.
When a pre-firmware USB device is plugged in, the `uea_probe` function is called. It allocates a `struct completion` (`fw_done`), sets it as the interface data (`usb_set_intfdata(intf, fw_done)`), and schedules an asynchronous firmware load via `request_firmware_nowait`. The firmware load work item eventually executes `uea_upload_pre_firmware`, which expects the `struct usb_interface` pointer as its context.
If an attacker plugs in a malicious USB device that matches the pre-firmware device ID (e.g., `VID=0x1110`, `PID=0x9010`) but presents multiple interfaces (`bNumInterfaces > 1`), `uea_probe` will be called for each interface.
When the device is subsequently disconnected, `uea_disconnect` is invoked. The disconnect handler contains the following logic:
```c
if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
mutex_lock(&uea_mutex);
usbatm_usb_disconnect(intf);
mutex_unlock(&uea_mutex);
} else if (usb->config->desc.bNumInterfaces == 1) {
struct completion *fw_done = usb_get_intfdata(intf);
wait_for_completion(fw_done);
kfree(fw_done);
}
```
If `bNumInterfaces != 1` and `ifnum != 0` (e.g., for the second interface), `uea_disconnect` falls through and does **nothing**. It does not wait for the asynchronous firmware load to complete. Consequently, the USB core frees the `struct usb_interface` object.
When the scheduled `request_firmware_work_func` runs, it calls `uea_upload_pre_firmware`, which accesses the now-freed `intf` to retrieve the `struct usb_device` pointer (`interface_to_usbdev(intf)` accesses `intf->dev.parent`). This results in a Use-After-Free.
*(Note: For `ifnum == 0`, `usbatm_usb_disconnect` is called, which incorrectly casts the 32-byte `fw_done` completion object to a large `struct usbatm_data` and accesses out-of-bounds memory at offset 136, leading to another severe memory corruption / DoS).*
**Exploitability:**
The UAF is highly exploitable. The `struct usb_interface` is allocated in the `kmalloc-2k` cache. An attacker can spray this cache to overwrite the freed interface and control the `intf->dev.parent` pointer, effectively forging a fake `struct usb_device`.
The `uea_upload_pre_firmware` function then passes this controlled `usb_device` to `uea_send_modem_cmd`, which calls `usb_control_msg`. The USB core will use the fake `usb_device` to submit an URB (`usb_submit_urb` -> `usb_hcd_submit_urb` -> `hcd->driver->urb_enqueue`). By crafting the fake `usb_device` and its associated `usb_bus` and `usb_hcd` structures, the attacker can hijack the `urb_enqueue` function pointer, achieving arbitrary kernel code execution and privilege escalation.
**Trigger Vectors:**
* **Peripheral Trigger:** The bug can be triggered by physically plugging a malicious USB device into the system.
* **VM Host Trigger (Confidential Computing):** A malicious hypervisor can emulate and hotplug this crafted USB device into a Confidential VM (e.g., AMD SEV, Intel TDX) to compromise the guest kernel.
* **Unprivileged / Remote:** The bug cannot be triggered remotely or by unprivileged users, as emulating USB devices (e.g., via Dummy HCD or Raw Gadget) or attaching USB/IP devices requires root privileges (`CAP_SYS_ADMIN` or `CAP_NET_ADMIN` + sysfs write access).
|
| 6/2 |
2026/06/29 00:37 |
llm |
expert |
0m
Model:
Tokens:
input: 9558
output: 45
thoughts: 103
Thoughts: **Analyzing a KASAN Slab-Use-After-Free Vulnerability**
Okay, so I'm looking at a KASAN slab-use-after-free issue. From what I understand, it's occurring within the `__intf_to_usbdev` function. That function is being called from `uea_upload_pre_firmware` in the `drivers/usb/atm/ueagle-atm.c` file. The critical point seems to be during the execution of `request_firmware_work_func`. Right, so this suggests a race condition or a memory management issue specifically linked to that firmware request handling. I need to dig into `uea_upload_pre_firmware` in that `ueagle-atm.c` file to trace the execution path and pinpoint the exact source of the problem. Time to start debugging!
|
| 7/2 |
2026/06/29 00:37 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/ueagle-atm.c Name:uea_upload_pre_firmware]
Results: map[SourceCode: 594: static void uea_upload_pre_firmware(const struct firmware *fw_entry,
595: void *context)
596: {
597: struct usb_interface *intf = context;
598: struct usb_device *usb = interface_to_usbdev(intf);
599: struct completion *fw_done = usb_get_intfdata(intf);
600: const u8 *pfw;
601: u8 value;
602: u32 crc = 0;
603: int ret, size;
604:
605: if (!fw_entry) {
606: uea_err(usb, "firmware is not available\n");
607: goto err;
608: }
609:
610: pfw = fw_entry->data;
611: size = fw_entry->size;
612: if (size < 4)
613: goto err_fw_corrupted;
614:
615: crc = get_unaligned_le32(pfw);
616: pfw += 4;
617: size -= 4;
618: if (crc32_be(0, pfw, size) != crc)
619: goto err_fw_corrupted;
620:
621: /*
622: * Start to upload firmware : send reset
623: */
624: value = 1;
625: ret = uea_send_modem_cmd(usb, F8051_USBCS, sizeof(value), &value);
626:
627: if (ret < 0) {
628: uea_err(usb, "modem reset failed with error %d\n", ret);
629: goto err;
630: }
631:
632: while (size > 3) {
633: u8 len = FW_GET_BYTE(pfw);
634: u16 add = get_unaligned_le16(pfw + 1);
635:
636: size -= len + 3;
637: if (size < 0)
638: goto err_fw_corrupted;
639:
640: ret = uea_send_modem_cmd(usb, add, len, pfw + 3);
641: if (ret < 0) {
642: uea_err(usb, "uploading firmware data failed "
643: "with error %d\n", ret);
644: goto err;
645: }
646: pfw += len + 3;
647: }
648:
649: if (size != 0)
650: goto err_fw_corrupted;
651:
652: /*
653: * Tell the modem we finish : de-assert reset
654: */
655: value = 0;
656: ret = uea_send_modem_cmd(usb, F8051_USBCS, 1, &value);
657: if (ret < 0)
658: uea_err(usb, "modem de-assert failed with error %d\n", ret);
659: else
660: uea_info(usb, "firmware uploaded\n");
661:
662: goto err;
663:
664: err_fw_corrupted:
665: uea_err(usb, "firmware is corrupted\n");
666: err:
667: release_firmware(fw_entry);
668: complete(fw_done);
669: }
SourceFile:drivers/usb/atm/ueagle-atm.c]
|
| 8/2 |
2026/06/29 00:37 |
llm |
expert |
0m
Model:
Tokens:
input: 11022
output: 59
thoughts: 80
Thoughts: **Analyzing a Potential Use-After-Free Vulnerability**
Okay, so I'm digging into this UAF, and it looks like the issue stems from how we're handling `intf` within `interface_to_usbdev(intf)`. Specifically, the problem appears when we try to access `intf` there. I need to trace this back.
Alright, `intf` is passed as `context` to `uea_upload_pre_firmware`. That function is a callback that is registered with `request_firmware_nowait`. The key here is the timing. I need to understand when and how `request_firmware_nowait` is called. It looks like the asynchronous nature of this call is the key. My focus has to be on the relationship between these functions, the state of `intf`, and how the callback is scheduled and executed.
|
| 9/2 |
2026/06/29 00:37 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:drivers/usb/atm/ueagle-atm.c IncludeSnippetLines:10 Name:uea_upload_pre_firmware SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:uea_load_firmware SourceFile:drivers/usb/atm/ueagle-atm.c SourceLine:702 SourceSnippet: 692: case EAGLE_III:
693: fw_name = EAGLE_III_FIRMWARE;
694: break;
695: case EAGLE_IV:
696: fw_name = EAGLE_IV_FIRMWARE;
697: break;
698: }
699:
700: ret = request_firmware_nowait(THIS_MODULE, 1, fw_name, &usb->dev,
701: GFP_KERNEL, intf,
702: uea_upload_pre_firmware);
703: if (ret)
704: uea_err(usb, "firmware %s is not available\n", fw_name);
705: else
706: uea_info(usb, "loading firmware %s\n", fw_name);
707:
708: return ret;
709: }
]] TruncatedOutput:false]
|
| 10/2 |
2026/06/29 00:37 |
llm |
expert |
0m
Model:
Tokens:
input: 11698
output: 43
thoughts: 13
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Analyzing `uea_load_firmware`**
Right, `uea_load_firmware`. Okay, this is probably a critical piece of the puzzle. I need to understand what this function *does*, where it's called, and what its dependencies are. Immediately, I'm thinking about the implications of "firmware" in this context. Is this for a specific hardware component? A system-level boot process? I need more context to be certain.
My first questions are: What's the target platform or device? Is this related to a specific chipset or architecture? Knowing this will help me determine the potential vulnerabilities associated with the firmware and the load process. Is this an off-the-shelf, closed source component? If so, decompiling and analyzing might be necessary, assuming I can legally do that, of course. Is there any existing documentation? Even a vague description could give me enough of a lead to find out more.
I'll be looking for potential attack vectors. Can the firmware be updated remotely? Is it signed? Can someone potentially inject malicious code into the firmware image? Is there any security hardening in place to prevent tampering? The implications of a compromised firmware load are significant, potentially leading to privilege escalation, persistent malware installation, or even a complete system compromise. I need to understand the mechanism by which it's loaded to see if there are any obvious weaknesses.
|
| 11/2 |
2026/06/29 00:37 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/ueagle-atm.c Name:uea_load_firmware]
Results: map[SourceCode: 671: /*
672: * uea_load_firmware - Load usb firmware for pre-firmware devices.
673: */
674: static int uea_load_firmware(struct usb_interface *intf, unsigned int ver)
675: {
676: int ret;
677: char *fw_name = EAGLE_FIRMWARE;
678: struct usb_device *usb = interface_to_usbdev(intf);
679:
680: uea_info(usb, "pre-firmware device, uploading firmware\n");
681:
682: switch (ver) {
683: case ADI930:
684: fw_name = ADI930_FIRMWARE;
685: break;
686: case EAGLE_I:
687: fw_name = EAGLE_I_FIRMWARE;
688: break;
689: case EAGLE_II:
690: fw_name = EAGLE_II_FIRMWARE;
691: break;
692: case EAGLE_III:
693: fw_name = EAGLE_III_FIRMWARE;
694: break;
695: case EAGLE_IV:
696: fw_name = EAGLE_IV_FIRMWARE;
697: break;
698: }
699:
700: ret = request_firmware_nowait(THIS_MODULE, 1, fw_name, &usb->dev,
701: GFP_KERNEL, intf,
702: uea_upload_pre_firmware);
703: if (ret)
704: uea_err(usb, "firmware %s is not available\n", fw_name);
705: else
706: uea_info(usb, "loading firmware %s\n", fw_name);
707:
708: return ret;
709: }
SourceFile:drivers/usb/atm/ueagle-atm.c]
|
| 12/2 |
2026/06/29 00:37 |
llm |
expert |
0m
Model:
Tokens:
input: 12682
output: 57
thoughts: 31
Thoughts: Here's my take on the thought process, summarized as you requested:
**Investigating Firmware Loading in the UEA Driver**
Okay, so I'm trying to nail down the control flow of the UEA driver. My concern is the `uea_load_firmware` function. I need to understand where it's being invoked. Is it being called exclusively from within the `uea_bind` function? Or is `uea_probe` potentially responsible for calling it too? It's a critical detail because it dictates the initialization sequence. Time to dive into the code and verify. Let's trace back the calls and see who's doing the heavy lifting here. This information will inform my strategy for debugging any firmware related issues.
|
| 13/2 |
2026/06/29 00:37 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:drivers/usb/atm/ueagle-atm.c IncludeSnippetLines:10 Name:uea_load_firmware SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:uea_probe SourceFile:drivers/usb/atm/ueagle-atm.c SourceLine:2573 SourceSnippet:2563: struct completion *fw_done;
2564:
2565: /* Wait for the firmware load to be done, in .disconnect() */
2566: fw_done = kzalloc_obj(*fw_done);
2567: if (!fw_done)
2568: return -ENOMEM;
2569:
2570: init_completion(fw_done);
2571: usb_set_intfdata(intf, fw_done);
2572:
2573: ret = uea_load_firmware(intf, UEA_CHIP_VERSION(id));
2574: if (ret)
2575: kfree(fw_done);
2576:
2577: return ret;
2578: }
2579:
2580: ret = usbatm_usb_probe(intf, id, &uea_usbatm_driver);
2581: if (ret == 0) {
2582: struct usbatm_data *usbatm = usb_get_intfdata(intf);
2583: struct uea_softc *sc = usbatm->driver_data;
]] TruncatedOutput:false]
|
| 14/2 |
2026/06/29 00:37 |
llm |
expert |
0m
Model:
Tokens:
input: 13333
output: 40
thoughts: 171
Thoughts: Okay, let me break this down.
**My Analysis of `uea_probe` and `uea_disconnect`**
Alright, I see how `uea_probe` handles this. The code checks if the `id` corresponds to a "PREFIRM" state. If it does, a `struct completion *fw_done` is being allocated and initialized. This is a classic signaling mechanism, a semaphore-like object, specifically for waiting on the completion of the firmware load. It allocates this object, initializes it with `init_completion`, and then sets it as interface-specific data (`usb_set_intfdata`). The critical part is the call to `uea_load_firmware` with the chip version. Then, the code calls to `kfree()` the object if the call to load the firmware fails. This makes sense: clean up the allocation if an error occurred. The return value from `uea_load_firmware` is then returned from the `uea_probe` function. This is standard error-handling protocol.
|
| 15/2 |
2026/06/29 00:37 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/ueagle-atm.c Name:uea_disconnect]
Results: map[SourceCode:2595: static void uea_disconnect(struct usb_interface *intf)
2596: {
2597: struct usb_device *usb = interface_to_usbdev(intf);
2598: int ifnum = intf->altsetting->desc.bInterfaceNumber;
2599:
2600: /* ADI930 has 2 interfaces and eagle 3 interfaces.
2601: * Pre-firmware device has one interface
2602: */
2603: if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
2604: mutex_lock(&uea_mutex);
2605: usbatm_usb_disconnect(intf);
2606: mutex_unlock(&uea_mutex);
2607: uea_info(usb, "ADSL device removed\n");
2608: } else if (usb->config->desc.bNumInterfaces == 1) {
2609: struct completion *fw_done = usb_get_intfdata(intf);
2610:
2611: uea_dbg(usb, "pre-firmware device, waiting firmware upload\n");
2612: wait_for_completion(fw_done);
2613: uea_dbg(usb, "pre-firmware device, finished waiting\n");
2614: kfree(fw_done);
2615: }
2616: }
SourceFile:drivers/usb/atm/ueagle-atm.c]
|
| 16/2 |
2026/06/29 00:37 |
llm |
expert |
0m
Model:
Tokens:
input: 13793
output: 43
thoughts: 1599
Thoughts: **Analyzing a KASAN Slab-Use-After-Free in `uea_upload_pre_firmware`**
Okay, so I've got a KASAN slab-use-after-free on my hands. It's happening in `__intf_to_usbdev`, called from `uea_upload_pre_firmware`, which is, in turn, a workqueue function scheduled by `request_firmware_nowait`. This entire sequence is triggered by `uea_load_firmware`, called from `uea_probe` when a pre-firmware device is plugged in. The key thing here is that `request_firmware_nowait` gets the `struct usb_interface *intf` as the `context`. The vulnerability lies in the fact that `intf` is then used after it has been freed.
Looking at `uea_upload_pre_firmware`, I can see where it's happening: it's trying to dereference `intf` using `interface_to_usbdev(intf)`. Now, let's trace where `intf` is freed. `uea_disconnect` is the likely culprit, and indeed, it does seem to be the function in charge of cleaning up `intf`.
The code in `uea_disconnect` is a bit conditional, depending on the number of interfaces the USB device has. If it's a pre-firmware device (single interface), it sets up a `completion` structure `fw_done`, signals that this is the device type we are investigating, and waits for a completion of this `fw_done` structure. This `fw_done` is completed at the end of `uea_upload_pre_firmware`, after the firmware has been loaded and released. So, `uea_disconnect` waits for `uea_upload_pre_firmware` to finish before returning. This is where the race condition starts to form.
My initial assumption was that `uea_disconnect` completes *before* the workqueue is scheduled, but that wouldn't cause a use-after-free, since `intf` wouldn't be freed. The timing that I think the KASAN report indicates: the workqueue is scheduled before disconnect. Disconnect is called, waits for the completion, then after the workqueue completes, disconnect continues. This means that if the device is disconnected before the workqueue function starts, we *shouldn't* have a UAF, because `uea_disconnect` blocks until `uea_upload_pre_firmware` completes. However, the KASAN report suggests otherwise.
I had assumed, incorrectly, that the USB core frees `intf` only *after* `uea_disconnect` returns, but that isn't true. The USB core frees `intf` *during* `uea_disconnect`, which is why the code has to wait for completion. But I was missing something. The KASAN report pinpoints the problem: the UAF happens within `uea_upload_pre_firmware` itself, specifically on the line where it tries to get the USB device from the interface pointer. The report also says the freed `intf` is accessed in `uea_upload_pre_firmware`, which only makes sense if there's a race between `uea_disconnect` and `request_firmware_nowait`.
The question then is, how can `uea_upload_pre_firmware` access a freed `intf`? I need to look closer at the execution path. What if `request_firmware_nowait` fails? If it fails, the work isn't scheduled. But, if it succeeds but firmware loading is aborted, we have a disconnect. However, if `request_firmware_nowait` fails, then `uea_probe` returns an error. This does *not* cause `uea_disconnect` to be called. However, if the firmware loads and the device is then disconnected immediately, the sequence is: `uea_disconnect` is called, it waits for `fw_done`, `uea_upload_pre_firmware` runs, completing `fw_done`, and then `uea_disconnect` returns, and the USB core frees `intf`.
The KASAN report notes that `intf` is freed by task 5805 (likely the USB disconnect path) and accessed by task 12640 (the `kworker` thread handling `request_firmware_work_func`, which calls `uea_upload_pre_firmware`). It's a race, but if `uea_upload_pre_firmware` is running, then `request_firmware_work_func` is
|
| 17/2 |
2026/06/29 00:37 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/base/firmware_loader/main.c Name:request_firmware_nowait]
Results: map[SourceCode:1225: /**
1226: * request_firmware_nowait() - asynchronous version of request_firmware
1227: * @module: module requesting the firmware
1228: * @uevent: sends uevent to copy the firmware image if this flag
1229: * is non-zero else the firmware copy must be done manually.
1230: * @name: name of firmware file
1231: * @device: device for which firmware is being loaded
1232: * @gfp: allocation flags
1233: * @context: will be passed over to @cont, and
1234: * @fw may be %NULL if firmware request fails.
1235: * @cont: function will be called asynchronously when the firmware
1236: * request is over.
1237: *
1238: * Caller must hold the reference count of @device.
1239: *
1240: * Asynchronous variant of request_firmware() for user contexts:
1241: * - sleep for as small periods as possible since it may
1242: * increase kernel boot time of built-in device drivers
1243: * requesting firmware in their ->probe() methods, if
1244: * @gfp is GFP_KERNEL.
1245: *
1246: * - can't sleep at all if @gfp is GFP_ATOMIC.
1247: **/
1248: int request_firmware_nowait(
1249: struct module *module, bool uevent,
1250: const char *name, struct device *device, gfp_t gfp, void *context,
1251: void (*cont)(const struct firmware *fw, void *context))
1252: {
1253: return _request_firmware_nowait(module, uevent, name, device, gfp,
1254: context, cont, false);
1255:
1256: }
SourceFile:drivers/base/firmware_loader/main.c]
|
| 18/2 |
2026/06/29 00:37 |
llm |
expert |
0m
Model:
Tokens:
input: 17428
output: 44
thoughts: 14
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and presented as if it were my own internal monologue:
**Checking `_request_firmware_nowait`**
Alright, let's dive in. My immediate thought is to examine the `_request_firmware_nowait` function or module. I'm assuming, given the naming, this is likely an asynchronous call designed to initiate a firmware update without blocking the main execution thread. I need to understand its behaviour, especially in a time-critical situation. My primary concerns are:
* **Error Handling:** What's the error reporting like? Does it signal failures gracefully or leave the system in an indeterminate state? I need to know how resilient it is.
* **Concurrency & Synchronization:** Does it use any locking mechanisms to prevent race conditions or data corruption with other tasks that may be accessing the same resources? Does it correctly protect shared state?
* **Status Reporting:** How does it signal success or failure back to the caller? Are there callbacks, flags, status registers, or is there a polling mechanism required to monitor the update's progress? Is it efficient, or does it add excessive overhead?
* **Power Management:** How does this function interact with power-saving modes? Does it correctly handle scenarios where the target device might be put into a low-power state during the update? Could this lead to corruption or device failure?
* **Idempotency:** Is the function idempotent? In other words, if it is called multiple times, does it work as expected? Can the call be performed again without causing a critical error?
* **Timeouts:** Does it implement timeouts? If a firmware update process hangs, will it be handled correctly?
* **Version Checking:** Does this have any firmware version checking implemented? Does it check to see if the update is necessary or a downgrade is present?
I need to quickly assess how it handles these points. This `_nowait` designation hints at a critical performance aspect. Depending on the architecture, any flaws in this function could severely impact the user experience, cause issues on the target device, or even brick the hardware. So, Iβll be paying close attention.
|
| 19/2 |
2026/06/29 00:37 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/base/firmware_loader/main.c Name:_request_firmware_nowait]
Results: map[SourceCode:1177: static int _request_firmware_nowait(
1178: struct module *module, bool uevent,
1179: const char *name, struct device *device, gfp_t gfp, void *context,
1180: void (*cont)(const struct firmware *fw, void *context), bool nowarn)
1181: {
1182: struct firmware_work *fw_work;
1183: unsigned long flags;
1184:
1185: fw_work = kzalloc_obj(struct firmware_work, gfp);
1186: if (!fw_work)
1187: return -ENOMEM;
1188:
1189: fw_work->module = module;
1190: fw_work->name = kstrdup_const(name, gfp);
1191: if (!fw_work->name) {
1192: kfree(fw_work);
1193: return -ENOMEM;
1194: }
1195: fw_work->device = device;
1196: fw_work->context = context;
1197: fw_work->cont = cont;
1198: fw_work->opt_flags = FW_OPT_NOWAIT |
1199: (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER) |
1200: (nowarn ? FW_OPT_NO_WARN : 0);
1201:
1202: if (!uevent && fw_cache_is_setup(device, name)) {
1203: kfree_const(fw_work->name);
1204: kfree(fw_work);
1205: return -EOPNOTSUPP;
1206: }
1207:
1208: if (!try_module_get(module)) {
1209: kfree_const(fw_work->name);
1210: kfree(fw_work);
1211: return -EFAULT;
1212: }
1213:
1214: get_device(fw_work->device);
1215: INIT_WORK(&fw_work->work, request_firmware_work_func);
1216:
1217: spin_lock_irqsave(&firmware_work_lock, flags);
1218: list_add_tail(&fw_work->list, &firmware_work_list);
1219: schedule_work(&fw_work->work);
1220: spin_unlock_irqrestore(&firmware_work_lock, flags);
1221:
1222: return 0;
1223: }
SourceFile:drivers/base/firmware_loader/main.c]
|
| 20/2 |
2026/06/29 00:37 |
llm |
expert |
0m
Model:
Tokens:
input: 18719
output: 44
thoughts: 722
Thoughts: **Analyzing a Potential Use-After-Free Vulnerability**
Okay, let's break this down. It seems the `uea_disconnect` function has some conditional logic based on `usb->config->desc.bNumInterfaces`. Specifically, it checks if the number of interfaces is not equal to 1, and the interface number `ifnum` is 0. If it *is* not equal to 1, it calls `usbatm_usb_disconnect(intf)` directly, *without* waiting for a firmware upload to complete. On the other hand, if there's only one interface, it *does* wait for `fw_done`.
The core of the issue, as I see it, hinges on the interaction between `uea_probe` and `uea_disconnect`. `uea_probe` decides whether to load firmware, specifically calling `uea_load_firmware` if `UEA_IS_PREFIRM(id)` is true. That function, and its subsequent usage, is the critical area of concern. The crucial point is that if a device is recognized as a "pre-firmware" device (by matching the USB ID), it's *supposed* to wait for firmware loading, right? `UEA_IS_PREFIRM` is the gatekeeper.
The vulnerability comes into play if a malicious device claims to be pre-firmware (matching the USB ID), but lies about having a single interface (`bNumInterfaces != 1`). Here's the scenario: the malicious device is plugged in; `uea_probe` will call `uea_load_firmware` because it *thinks* it's a pre-firmware device. When the device is disconnected, `uea_disconnect` takes the first branch because of the faked value of `bNumInterfaces`. The code *does not* wait for `fw_done`. This means the `intf` struct, crucial for the firmware upload, is freed immediately.
Crucially, the `request_firmware_work_func` is *still* running (or scheduled) to execute `uea_upload_pre_firmware`. This function still needs the `intf` struct, but now it's gone! Boom, we have a classic Use-After-Free condition. The code attempts to access memory after it has been freed.
I need to confirm this. Let's look at `uea_probe` again. The `UEA_IS_PREFIRM(id)` check is the pivot point. If that is true, it proceeds to initialize a `completion` structure named `fw_done` (using `kzalloc_obj`), stores a pointer to it using `usb_set_intfdata(intf, fw_done)`, and then calls `uea_load_firmware`. The next critical operation is looking into `uea_disconnect` and seeing if it actually checks the variable `bNumInterfaces` correctly and waits for the completion of the `fw_done` to be signalled before freeing the `intf` struct.
|
| 21/2 |
2026/06/29 00:38 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/usb/atm/ueagle-atm.c Name:UEA_IS_PREFIRM]
Results: map[SourceCode: SourceFile:]
|
| 22/2 |
2026/06/29 00:38 |
llm |
expert |
0m
Model:
Tokens:
input: 20161
output: 22
thoughts: 15
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing the Search Term**
Okay, so I'm presented with "Let's grep for `UEA_IS_PREFIRM`." My initial thought is to immediately recognize this as a command-line instruction, specifically using the `grep` utility. The structure is quite explicit: "Let's grep for..." implies a search for a specific string within a set of files or standard input.
The key element is the search term itself: `UEA_IS_PREFIRM`. The capitalization and underscores immediately suggest a configuration variable, environment variable, a macro definition in C or C++, or possibly a key in a data structure, or an attribute in a configuration file. The `UEA` part is intriguing - could it be an acronym for a specific system or project? Could it be tied to a university or organization? And the presence of "PREFIRM" offers additional context. It suggests, potentially, the pre-format state of some data, an indicator for pre-firmware, or a designation related to a preliminary state or version.
My next step is to mentally explore the context for this search. What's the environment? Am I on a Linux/Unix system given the implied use of `grep`? What are the possible file types that might contain this string? Logs? Configuration files? Source code? Output from build processes? Is there any documentation related to this term? I'd immediately start listing likely locations in my mind: `/etc`, `/var/log`, the current working directory, directories specified in configuration files. If I had more information, like the name of the system or the project, it would dramatically refine my search space.
In essence, I'm already mentally constructing the `grep` command, filling in the blanks. I'm thinking, "Okay, if it's a log, I'd probably do `grep 'UEA_IS_PREFIRM' /var/log/*` or similar, depending on what I have available." Then, I'd look for how the result aligns with the system's objective.
|
| 23/2 |
2026/06/29 00:38 |
tool |
grepper |
0m
Args: map[Expression:UEA_IS_PREFIRM]
Results: map[Output:drivers/usb/atm/ueagle-atm.c=226=enum {
--
drivers/usb/atm/ueagle-atm.c-234-/* macros for both struct usb_device_id and struct uea_softc */
drivers/usb/atm/ueagle-atm.c:235:#define UEA_IS_PREFIRM(x) \
drivers/usb/atm/ueagle-atm.c-236- (!((x)->driver_info & PSTFIRM))
--
drivers/usb/atm/ueagle-atm.c=2549=static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
--
drivers/usb/atm/ueagle-atm.c-2561-
drivers/usb/atm/ueagle-atm.c:2562: if (UEA_IS_PREFIRM(id)) {
drivers/usb/atm/ueagle-atm.c-2563- struct completion *fw_done;
]
|
| 24/2 |
2026/06/29 00:38 |
llm |
expert |
0m
Model:
Tokens:
input: 20909
output: 40
thoughts: 52
Thoughts: Here's my understanding of the situation:
**Decoding the USB Device ID Check**
Okay, so I'm looking at this `UEA_IS_PREFIRM` macro. From what I can tell, it's really just a simple check, diving into the `driver_info` field within a `struct usb_device_id`. Nothing overly complex there, which makes sense. I can probably quickly determine the specific flag it's checking.
Now, where's this `usb_device_id` table defined? Ah, right, that's in `ueagle-atm.c`. That's where I need to look to understand the specific device identifiers and associated data. I'll need to go there to figure out what values are considered valid and what they represent. From there, I'll be able to trace how this flag is being used.
|
| 25/2 |
2026/06/29 00:38 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/ueagle-atm.c Name:uea_ids]
Results: map[SourceCode:2618: /*
2619: * List of supported VID/PID
2620: */
2621: static const struct usb_device_id uea_ids[] = {
2622: {USB_DEVICE(ANALOG_VID, ADI930_PID_PREFIRM),
2623: .driver_info = ADI930 | PREFIRM},
2624: {USB_DEVICE(ANALOG_VID, ADI930_PID_PSTFIRM),
2625: .driver_info = ADI930 | PSTFIRM},
2626: {USB_DEVICE(ANALOG_VID, EAGLE_I_PID_PREFIRM),
2627: .driver_info = EAGLE_I | PREFIRM},
2628: {USB_DEVICE(ANALOG_VID, EAGLE_I_PID_PSTFIRM),
2629: .driver_info = EAGLE_I | PSTFIRM},
2630: {USB_DEVICE(ANALOG_VID, EAGLE_II_PID_PREFIRM),
2631: .driver_info = EAGLE_II | PREFIRM},
2632: {USB_DEVICE(ANALOG_VID, EAGLE_II_PID_PSTFIRM),
2633: .driver_info = EAGLE_II | PSTFIRM},
2634: {USB_DEVICE(ANALOG_VID, EAGLE_IIC_PID_PREFIRM),
2635: .driver_info = EAGLE_II | PREFIRM},
2636: {USB_DEVICE(ANALOG_VID, EAGLE_IIC_PID_PSTFIRM),
2637: .driver_info = EAGLE_II | PSTFIRM},
2638: {USB_DEVICE(ANALOG_VID, EAGLE_III_PID_PREFIRM),
2639: .driver_info = EAGLE_III | PREFIRM},
2640: {USB_DEVICE(ANALOG_VID, EAGLE_III_PID_PSTFIRM),
2641: .driver_info = EAGLE_III | PSTFIRM},
2642: {USB_DEVICE(ANALOG_VID, EAGLE_IV_PID_PREFIRM),
2643: .driver_info = EAGLE_IV | PREFIRM},
2644: {USB_DEVICE(ANALOG_VID, EAGLE_IV_PID_PSTFIRM),
2645: .driver_info = EAGLE_IV | PSTFIRM},
2646: {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_A_PID_PREFIRM),
2647: .driver_info = EAGLE_I | PREFIRM},
2648: {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_A_PID_PSTFIRM),
2649: .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_A},
2650: {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_B_PID_PREFIRM),
2651: .driver_info = EAGLE_I | PREFIRM},
2652: {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_B_PID_PSTFIRM),
2653: .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_B},
2654: {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_A_PID_PREFIRM),
2655: .driver_info = EAGLE_II | PREFIRM},
2656: {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_A_PID_PSTFIRM),
2657: .driver_info = EAGLE_II | PSTFIRM | AUTO_ANNEX_A},
2658: {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_B_PID_PREFIRM),
2659: .driver_info = EAGLE_II | PREFIRM},
2660: {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_B_PID_PSTFIRM),
2661: .driver_info = EAGLE_II | PSTFIRM | AUTO_ANNEX_B},
2662: {USB_DEVICE(ELSA_VID, ELSA_PID_PREFIRM),
2663: .driver_info = ADI930 | PREFIRM},
2664: {USB_DEVICE(ELSA_VID, ELSA_PID_PSTFIRM),
2665: .driver_info = ADI930 | PSTFIRM},
2666: {USB_DEVICE(ELSA_VID, ELSA_PID_A_PREFIRM),
2667: .driver_info = ADI930 | PREFIRM},
2668: {USB_DEVICE(ELSA_VID, ELSA_PID_A_PSTFIRM),
2669: .driver_info = ADI930 | PSTFIRM | AUTO_ANNEX_A},
2670: {USB_DEVICE(ELSA_VID, ELSA_PID_B_PREFIRM),
2671: .driver_info = ADI930 | PREFIRM},
2672: {USB_DEVICE(ELSA_VID, ELSA_PID_B_PSTFIRM),
2673: .driver_info = ADI930 | PSTFIRM | AUTO_ANNEX_B},
2674: {USB_DEVICE(USR_VID, MILLER_A_PID_PREFIRM),
2675: .driver_info = EAGLE_I | PREFIRM},
2676: {USB_DEVICE(USR_VID, MILLER_A_PID_PSTFIRM),
2677: .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_A},
2678: {USB_DEVICE(USR_VID, MILLER_B_PID_PREFIRM),
2679: .driver_info = EAGLE_I | PREFIRM},
2680: {USB_DEVICE(USR_VID, MILLER_B_PID_PSTFIRM),
2681: .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_B},
2682: {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PREFIRM),
2683: .driver_info = EAGLE_I | PREFIRM},
2684: {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PSTFIRM),
2685: .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_A},
2686: {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PREFIRM),
2687: .driver_info = EAGLE_I | PREFIRM},
2688: {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PSTFIRM),
2689: .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_B},
2690: {}
2691: };
SourceFile:drivers/usb/atm/ueagle-atm.c]
|
| 26/2 |
2026/06/29 00:38 |
llm |
expert |
0m
Model:
Tokens:
input: 23154
output: 42
thoughts: 700
Thoughts: **Vulnerability Deep Dive: A USB Device Firmware Loading Exploit**
Okay, let's break this down. My initial assessment is that a potential vulnerability exists within this USB device firmware loading process. I'm seeing a scenario where an attacker could exploit a race condition or type confusion during device disconnection.
Here's my thought process: an attacker plugs in a USB device with specific Vendor and Product IDs (`VID=ANALOG_VID` and `PID=ADI930_PID_PREFIRM`). This device is crafted to present multiple interfaces (`bNumInterfaces != 1`), let's say two.
The `uea_probe` function is then triggered. Because the device matches the "pre-firmware" criteria (`UEA_IS_PREFIRM(id)`), the code proceeds to load the firmware asynchronously. It allocates a completion structure (`fw_done`), initializes it, and associates it with the USB interface using `usb_set_intfdata(intf, fw_done)`. Crucially, `uea_load_firmware` is called, which initiates a firmware load. The code then returns from `uea_probe`, leaving the firmware load in progress.
Now, here's where the potential issue arises: the attacker *unplugs* the device. This triggers the `uea_disconnect` function. The code checks the number of interfaces and the interface number. If the device has multiple interfaces *and* the interface number is zero (`bNumInterfaces != 1` and `ifnum == 0`), the code calls `usbatm_usb_disconnect(intf)`.
The problem is that `usbatm_usb_disconnect` is designed to free the `usbatm` data associated with the interface. However, in this "pre-firmware" scenario, the `usb_set_intfdata(intf, fw_done)` call in `uea_probe` means that `intf->driver_data` is `fw_done`, *not* `usbatm`.
Therefore, `usbatm_usb_disconnect` will attempt to interpret the `fw_done` structure as if it were `usbatm` data. This is a type confusion bug! The code will be attempting to free the wrong memory and use a structure with the wrong layout, likely leading to a crash or, more critically, a controlled overwrite or code execution if memory corruption is exploited.
The only way the code continues to protect the completion structure after the call to `usbatm_usb_disconnect` is if `bNumInterfaces` is equal to 1, or the interface number is not 0 (e.g. `ifnum` is 1). In the latter case the code proceeds to wait for the completion (`fw_done`) and then frees the memory safely.
I need to confirm what `usbatm_usb_disconnect` actually does, to assess the severity. It could be a simple crash or a full-blown remote code execution vulnerability! This needs immediate investigation.
|
| 27/2 |
2026/06/29 00:38 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/usbatm.c Name:usbatm_usb_disconnect]
Results: map[SourceCode:1207: void usbatm_usb_disconnect(struct usb_interface *intf)
1208: {
1209: struct device *dev = &intf->dev;
1210: struct usbatm_data *instance = usb_get_intfdata(intf);
1211: struct usbatm_vcc_data *vcc_data;
1212: int i;
1213:
1214: if (!instance) {
1215: dev_dbg(dev, "%s: NULL instance!\n", __func__);
1216: return;
1217: }
1218:
1219: usb_set_intfdata(intf, NULL);
1220:
1221: mutex_lock(&instance->serialize);
1222: instance->disconnected = 1;
1223: if (instance->thread != NULL)
1224: send_sig(SIGTERM, instance->thread, 1);
1225: mutex_unlock(&instance->serialize);
1226:
1227: wait_for_completion(&instance->thread_exited);
1228:
1229: mutex_lock(&instance->serialize);
1230: list_for_each_entry(vcc_data, &instance->vcc_list, list)
1231: vcc_release_async(vcc_data->vcc, -EPIPE);
1232: mutex_unlock(&instance->serialize);
1233:
1234: tasklet_disable(&instance->rx_channel.tasklet);
1235: tasklet_disable(&instance->tx_channel.tasklet);
1236:
1237: for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++)
1238: usb_kill_urb(instance->urbs[i]);
1239:
1240: timer_delete_sync(&instance->rx_channel.delay);
1241: timer_delete_sync(&instance->tx_channel.delay);
1242:
1243: /* turn usbatm_[rt]x_process into something close to a no-op */
1244: /* no need to take the spinlock */
1245: INIT_LIST_HEAD(&instance->rx_channel.list);
1246: INIT_LIST_HEAD(&instance->tx_channel.list);
1247:
1248: tasklet_enable(&instance->rx_channel.tasklet);
1249: tasklet_enable(&instance->tx_channel.tasklet);
1250:
1251: if (instance->atm_dev && instance->driver->atm_stop)
1252: instance->driver->atm_stop(instance, instance->atm_dev);
1253:
1254: if (instance->driver->unbind)
1255: instance->driver->unbind(instance, intf);
1256:
1257: instance->driver_data = NULL;
1258:
1259: for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) {
1260: kfree(instance->urbs[i]->transfer_buffer);
1261: usb_free_urb(instance->urbs[i]);
1262: }
1263:
1264: kfree(instance->cell_buf);
1265:
1266: /* ATM finalize */
1267: if (instance->atm_dev) {
1268: atm_dev_deregister(instance->atm_dev);
1269: instance->atm_dev = NULL;
1270: }
1271:
1272: usbatm_put_instance(instance); /* taken in usbatm_usb_probe */
1273: }
SourceFile:drivers/usb/atm/usbatm.c]
|
| 28/2 |
2026/06/29 00:38 |
llm |
expert |
0m
Model:
Tokens:
input: 25617
output: 40
thoughts: 555
Thoughts: **Analyzing a Potential USB ATM Driver UAF Vulnerability**
Okay, let's break this down. My initial thought was that a potential crash in `usbatm_usb_disconnect` was happening, specifically when passed a `struct completion *` instead of a `struct usbatm_data *`. But the KASAN report indicates a use-after-free in `uea_upload_pre_firmware`, which means that function is still running and attempting to access the `intf` variable. If `usbatm_usb_disconnect` was the problem, I'd expect the crash to be *there*, not in `uea_upload_pre_firmware`.
So why isn't `usbatm_usb_disconnect` crashing? Ah, the conditional! It's likely that `ifnum` isn't equal to zero. Let's look at the code:
```c
if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
```
If `usb->config->desc.bNumInterfaces` isn't equal to one and `ifnum` is zero, we *might* have a problem.
```c
} else if (usb->config->desc.bNumInterfaces == 1) {
```
But, if it's *not* equal to one AND `ifnum` isn't zero, it goes nowhere. It doesn't wait for `fw_done`, and it doesn't call `usbatm_usb_disconnect`! It just returns, and the USB core then presumably frees `intf`.
The problem is that `uea_upload_pre_firmware` is then accessing that freed interface. This explains the Use-After-Free (UAF) error. But can `ifnum` *actually* be something other than zero? Absolutely. An attacker could create a USB device with `bNumInterfaces` set to two or more. The USB core will then probe each interface. When it probes the second or later interface, `ifnum` will be 1 or higher. This means that `uea_probe` will be called for all interfaces. But wait, `uea_probe` is called *for each* interface? That's right, `uea_probe` is a USB driver's probe function, triggered for each interface that matches the device ID.
And now I see it. The device ID matches at the *device* level using `USB_DEVICE(VID, PID)`. So the USB core sees the whole device, not the interfaces separately. Which means `uea_probe` is called for *every* interface on the device. Then the driver will load for the first interface and do some initialization before failing the second. And since `bNumInterfaces != 1 && ifnum != 0`, the driver does nothing, and the UAF occurs. This is definitely something that needs to be checked.
|
| 29/2 |
2026/06/29 00:38 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/ueagle-atm.c Name:uea_probe]
Results: map[SourceCode:2549: static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
2550: {
2551: struct usb_device *usb = interface_to_usbdev(intf);
2552: int ret;
2553:
2554: uea_dbg(usb, "ADSL device found with vid (%#X) pid (%#X) Rev (%#X): %s\n",
2555: le16_to_cpu(usb->descriptor.idVendor),
2556: le16_to_cpu(usb->descriptor.idProduct),
2557: le16_to_cpu(usb->descriptor.bcdDevice),
2558: chip_name[UEA_CHIP_VERSION(id)]);
2559:
2560: usb_reset_device(usb);
2561:
2562: if (UEA_IS_PREFIRM(id)) {
2563: struct completion *fw_done;
2564:
2565: /* Wait for the firmware load to be done, in .disconnect() */
2566: fw_done = kzalloc_obj(*fw_done);
2567: if (!fw_done)
2568: return -ENOMEM;
2569:
2570: init_completion(fw_done);
2571: usb_set_intfdata(intf, fw_done);
2572:
2573: ret = uea_load_firmware(intf, UEA_CHIP_VERSION(id));
2574: if (ret)
2575: kfree(fw_done);
2576:
2577: return ret;
2578: }
2579:
2580: ret = usbatm_usb_probe(intf, id, &uea_usbatm_driver);
2581: if (ret == 0) {
2582: struct usbatm_data *usbatm = usb_get_intfdata(intf);
2583: struct uea_softc *sc = usbatm->driver_data;
2584:
2585: /* Ensure carrier is initialized to off as early as possible */
2586: UPDATE_ATM_SIGNAL(ATM_PHY_SIG_LOST);
2587:
2588: /* Only start the worker thread when all init is done */
2589: wake_up_process(sc->kthread);
2590: }
2591:
2592: return ret;
2593: }
SourceFile:drivers/usb/atm/ueagle-atm.c]
|
| 30/2 |
2026/06/29 00:38 |
llm |
expert |
0m
Model:
Tokens:
input: 27585
output: 34
thoughts: 756
Thoughts: **Analyzing a Potential Kernel Crash**
Okay, so I'm digging into this code and I see a potential issue. If `UEA_IS_PREFIRM(id)` is true, `uea_probe` iterates through *every* interface and calls `uea_load_firmware` for each. Now, if `bNumInterfaces` is equal to 2, `uea_probe` gets called for `ifnum == 0` and `ifnum == 1`. This leads to `uea_load_firmware` being called for both `intf0` and `intf1`, which makes sense so far.
Then the device gets disconnected and that is where it gets interesting. `uea_disconnect` is called for `intf0` (when `ifnum` is 0). Inside, it calls `usbatm_usb_disconnect(intf)`. The kicker is that `usbatm_usb_disconnect` expects a `struct usbatm_data *` from `usb_get_intfdata(intf)`. But for `intf0`, the data set with `usb_set_intfdata` is actually `fw_done`! This `fw_done` is just a `struct completion`!
So, `usbatm_usb_disconnect` is going to dereference something that *should* be a large structure, but *is* just a small `struct completion`. This has crash written all over it. The code attempts to get `struct usbatm_data *instance = usb_get_intfdata(intf);`, then checks if `instance` is NULL. It also accesses a mutex `mutex_lock(&instance->serialize)`, which is going to be out of bounds for a small `struct completion`!
Okay, so the syzbot report gives me a clue. I see that `fw_done` is allocated using `kzalloc_obj(*fw_done)`. I need to remember what that really does; it's probably `kzalloc(sizeof(*fw_done), GFP_KERNEL)`.
Hmm, syzbot also tells me: "The buggy address belongs to the object at ffff888062b26000 which belongs to the cache kmalloc-2k of size 2048". Wait, am I dealing with a `kmalloc-2k` object? The buggy address is `ffff888062b260b8` though. The offset of 0xb8 is 184 bytes. Could `intf` be allocated from `kmalloc-2k`? I'm going to check the size of `struct usb_interface`. It sounds like the `struct usb_interface`'s size would be 184 bytes!
This could be the root cause of the crash. I need to confirm the size of `struct usb_interface`, but it looks like I'm onto something.
|
| 31/2 |
2026/06/29 00:38 |
tool |
codesearch-struct-layout |
0m
Args: map[ContextFile:include/linux/usb.h Name:usb_interface]
Results: map[Fields:[map[Name:altsetting OffsetBits:0 SizeBits:64] map[Name:cur_altsetting OffsetBits:64 SizeBits:64] map[Name:num_altsetting OffsetBits:128 SizeBits:32] map[Name:intf_assoc OffsetBits:192 SizeBits:64] map[Name:minor OffsetBits:256 SizeBits:32] map[Name:condition OffsetBits:288 SizeBits:32] map[Name:sysfs_files_created OffsetBits:320 SizeBits:1] map[Name:ep_devs_created OffsetBits:321 SizeBits:1] map[Name:unregistering OffsetBits:322 SizeBits:1] map[Name:needs_remote_wakeup OffsetBits:323 SizeBits:1] map[Name:needs_altsetting0 OffsetBits:324 SizeBits:1] map[Name:needs_binding OffsetBits:325 SizeBits:1] map[Name:resetting_device OffsetBits:326 SizeBits:1] map[Name:authorized OffsetBits:327 SizeBits:1] map[Name:wireless_status OffsetBits:352 SizeBits:32] map[Name:wireless_status_work OffsetBits:384 SizeBits:576] map[Name:dev OffsetBits:960 SizeBits:11776] map[Name:usb_dev OffsetBits:12736 SizeBits:64] map[Name:reset_ws OffsetBits:12800 SizeBits:576]]]
|
| 32/2 |
2026/06/29 00:38 |
llm |
expert |
0m
Model:
Tokens:
input: 29427
output: 39
thoughts: 208
Thoughts: **Analyzing USB Device Structure Access**
Okay, so I'm looking at this memory offset, 184 bytes, which translates to 1472 bits. I know that the `dev` structure, part of a `struct device`, begins at 960 bits (or 120 bytes) and spans a substantial 11776 bits (1472 bytes). Immediately, I recognize that offset 184 falls squarely within the `dev` region.
Now, my focus shifts to the `interface_to_usbdev(intf)` function. I recall its definition:
```c
static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf)
{
return to_usb_device(intf->dev.parent);
}
```
Aha! It's accessing `intf->dev.parent`. Now the crucial piece is where that resides within the larger structure. Let's see... `dev.parent` is at an offset of 16 bytes within the `struct device`. Therefore the address is 120 bytes (start of dev) + 16 bytes = 136 bytes. Wait, let's verify if the call is inlined. Good, it is an inline function, so it's probably getting inlined. Now, let's also verify `__intf_to_usbdev` just in case.
|
| 33/2 |
2026/06/29 00:38 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/linux/usb.h Name:__intf_to_usbdev]
Results: map[SourceCode: 750: static inline struct usb_device *__intf_to_usbdev(struct usb_interface *intf)
751: {
752: return to_usb_device(intf->dev.parent);
753: }
SourceFile:include/linux/usb.h]
|
| 34/2 |
2026/06/29 00:38 |
llm |
expert |
0m
Model:
Tokens:
input: 30082
output: 32
thoughts: 24
Thoughts: Here's my thought process, as if I were analyzing that code:
**Checking Device Parentage**
Okay, first things first. I see a reference to `intf->dev.parent`. That immediately flags a potential issue, or at least a point of interest, depending on the context. I need to understand what this `dev.parent` field represents, so I'm going to quickly review the `struct device` layout. I'm going to look at how the `struct device` is defined, and especially where `parent` sits within that structure and what it points to. I need to ensure the access is valid and that I understand the relationship it establishes within the device hierarchy. I'm also considering what might happen if that `parent` pointer is null, and if the code is handling that potential scenario correctly. This initial check is crucial to understanding the data flow and potential dependencies. I want to build a mental picture of the device's relationship within the system.
|
| 35/2 |
2026/06/29 00:38 |
tool |
codesearch-struct-layout |
0m
Args: map[ContextFile:include/linux/device.h Name:device]
Results: map[Fields:[map[Name:kobj OffsetBits:0 SizeBits:512] map[Name:parent OffsetBits:512 SizeBits:64] map[Name:p OffsetBits:576 SizeBits:64] map[Name:init_name OffsetBits:640 SizeBits:64] map[Name:type OffsetBits:704 SizeBits:64] map[Name:bus OffsetBits:768 SizeBits:64] map[Name:driver OffsetBits:832 SizeBits:64] map[Name:platform_data OffsetBits:896 SizeBits:64] map[Name:driver_data OffsetBits:960 SizeBits:64] map[Name:driver_override OffsetBits:1024 SizeBits:1088] map[Name:mutex OffsetBits:2112 SizeBits:1024] map[Name:links OffsetBits:3136 SizeBits:448] map[Name:power OffsetBits:3584 SizeBits:5440] map[Name:pm_domain OffsetBits:9024 SizeBits:64] map[Name:msi OffsetBits:9088 SizeBits:128] map[Name:dma_mask OffsetBits:9216 SizeBits:64] map[Name:coherent_dma_mask OffsetBits:9280 SizeBits:64] map[Name:bus_dma_limit OffsetBits:9344 SizeBits:64] map[Name:dma_range_map OffsetBits:9408 SizeBits:64] map[Name:dma_parms OffsetBits:9472 SizeBits:64] map[Name:dma_pools OffsetBits:9536 SizeBits:128] map[Name:dma_mem OffsetBits:9664 SizeBits:64] map[Name:cma_area OffsetBits:9728 SizeBits:64] map[Name:dma_io_tlb_mem OffsetBits:9792 SizeBits:64] map[Name:archdata OffsetBits:9856 SizeBits:0] map[Name:of_node OffsetBits:9856 SizeBits:64] map[Name:fwnode OffsetBits:9920 SizeBits:64] map[Name:numa_node OffsetBits:9984 SizeBits:32] map[Name:devt OffsetBits:10016 SizeBits:32] map[Name:id OffsetBits:10048 SizeBits:32] map[Name:devres_lock OffsetBits:10112 SizeBits:1024] map[Name:devres_head OffsetBits:11136 SizeBits:128] map[Name:class OffsetBits:11264 SizeBits:64] map[Name:groups OffsetBits:11328 SizeBits:64] map[Name:release OffsetBits:11392 SizeBits:64] map[Name:iommu_group OffsetBits:11456 SizeBits:64] map[Name:iommu OffsetBits:11520 SizeBits:64] map[Name:physical_location OffsetBits:11584 SizeBits:64] map[Name:removable OffsetBits:11648 SizeBits:32] map[Name:flags OffsetBits:11712 SizeBits:64]]]
|
| 36/2 |
2026/06/29 00:38 |
llm |
expert |
0m
Model:
Tokens:
input: 31244
output: 40
thoughts: 694
Thoughts: **Analyzing a USB Driver UAF Bug**
Okay, let's break this down. The KASAN report is pinpointing an issue at 184 bytes into a freed 2048-byte region. Knowing that `parent` is offset 64 bytes within the relevant structure and that the structure, `intf->dev.parent`, is located at offset 120 + 64 = 184 bytes, it's pretty clear that `intf` has been freed, as KASAN suggests!
So, here's the bug in a nutshell: an attacker plugs in a USB device with a pre-firmware VID and PID. Critically, this device has multiple interfaces (`bNumInterfaces != 1`) and the interface of interest isn't the first one (`bInterfaceNumber != 0`). When `uea_probe` is called, it identifies the device as requiring pre-firmware loading, allocates `fw_done`, and sets it as interface data. Then, `uea_load_firmware` initiates firmware loading asynchronously.
The attacker then unplugs the device. This is where the problem arises. `uea_disconnect` is called. It checks the interface numbers, it sees `bNumInterfaces != 1` and `ifnum != 0` meaning it skips the disconnect and return!
The USB core then frees `intf`.
The asynchronous firmware loading, specifically `uea_upload_pre_firmware`, which is scheduled earlier, now tries to access `intf->dev.parent` after it has been freed, leading to a UAF!
Now, the interesting question is if `ifnum == 0` what would happen then? Looking at the code for that case:
```c
if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
mutex_lock(&uea_mutex);
usbatm_usb_disconnect(intf);
mutex_unlock(&uea_mutex);
uea_info(usb, "ADSL device removed\n");
}
```
It executes `usbatm_usb_disconnect(intf)`, which retrieves `instance = usb_get_intfdata(intf)`. `instance` here is `fw_done`, which is a `struct completion *`. The code then attempts `mutex_lock(&instance->serialize)`.
`instance->serialize` is located at some offset within `struct usbatm_data`.
I'll need to check the `struct usbatm_data` definition to understand where that points to and what the implications of that are...
|
| 37/2 |
2026/06/29 00:38 |
tool |
codesearch-struct-layout |
0m
Args: map[ContextFile:drivers/usb/atm/usbatm.h Name:usbatm_data]
Results: map[Fields:[map[Name:driver OffsetBits:0 SizeBits:64] map[Name:driver_data OffsetBits:64 SizeBits:64] map[Name:driver_name OffsetBits:128 SizeBits:128] map[Name:flags OffsetBits:256 SizeBits:32] map[Name:usb_dev OffsetBits:320 SizeBits:64] map[Name:usb_intf OffsetBits:384 SizeBits:64] map[Name:description OffsetBits:448 SizeBits:512] map[Name:atm_dev OffsetBits:960 SizeBits:64] map[Name:refcount OffsetBits:1024 SizeBits:32] map[Name:serialize OffsetBits:1088 SizeBits:1024] map[Name:disconnected OffsetBits:2112 SizeBits:32] map[Name:thread OffsetBits:2176 SizeBits:64] map[Name:thread_started OffsetBits:2240 SizeBits:704] map[Name:thread_exited OffsetBits:2944 SizeBits:704] map[Name:vcc_list OffsetBits:3648 SizeBits:128] map[Name:rx_channel OffsetBits:3776 SizeBits:2304] map[Name:tx_channel OffsetBits:6080 SizeBits:2304] map[Name:sndqueue OffsetBits:8384 SizeBits:1216] map[Name:current_skb OffsetBits:9600 SizeBits:64] map[Name:cached_vcc OffsetBits:9664 SizeBits:64] map[Name:cached_vci OffsetBits:9728 SizeBits:32] map[Name:cached_vpi OffsetBits:9760 SizeBits:16] map[Name:cell_buf OffsetBits:9792 SizeBits:64] map[Name:buf_usage OffsetBits:9856 SizeBits:32] map[Name:urbs OffsetBits:9920 SizeBits:0]]]
|
| 38/2 |
2026/06/29 00:38 |
llm |
expert |
0m
Model:
Tokens:
input: 33109
output: 45
thoughts: 787
Thoughts: **Analyzing a Potential Kernel Exploit**
Okay, let's break this down. First, I see a potential out-of-bounds memory access. The `serialize` variable is positioned at an offset of 136 bytes within an allocation. Meanwhile, `fw_done`, a `struct completion`, is only 32 bytes. Locking the mutex `instance->serialize` is going to read at offset 136, but it is only allocated as 32 bytes! That's going to cause a crash or at least memory corruption, right?
But wait. I see `fw_done` is allocated using `kzalloc_obj(*fw_done)`, which allocates 32 bytes for a struct completion into the `kmalloc-32` slab. Offset 136 is definitely outside that 32-byte object. Definitely an out of bounds access.
Now, it looks like a device disconnect scenario is the trigger. If the device gets unplugged, `uea_disconnect` gets called for interface numbers 0 and 1. If interface 1 is processed first, we get a UAF. However, if interface 0 is first, there's an out-of-bounds access. Interesting. The order of USB interface disconnects is typically in reverse order, but sometimes in order. This gives the attacker some degree of control over the execution path. A malicious USB device can probably be used to trigger this bug!
The UAF is a read of 8 bytes from `intf->dev.parent`. Let me check the code:
```c
static inline struct usb_device *__intf_to_usbdev(struct usb_interface *intf)
{
return to_usb_device(intf->dev.parent);
}
```
Okay, `intf` is freed. The attacker can probably spray the `kmalloc-2k` cache to overwrite `intf->dev.parent` with a controlled pointer. If the attacker can control `intf->dev.parent` in the freed memory, then `__intf_to_usbdev` will return a controlled pointer as `usb`.
Then, in `uea_upload_pre_firmware`, it calls `usb_get_intfdata(intf)`. Which is defined as:
```c
static inline void *usb_get_intfdata(struct usb_interface *intf)
{
return dev_get_drvdata(&intf->dev);
}
```
So `usb_get_intfdata(intf)` accesses `intf->dev.driver_data`. This is read from the freed `intf`, which the attacker also controls. They can control both `intf->dev.parent` and `intf->dev.driver_data`.
The code then checks `if (!fw_entry)`. If there is no fw_entry, it will print an error message, using the `uea_err` macro:
```c
#define uea_err(usb, format, arg...) \
dev_err(&(usb)->dev, format, ##arg)
```
The macro expands to `dev_err(&(usb)->dev, format, ##arg)`. So, it accesses `usb->dev`. Since `usb` is the controlled `intf->dev.parent`, the attacker can control `usb->dev`. This is a very interesting point to control. `dev_err` accesses `usb->dev` to print the error message. That could be where code execution happens!
If `fw_entry` is valid, it then proceeds to:
```c
ret = uea_send_modem_cmd(usb, F8051_USBCS, sizeof(value), &value);
```
I need to understand what `uea_send_modem_cmd` does.
|
| 39/2 |
2026/06/29 00:39 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/ueagle-atm.c Name:uea_send_modem_cmd]
Results: map[SourceCode: 568: /*
569: * uea_send_modem_cmd - Send a command for pre-firmware devices.
570: */
571: static int uea_send_modem_cmd(struct usb_device *usb,
572: u16 addr, u16 size, const u8 *buff)
573: {
574: int ret = -ENOMEM;
575: u8 *xfer_buff;
576:
577: xfer_buff = kmemdup(buff, size, GFP_KERNEL);
578: if (xfer_buff) {
579: ret = usb_control_msg(usb,
580: usb_sndctrlpipe(usb, 0),
581: LOAD_INTERNAL,
582: USB_DIR_OUT | USB_TYPE_VENDOR |
583: USB_RECIP_DEVICE, addr, 0, xfer_buff,
584: size, CTRL_TIMEOUT);
585: kfree(xfer_buff);
586: }
587:
588: if (ret < 0)
589: return ret;
590:
591: return (ret == size) ? 0 : -EIO;
592: }
SourceFile:drivers/usb/atm/ueagle-atm.c]
|
| 40/2 |
2026/06/29 00:39 |
llm |
expert |
0m
Model:
Tokens:
input: 35189
output: 38
thoughts: 260
Thoughts: **Analyzing the `uea_send_modem_cmd` Function Call**
Okay, so `uea_send_modem_cmd` is using `usb_control_msg` with a `usb` pointer. Ah, right, that `usb` is a `struct usb_device *`. `usb_control_msg` is a low-level primitive; it lets me send control messages using the `usb` pointer. This is where things get interesting because I control that `usb` pointer! And `usb_control_msg` is going to use that pointer to access a bunch of fields within the `usb` structure: `usb->bus`, `usb->ep0`, and so on.
My mind immediately starts thinking about memory corruption. If I can carefully craft a fake `struct usb_device`, I could potentially achieve arbitrary memory read or write, or even control flow hijacking. For instance, if there are function pointers lurking in `usb->bus` or `usb->ep0` that get called later, I could redirect execution. This is a classic vulnerability vector.
Hang on a second⦠I need to dig deeper into the call chain. `usb_control_msg` calls `usb_internal_control_msg`, which in turn calls `usb_start_wait_urb`. Okay, so `usb_start_wait_urb` allocates an URB, sets `urb->dev = usb`, and then calls `usb_submit_urb`. Alright, so the URB uses my controlled `usb` struct...
`usb_submit_urb` is the critical point. It's accessing `usb->bus` and, likely, calling `usb->bus->op->submit_urb` or something similar. I need to confirm that. Let's get into the details of `usb_submit_urb` and see what it does.
|
| 41/2 |
2026/06/29 00:39 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/core/urb.c Name:usb_submit_urb]
Results: map[SourceCode: 230: /**
231: * usb_submit_urb - issue an asynchronous transfer request for an endpoint
232: * @urb: pointer to the urb describing the request
233: * @mem_flags: the type of memory to allocate, see kmalloc() for a list
234: * of valid options for this.
235: *
236: * This submits a transfer request, and transfers control of the URB
237: * describing that request to the USB subsystem. Request completion will
238: * be indicated later, asynchronously, by calling the completion handler.
239: * The three types of completion are success, error, and unlink
240: * (a software-induced fault, also called "request cancellation").
241: *
242: * URBs may be submitted in interrupt context.
243: *
244: * The caller must have correctly initialized the URB before submitting
245: * it. Functions such as usb_fill_bulk_urb() and usb_fill_control_urb() are
246: * available to ensure that most fields are correctly initialized, for
247: * the particular kind of transfer, although they will not initialize
248: * any transfer flags.
249: *
250: * If the submission is successful, the complete() callback from the URB
251: * will be called exactly once, when the USB core and Host Controller Driver
252: * (HCD) are finished with the URB. When the completion function is called,
253: * control of the URB is returned to the device driver which issued the
254: * request. The completion handler may then immediately free or reuse that
255: * URB.
256: *
257: * With few exceptions, USB device drivers should never access URB fields
258: * provided by usbcore or the HCD until its complete() is called.
259: * The exceptions relate to periodic transfer scheduling. For both
260: * interrupt and isochronous urbs, as part of successful URB submission
261: * urb->interval is modified to reflect the actual transfer period used
262: * (normally some power of two units). And for isochronous urbs,
263: * urb->start_frame is modified to reflect when the URB's transfers were
264: * scheduled to start.
265: *
266: * Not all isochronous transfer scheduling policies will work, but most
267: * host controller drivers should easily handle ISO queues going from now
268: * until 10-200 msec into the future. Drivers should try to keep at
269: * least one or two msec of data in the queue; many controllers require
270: * that new transfers start at least 1 msec in the future when they are
271: * added. If the driver is unable to keep up and the queue empties out,
272: * the behavior for new submissions is governed by the URB_ISO_ASAP flag.
273: * If the flag is set, or if the queue is idle, then the URB is always
274: * assigned to the first available (and not yet expired) slot in the
275: * endpoint's schedule. If the flag is not set and the queue is active
276: * then the URB is always assigned to the next slot in the schedule
277: * following the end of the endpoint's previous URB, even if that slot is
278: * in the past. When a packet is assigned in this way to a slot that has
279: * already expired, the packet is not transmitted and the corresponding
280: * usb_iso_packet_descriptor's status field will return -EXDEV. If this
281: * would happen to all the packets in the URB, submission fails with a
282: * -EXDEV error code.
283: *
284: * For control endpoints, the synchronous usb_control_msg() call is
285: * often used (in non-interrupt context) instead of this call.
286: * That is often used through convenience wrappers, for the requests
287: * that are standardized in the USB 2.0 specification. For bulk
288: * endpoints, a synchronous usb_bulk_msg() call is available.
289: *
290: * Return:
291: * 0 on successful submissions. A negative error number otherwise.
292: *
293: * Request Queuing:
294: *
295: * URBs may be submitted to endpoints before previous ones complete, to
296: * minimize the impact of interrupt latencies and system overhead on data
297: * throughput. With that queuing policy, an endpoint's queue would never
298: * be empty. This is required for continuous isochronous data streams,
299: * and may also be required for some kinds of interrupt transfers. Such
300: * queuing also maximizes bandwidth utilization by letting USB controllers
301: * start work on later requests before driver software has finished the
302: * completion processing for earlier (successful) requests.
303: *
304: * As of Linux 2.6, all USB endpoint transfer queues support depths greater
305: * than one. This was previously a HCD-specific behavior, except for ISO
306: * transfers. Non-isochronous endpoint queues are inactive during cleanup
307: * after faults (transfer errors or cancellation).
308: *
309: * Reserved Bandwidth Transfers:
310: *
311: * Periodic transfers (interrupt or isochronous) are performed repeatedly,
312: * using the interval specified in the urb. Submitting the first urb to
313: * the endpoint reserves the bandwidth necessary to make those transfers.
314: * If the USB subsystem can't allocate sufficient bandwidth to perform
315: * the periodic request, submitting such a periodic request should fail.
316: *
317: * For devices under xHCI, the bandwidth is reserved at configuration time, or
318: * when the alt setting is selected. If there is not enough bus bandwidth, the
319: * configuration/alt setting request will fail. Therefore, submissions to
320: * periodic endpoints on devices under xHCI should never fail due to bandwidth
321: * constraints.
322: *
323: * Device drivers must explicitly request that repetition, by ensuring that
324: * some URB is always on the endpoint's queue (except possibly for short
325: * periods during completion callbacks). When there is no longer an urb
326: * queued, the endpoint's bandwidth reservation is canceled. This means
327: * drivers can use their completion handlers to ensure they keep bandwidth
328: * they need, by reinitializing and resubmitting the just-completed urb
329: * until the driver longer needs that periodic bandwidth.
330: *
331: * Memory Flags:
332: *
333: * The general rules for how to decide which mem_flags to use
334: * are the same as for kmalloc. There are four
335: * different possible values; GFP_KERNEL, GFP_NOFS, GFP_NOIO and
336: * GFP_ATOMIC.
337: *
338: * GFP_NOFS is not ever used, as it has not been implemented yet.
339: *
340: * GFP_ATOMIC is used when
341: * (a) you are inside a completion handler, an interrupt, bottom half,
342: * tasklet or timer, or
343: * (b) you are holding a spinlock or rwlock (does not apply to
344: * semaphores), or
345: * (c) current->state != TASK_RUNNING, this is the case only after
346: * you've changed it.
347: *
348: * GFP_NOIO is used in the block io path and error handling of storage
349: * devices.
350: *
351: * All other situations use GFP_KERNEL.
352: *
353: * Some more specific rules for mem_flags can be inferred, such as
354: * (1) start_xmit, timeout, and receive methods of network drivers must
355: * use GFP_ATOMIC (they are called with a spinlock held);
356: * (2) queuecommand methods of scsi drivers must use GFP_ATOMIC (also
357: * called with a spinlock held);
358: * (3) If you use a kernel thread with a network driver you must use
359: * GFP_NOIO, unless (b) or (c) apply;
360: * (4) after you have done a down() you can use GFP_KERNEL, unless (b) or (c)
361: * apply or your are in a storage driver's block io path;
362: * (5) USB probe and disconnect can use GFP_KERNEL unless (b) or (c) apply; and
363: * (6) changing firmware on a running storage or net device uses
364: * GFP_NOIO, unless b) or c) apply
365: *
366: */
367: int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
368: {
369: int xfertype, max;
370: struct usb_device *dev;
371: struct usb_host_endpoint *ep;
372: int is_out;
373: unsigned int allowed;
374: bool is_eusb2_isoch_double;
375:
376: if (!urb || !urb->complete)
377: return -EINVAL;
378: if (urb->hcpriv) {
379: WARN_ONCE(1, "URB %p submitted while active\n", urb);
380: return -EBUSY;
381: }
382:
383: dev = urb->dev;
384: if ((!dev) || (dev->state < USB_STATE_UNAUTHENTICATED))
385: return -ENODEV;
386:
387: /* For now, get the endpoint from the pipe. Eventually drivers
388: * will be required to set urb->ep directly and we will eliminate
389: * urb->pipe.
390: */
391: ep = usb_pipe_endpoint(dev, urb->pipe);
392: if (!ep)
393: return -ENOENT;
394:
395: urb->ep = ep;
396: urb->status = -EINPROGRESS;
397: urb->actual_length = 0;
398:
399: /* Lots of sanity checks, so HCDs can rely on clean data
400: * and don't need to duplicate tests
401: */
402: xfertype = usb_endpoint_type(&ep->desc);
403: if (xfertype == USB_ENDPOINT_XFER_CONTROL) {
404: struct usb_ctrlrequest *setup =
405: (struct usb_ctrlrequest *) urb->setup_packet;
406:
407: if (!setup)
408: return -ENOEXEC;
409: is_out = !(setup->bRequestType & USB_DIR_IN) ||
410: !setup->wLength;
411: dev_WARN_ONCE(&dev->dev, (usb_pipeout(urb->pipe) != is_out),
412: "BOGUS control dir, pipe %x doesn't match bRequestType %x\n",
413: urb->pipe, setup->bRequestType);
414: if (le16_to_cpu(setup->wLength) != urb->transfer_buffer_length) {
415: dev_dbg(&dev->dev, "BOGUS control len %d doesn't match transfer length %d\n",
416: le16_to_cpu(setup->wLength),
417: urb->transfer_buffer_length);
418: return -EBADR;
419: }
420: } else {
421: is_out = usb_endpoint_dir_out(&ep->desc);
422: }
423:
424: /* Clear the internal flags and cache the direction for later use */
425: urb->transfer_flags &= ~(URB_DIR_MASK | URB_DMA_MAP_SINGLE |
426: URB_DMA_MAP_PAGE | URB_DMA_MAP_SG | URB_MAP_LOCAL |
427: URB_SETUP_MAP_SINGLE | URB_SETUP_MAP_LOCAL |
428: URB_DMA_SG_COMBINED);
429: urb->transfer_flags |= (is_out ? URB_DIR_OUT : URB_DIR_IN);
430: kmsan_handle_urb(urb, is_out);
431:
432: if (xfertype != USB_ENDPOINT_XFER_CONTROL &&
433: dev->state < USB_STATE_CONFIGURED)
434: return -ENODEV;
435:
436: max = usb_endpoint_maxp(&ep->desc);
437: is_eusb2_isoch_double = usb_endpoint_is_hs_isoc_double(dev, ep);
438: if (!max && !is_eusb2_isoch_double) {
439: dev_dbg(&dev->dev,
440: "bogus endpoint ep%d%s in %s (bad maxpacket %d)\n",
441: usb_endpoint_num(&ep->desc), is_out ? "out" : "in",
442: __func__, max);
443: return -EMSGSIZE;
444: }
445:
446: /* periodic transfers limit size per frame/uframe,
447: * but drivers only control those sizes for ISO.
448: * while we're checking, initialize return status.
449: */
450: if (xfertype == USB_ENDPOINT_XFER_ISOC) {
451: int n, len;
452:
453: /* SuperSpeed isoc endpoints have up to 16 bursts of up to
454: * 3 packets each
455: */
456: if (dev->speed >= USB_SPEED_SUPER) {
457: int burst = 1 + ep->ss_ep_comp.bMaxBurst;
458: int mult = USB_SS_MULT(ep->ss_ep_comp.bmAttributes);
459: max *= burst;
460: max *= mult;
461: }
462:
463: if (dev->speed == USB_SPEED_SUPER_PLUS &&
464: USB_SS_SSP_ISOC_COMP(ep->ss_ep_comp.bmAttributes)) {
465: struct usb_ssp_isoc_ep_comp_descriptor *isoc_ep_comp;
466:
467: isoc_ep_comp = &ep->ssp_isoc_ep_comp;
468: max = le32_to_cpu(isoc_ep_comp->dwBytesPerInterval);
469: }
470:
471: /* High speed, 1-3 packets/uframe, max 6 for eUSB2 double bw */
472: if (dev->speed == USB_SPEED_HIGH) {
473: if (is_eusb2_isoch_double)
474: max = le32_to_cpu(ep->eusb2_isoc_ep_comp.dwBytesPerInterval);
475: else
476: max *= usb_endpoint_maxp_mult(&ep->desc);
477: }
478:
479: if (urb->number_of_packets <= 0)
480: return -EINVAL;
481: for (n = 0; n < urb->number_of_packets; n++) {
482: len = urb->iso_frame_desc[n].length;
483: if (len < 0 || len > max)
484: return -EMSGSIZE;
485: urb->iso_frame_desc[n].status = -EXDEV;
486: urb->iso_frame_desc[n].actual_length = 0;
487: }
488: } else if (urb->num_sgs && !urb->dev->bus->no_sg_constraint) {
489: struct scatterlist *sg;
490: int i;
491:
492: for_each_sg(urb->sg, sg, urb->num_sgs - 1, i)
493: if (sg->length % max)
494: return -EINVAL;
495: }
496:
497: /* the I/O buffer must be mapped/unmapped, except when length=0 */
498: if (urb->transfer_buffer_length > INT_MAX)
499: return -EMSGSIZE;
500:
501: /*
502: * stuff that drivers shouldn't do, but which shouldn't
503: * cause problems in HCDs if they get it wrong.
504: */
505:
506: /* Check that the pipe's type matches the endpoint's type */
507: if (usb_pipe_type_check(urb->dev, urb->pipe))
508: dev_warn_once(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n",
509: usb_pipetype(urb->pipe), pipetypes[xfertype]);
510:
511: /* Check against a simple/standard policy */
512: allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK |
513: URB_FREE_BUFFER);
514: switch (xfertype) {
515: case USB_ENDPOINT_XFER_BULK:
516: case USB_ENDPOINT_XFER_INT:
517: if (is_out)
518: allowed |= URB_ZERO_PACKET;
519: fallthrough;
520: default: /* all non-iso endpoints */
521: if (!is_out)
522: allowed |= URB_SHORT_NOT_OK;
523: break;
524: case USB_ENDPOINT_XFER_ISOC:
525: allowed |= URB_ISO_ASAP;
526: break;
527: }
528: allowed &= urb->transfer_flags;
529:
530: /* warn if submitter gave bogus flags */
531: if (allowed != urb->transfer_flags)
532: dev_WARN(&dev->dev, "BOGUS urb flags, %x --> %x\n",
533: urb->transfer_flags, allowed);
534:
535: /*
536: * Force periodic transfer intervals to be legal values that are
537: * a power of two (so HCDs don't need to).
538: *
539: * FIXME want bus->{intr,iso}_sched_horizon values here. Each HC
540: * supports different values... this uses EHCI/UHCI defaults (and
541: * EHCI can use smaller non-default values).
542: */
543: switch (xfertype) {
544: case USB_ENDPOINT_XFER_ISOC:
545: case USB_ENDPOINT_XFER_INT:
546: /* too small? */
547: if (urb->interval <= 0)
548: return -EINVAL;
549:
550: /* too big? */
551: switch (dev->speed) {
552: case USB_SPEED_SUPER_PLUS:
553: case USB_SPEED_SUPER: /* units are 125us */
554: /* Handle up to 2^(16-1) microframes */
555: if (urb->interval > (1 << 15))
556: return -EINVAL;
557: max = 1 << 15;
558: break;
559: case USB_SPEED_HIGH: /* units are microframes */
560: /* NOTE usb handles 2^15 */
561: if (urb->interval > (1024 * 8))
562: urb->interval = 1024 * 8;
563: max = 1024 * 8;
564: break;
565: case USB_SPEED_FULL: /* units are frames/msec */
566: case USB_SPEED_LOW:
567: if (xfertype == USB_ENDPOINT_XFER_INT) {
568: if (urb->interval > 255)
569: return -EINVAL;
570: /* NOTE ohci only handles up to 32 */
571: max = 128;
572: } else {
573: if (urb->interval > 1024)
574: urb->interval = 1024;
575: /* NOTE usb and ohci handle up to 2^15 */
576: max = 1024;
577: }
578: break;
579: default:
580: return -EINVAL;
581: }
582: /* Round down to a power of 2, no more than max */
583: urb->interval = min(max, 1 << ilog2(urb->interval));
584: }
585:
586: return usb_hcd_submit_urb(urb, mem_flags);
587: }
SourceFile:drivers/usb/core/urb.c]
|
| 42/2 |
2026/06/29 00:39 |
llm |
expert |
0m
Model:
Tokens:
input: 42114
output: 40
thoughts: 3167
Thoughts: **Bug Analysis: USB Device Driver Vulnerability**
Okay, so here's the breakdown of this critical kernel vulnerability. It looks like a classic use-after-free, ripe for privilege escalation.
The core issue centers around the `usb_submit_urb` function chain, specifically how a malicious USB device can manipulate the `usb_bus` structure. An attacker can control the `urb->dev` (the USB device), which then gives them control over the `usb->bus` pointer. By pointing this to a crafted, fake `usb_bus` object, they can redirect the call chain within `usb_hcd_submit_urb` through `bus_to_hcd` to point to a crafted `usb_hcd`. This, in turn, allows the attacker to control the `hcd->driver` pointer and the subsequent `urb_enqueue` function pointer. This is direct control flow hijacking, allowing for execution of arbitrary kernel code. Textbook stuff.
The attacker needs to be able to control `intf->dev.parent`. It looks like `struct usb_interface` fits within `kmalloc-2k`, so heap spraying techniques (e.g., using `msg_msg`, `userfaultfd` + `setxattr`, etc.) are viable to overwrite the `intf` structure. The attacker needs to overwrite the `intf->dev.parent` with a fake `struct usb_device`, and also make sure `usb_get_intfdata(intf)` returns something valid. The attacker can set `intf->dev.driver_data` to a fake `struct completion` in user space or a sprayed kernel object. This is all doable.
`uea_upload_pre_firmware` calls `usb_control_msg` which, through `usb_submit_urb`, hits the same vulnerability path. The attacker controls `usb`, therefore `usb->bus`, and through manipulation, can control the `hcd->driver->urb_enqueue` function pointer to execute arbitrary kernel code.
Regarding accessibility, the vulnerability can be triggered by plugging in a malicious USB device. It is not directly exploitable remotely unless there's a virtual USB setup like USB/IP. The key factor is the `ueagle-atm` driver being loaded.
Now, a crucial detail β the timing of the firmware loading and device disconnection. The use-after-free *only* occurs if the device is disconnected *before* or *while* `uea_upload_pre_firmware` is running. Since the attacker controls the device, they can win this race by disconnecting the device immediately after probing.
The potential for a denial-of-service also exists. If `bNumInterfaces != 1` and `ifnum == 0`, a different code path is taken. `usbatm_usb_disconnect` is called which attempts to access memory far beyond the allocated `struct completion` (specifically offset 136). This will lead to an out-of-bounds access, likely a crash, and is another vulnerability in the same driver.
I'm confident this is exploitable: physical access (to plug the USB device) is required, but an attacker with that level of access can achieve arbitrary code execution in the kernel. This is a very serious vulnerability.
|
| 43/2 |
2026/06/29 00:39 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/usb/atm/ueagle-atm.c Name:kzalloc_obj]
Results: map[SourceCode: SourceFile:]
|
| 44/2 |
2026/06/29 00:39 |
llm |
expert |
0m
Model:
Tokens:
input: 46039
output: 18
thoughts: 11
Thoughts: Here's my thought process, summarized as you requested:
**Investigating a `kzalloc_obj` Call**
Okay, so I'm seeing this reference to `kzalloc_obj`. That immediately flags a memory allocation within the kernel β and the specific `kzalloc` function is quite interesting. It indicates a zeroed memory allocation. Now, 'obj' usually refers to a data structure of some kind. My initial instinct is to use `grep` to trace the use of this function within the code base. I'm going to quickly search for occurrences of `kzalloc_obj`. This should give me a starting point and hopefully reveal the purpose and context for which the allocation is being used. From there, I'll be able to quickly determine if there are any potential memory related bugs, or if it is being used safely within the system. Let's see what that search turns up.
|
| 45/2 |
2026/06/29 00:39 |
tool |
grepper |
0m
Args: map[Expression:kzalloc_obj]
Results: map[Output:
Full output is too long, showing 500 out of 79118 lines.
Use more precise expression if possible.
Documentation/core-api/list.rst=103=list:
--
Documentation/core-api/list.rst-114-
Documentation/core-api/list.rst:115: grock = kzalloc_obj(*grock);
Documentation/core-api/list.rst-116- if (!grock)
--
Documentation/core-api/list.rst-125-
Documentation/core-api/list.rst:126: dimitri = kzalloc_obj(*dimitri);
Documentation/core-api/list.rst-127- if (!dimitri)
--
Documentation/driver-api/mailbox.rst=45=a message and a callback function to the API and return immediately).
--
Documentation/driver-api/mailbox.rst-89-
Documentation/driver-api/mailbox.rst:90: dc_sync = kzalloc_obj(*dc_sync);
Documentation/driver-api/mailbox.rst:91: dc_async = kzalloc_obj(*dc_async);
Documentation/driver-api/mailbox.rst-92-
--
Documentation/driver-api/media/v4l2-fh.rst=26=Example:
--
Documentation/driver-api/media/v4l2-fh.rst-44-
Documentation/driver-api/media/v4l2-fh.rst:45: my_fh = kzalloc_obj(*my_fh);
Documentation/driver-api/media/v4l2-fh.rst-46-
--
Documentation/process/coding-style.rst=938=The kernel provides the following general purpose memory allocators:
Documentation/process/coding-style.rst:939:kmalloc(), kzalloc(), kmalloc_objs(), kzalloc_objs(), vmalloc(), and
Documentation/process/coding-style.rst-940-vzalloc(). Please refer to the API documentation for further information
--
Documentation/process/coding-style.rst=964=The preferred form for allocating a zeroed array is the following:
--
Documentation/process/coding-style.rst-967-
Documentation/process/coding-style.rst:968: p = kzalloc_objs(*p, n, ...);
Documentation/process/coding-style.rst-969-
--
Documentation/process/deprecated.rst=398=become, respectively::
--
Documentation/process/deprecated.rst-400- ptr = kmalloc_obj(*ptr [, gfp] );
Documentation/process/deprecated.rst:401: ptr = kzalloc_obj(*ptr [, gfp] );
Documentation/process/deprecated.rst-402- ptr = kmalloc_objs(*ptr, count [, gfp] );
Documentation/process/deprecated.rst:403: ptr = kzalloc_objs(*ptr, count [, gfp] );
Documentation/process/deprecated.rst-404- ptr = kmalloc_flex(*ptr, flex_member, count [, gfp] );
--
Documentation/sound/kernel-api/writing-an-alsa-driver.rst=208=to details explained in the following section.
--
Documentation/sound/kernel-api/writing-an-alsa-driver.rst-268- /* allocate a chip-specific data with zero filled */
Documentation/sound/kernel-api/writing-an-alsa-driver.rst:269: chip = kzalloc_obj(*chip);
Documentation/sound/kernel-api/writing-an-alsa-driver.rst-270- if (chip == NULL)
--
Documentation/sound/kernel-api/writing-an-alsa-driver.rst=623=After allocating a card instance via :c:func:`snd_card_new()`
--
Documentation/sound/kernel-api/writing-an-alsa-driver.rst-630- .....
Documentation/sound/kernel-api/writing-an-alsa-driver.rst:631: chip = kzalloc_obj(*chip);
Documentation/sound/kernel-api/writing-an-alsa-driver.rst-632-
--
Documentation/sound/kernel-api/writing-an-alsa-driver.rst=698=destructor and PCI entries. Example code is shown first, below::
--
Documentation/sound/kernel-api/writing-an-alsa-driver.rst-749-
Documentation/sound/kernel-api/writing-an-alsa-driver.rst:750: chip = kzalloc_obj(*chip);
Documentation/sound/kernel-api/writing-an-alsa-driver.rst-751- if (chip == NULL) {
--
Documentation/sound/kernel-api/writing-an-alsa-driver.rst=3823=chip data individually::
--
Documentation/sound/kernel-api/writing-an-alsa-driver.rst-3835- ....
Documentation/sound/kernel-api/writing-an-alsa-driver.rst:3836: chip = kzalloc_obj(*chip);
Documentation/sound/kernel-api/writing-an-alsa-driver.rst-3837- ....
--
Documentation/translations/zh_CN/video4linux/v4l2-framework.txt=794=int my_open(struct file *file)
--
Documentation/translations/zh_CN/video4linux/v4l2-framework.txt-801-
Documentation/translations/zh_CN/video4linux/v4l2-framework.txt:802: my_fh = kzalloc_obj(*my_fh);
Documentation/translations/zh_CN/video4linux/v4l2-framework.txt-803-
--
arch/alpha/kernel/module.c=64=module_frob_arch_sections(Elf64_Ehdr *hdr, Elf64_Shdr *sechdrs,
--
arch/alpha/kernel/module.c-95- nsyms = symtab->sh_size / sizeof(Elf64_Sym);
arch/alpha/kernel/module.c:96: chains = kzalloc_objs(struct got_entry, nsyms);
arch/alpha/kernel/module.c-97- if (!chains) {
--
arch/alpha/kernel/setup.c=390=register_cpus(void)
--
arch/alpha/kernel/setup.c-394- for_each_possible_cpu(i) {
arch/alpha/kernel/setup.c:395: struct cpu *p = kzalloc_obj(*p);
arch/alpha/kernel/setup.c-396- if (!p)
--
arch/arc/net/bpf_jit_core.c=1120=static int jit_prepare_final_mem_alloc(struct jit_context *ctx)
--
arch/arc/net/bpf_jit_core.c-1131- if (ctx->need_extra_pass) {
arch/arc/net/bpf_jit_core.c:1132: ctx->jit_data = kzalloc_obj(*ctx->jit_data);
arch/arc/net/bpf_jit_core.c-1133- if (!ctx->jit_data)
--
arch/arm/common/locomo.c=220=locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info)
--
arch/arm/common/locomo.c-224-
arch/arm/common/locomo.c:225: dev = kzalloc_obj(struct locomo_dev);
arch/arm/common/locomo.c-226- if (!dev) {
--
arch/arm/common/locomo.c=356=__locomo_probe(struct device *me, struct resource *mem, int irq)
--
arch/arm/common/locomo.c-362-
arch/arm/common/locomo.c:363: lchip = kzalloc_obj(struct locomo);
arch/arm/common/locomo.c-364- if (!lchip)
--
arch/arm/common/sa1111.c=733=sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
--
arch/arm/common/sa1111.c-739-
arch/arm/common/sa1111.c:740: dev = kzalloc_obj(struct sa1111_dev);
arch/arm/common/sa1111.c-741- if (!dev) {
--
arch/arm/common/scoop.c=178=static int scoop_probe(struct platform_device *pdev)
--
arch/arm/common/scoop.c-187-
arch/arm/common/scoop.c:188: devptr = kzalloc_obj(struct scoop_dev);
arch/arm/common/scoop.c-189- if (!devptr)
--
arch/arm/kernel/smp.c=108=static int secondary_biglittle_prepare(unsigned int cpu)
--
arch/arm/kernel/smp.c-110- if (!cpu_vtable[cpu])
arch/arm/kernel/smp.c:111: cpu_vtable[cpu] = kzalloc_obj(*cpu_vtable[cpu]);
arch/arm/kernel/smp.c-112-
--
arch/arm/kernel/vdso.c=169=static int __init vdso_init(void)
--
arch/arm/kernel/vdso.c-181- /* Allocate the VDSO text pagelist */
arch/arm/kernel/vdso.c:182: vdso_text_pagelist = kzalloc_objs(struct page *, text_pages);
arch/arm/kernel/vdso.c-183- if (vdso_text_pagelist == NULL)
--
arch/arm/mach-footbridge/dc21285.c=261=int __init dc21285_setup(int nr, struct pci_sys_data *sys)
--
arch/arm/mach-footbridge/dc21285.c-264-
arch/arm/mach-footbridge/dc21285.c:265: res = kzalloc_objs(struct resource, 2);
arch/arm/mach-footbridge/dc21285.c-266- if (!res) {
--
arch/arm/mach-footbridge/ebsa285.c=69=static int __init ebsa285_leds_init(void)
--
arch/arm/mach-footbridge/ebsa285.c-86-
arch/arm/mach-footbridge/ebsa285.c:87: led = kzalloc_obj(*led);
arch/arm/mach-footbridge/ebsa285.c-88- if (!led)
--
arch/arm/mach-footbridge/netwinder-hw.c=720=static int __init netwinder_leds_init(void)
--
arch/arm/mach-footbridge/netwinder-hw.c-729-
arch/arm/mach-footbridge/netwinder-hw.c:730: led = kzalloc_obj(*led);
arch/arm/mach-footbridge/netwinder-hw.c-731- if (!led)
--
arch/arm/mach-imx/mmdc.c=473=static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_base,
--
arch/arm/mach-imx/mmdc.c-479-
arch/arm/mach-imx/mmdc.c:480: pmu_mmdc = kzalloc_obj(*pmu_mmdc);
arch/arm/mach-imx/mmdc.c-481- if (!pmu_mmdc) {
--
arch/arm/mach-mvebu/board-v7.c=114=static void __init i2c_quirk(void)
--
arch/arm/mach-mvebu/board-v7.c-129-
arch/arm/mach-mvebu/board-v7.c:130: new_compat = kzalloc_obj(*new_compat);
arch/arm/mach-mvebu/board-v7.c-131-
--
arch/arm/mach-mvebu/coherency.c=163=static void __init armada_375_380_coherency_init(struct device_node *np)
--
arch/arm/mach-mvebu/coherency.c-187-
arch/arm/mach-mvebu/coherency.c:188: p = kzalloc_obj(*p);
arch/arm/mach-mvebu/coherency.c-189- p->name = kstrdup("arm,io-coherent", GFP_KERNEL);
--
arch/arm/mach-mvebu/mvebu-soc-id.c=148=static int __init mvebu_soc_device(void)
--
arch/arm/mach-mvebu/mvebu-soc-id.c-156-
arch/arm/mach-mvebu/mvebu-soc-id.c:157: soc_dev_attr = kzalloc_obj(*soc_dev_attr);
arch/arm/mach-mvebu/mvebu-soc-id.c-158- if (!soc_dev_attr)
--
arch/arm/mach-mxs/mach-mxs.c=380=static void __init mxs_machine_init(void)
--
arch/arm/mach-mxs/mach-mxs.c-389-
arch/arm/mach-mxs/mach-mxs.c:390: soc_dev_attr = kzalloc_obj(*soc_dev_attr);
arch/arm/mach-mxs/mach-mxs.c-391- if (!soc_dev_attr)
--
arch/arm/mach-omap1/dma.c=294=static int __init omap1_system_dma_init(void)
--
arch/arm/mach-omap1/dma.c-321-
arch/arm/mach-omap1/dma.c:322: d = kzalloc_obj(*d);
arch/arm/mach-omap1/dma.c-323- if (!d) {
--
arch/arm/mach-omap1/mcbsp.c=292=static void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
--
arch/arm/mach-omap1/mcbsp.c-296-
arch/arm/mach-omap1/mcbsp.c:297: omap_mcbsp_devices = kzalloc_objs(struct platform_device *, size);
arch/arm/mach-omap1/mcbsp.c-298- if (!omap_mcbsp_devices) {
--
arch/arm/mach-omap1/timer.c=51=static int __init omap1_dm_timer_init(void)
--
arch/arm/mach-omap1/timer.c-127-
arch/arm/mach-omap1/timer.c:128: pdata = kzalloc_obj(*pdata);
arch/arm/mach-omap1/timer.c-129- if (!pdata) {
--
arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c=230=void omap2xxx_clkt_vps_init(void)
--
arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c-239-
arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c:240: hw = kzalloc_obj(*hw);
arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c-241- if (!hw)
--
arch/arm/mach-omap2/id.c=786=void __init omap_soc_device_init(void)
--
arch/arm/mach-omap2/id.c-790-
arch/arm/mach-omap2/id.c:791: soc_dev_attr = kzalloc_obj(*soc_dev_attr);
arch/arm/mach-omap2/id.c-792- if (!soc_dev_attr)
--
arch/arm/mach-omap2/omap_device.c=131=static int omap_device_build_from_dt(struct platform_device *pdev)
--
arch/arm/mach-omap2/omap_device.c-158-
arch/arm/mach-omap2/omap_device.c:159: hwmods = kzalloc_objs(struct omap_hwmod *, oh_cnt);
arch/arm/mach-omap2/omap_device.c-160- if (!hwmods) {
--
arch/arm/mach-omap2/omap_hwmod.c=3389=static int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh,
--
arch/arm/mach-omap2/omap_hwmod.c-3402-
arch/arm/mach-omap2/omap_hwmod.c:3403: sysc = kzalloc_obj(*sysc);
arch/arm/mach-omap2/omap_hwmod.c-3404- if (!sysc)
--
arch/arm/mach-omap2/omap_hwmod.c-3432- if (list_empty(&oh->slave_ports)) {
arch/arm/mach-omap2/omap_hwmod.c:3433: oi = kzalloc_obj(*oi);
arch/arm/mach-omap2/omap_hwmod.c-3434- if (!oi)
--
arch/arm/mach-omap2/omap_hwmod.c=3521=int omap_hwmod_init_module(struct device *dev,
--
arch/arm/mach-omap2/omap_hwmod.c-3535- if (!oh) {
arch/arm/mach-omap2/omap_hwmod.c:3536: oh = kzalloc_obj(*oh);
arch/arm/mach-omap2/omap_hwmod.c-3537- if (!oh)
--
arch/arm/mach-omap2/omap_hwmod.c-3546-
arch/arm/mach-omap2/omap_hwmod.c:3547: oh->class = kzalloc_obj(*oh->class);
arch/arm/mach-omap2/omap_hwmod.c-3548- if (!oh->class) {
--
arch/arm/mach-omap2/pm33xx-core.c=379=static int __init amx3_idle_init(struct device_node *cpu_node, int cpu)
--
arch/arm/mach-omap2/pm33xx-core.c-412-
arch/arm/mach-omap2/pm33xx-core.c:413: idle_states = kzalloc_objs(*idle_states, state_count);
arch/arm/mach-omap2/pm33xx-core.c-414- if (!idle_states)
--
arch/arm/mach-omap2/sr_device.c=30=static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
--
arch/arm/mach-omap2/sr_device.c-41-
arch/arm/mach-omap2/sr_device.c:42: nvalue_table = kzalloc_objs(*nvalue_table, count);
arch/arm/mach-omap2/sr_device.c-43- if (!nvalue_table)
--
arch/arm/mach-orion5x/pci.c=139=static int __init pcie_setup(struct pci_sys_data *sys)
--
arch/arm/mach-orion5x/pci.c-171- */
arch/arm/mach-orion5x/pci.c:172: res = kzalloc_obj(struct resource);
arch/arm/mach-orion5x/pci.c-173- if (!res)
--
arch/arm/mach-orion5x/pci.c=466=static int __init pci_setup(struct pci_sys_data *sys)
--
arch/arm/mach-orion5x/pci.c-492- */
arch/arm/mach-orion5x/pci.c:493: res = kzalloc_obj(struct resource);
arch/arm/mach-orion5x/pci.c-494- if (!res)
--
arch/arm/mach-rpc/ecard.c=689=static struct expansion_card *__init ecard_alloc_card(int type, int slot)
--
arch/arm/mach-rpc/ecard.c-694-
arch/arm/mach-rpc/ecard.c:695: ec = kzalloc_obj(ecard_t);
arch/arm/mach-rpc/ecard.c-696- if (!ec) {
--
arch/arm/mach-sa1100/clock.c=93=int __init sa11xx_clk_init(void)
--
arch/arm/mach-sa1100/clock.c-109-
arch/arm/mach-sa1100/clock.c:110: hw = kzalloc_obj(*hw);
arch/arm/mach-sa1100/clock.c-111- if (!hw)
--
arch/arm/mach-sa1100/clock.c-131-
arch/arm/mach-sa1100/clock.c:132: hw = kzalloc_obj(*hw);
arch/arm/mach-sa1100/clock.c-133- if (!hw)
--
arch/arm/mach-sa1100/generic.c=317=int __init sa11x0_register_fixed_regulator(int n,
--
arch/arm/mach-sa1100/generic.c-323-
arch/arm/mach-sa1100/generic.c:324: cfg->init_data = id = kzalloc_obj(*cfg->init_data);
arch/arm/mach-sa1100/generic.c-325- if (!cfg->init_data)
--
arch/arm/mach-sa1100/neponset.c=225=static int neponset_probe(struct platform_device *dev)
--
arch/arm/mach-sa1100/neponset.c-278-
arch/arm/mach-sa1100/neponset.c:279: d = kzalloc_obj(*d);
arch/arm/mach-sa1100/neponset.c-280- if (!d) {
--
arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c=141=static int __init rcar_gen2_regulator_quirk(void)
--
arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c-166-
arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c:167: quirk = kzalloc_obj(*quirk);
arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c-168- if (!quirk) {
--
arch/arm/mach-versatile/spc.c=393=static int ve_spc_populate_opps(uint32_t cluster)
--
arch/arm/mach-versatile/spc.c-397-
arch/arm/mach-versatile/spc.c:398: opps = kzalloc_objs(*opps, MAX_OPPS);
arch/arm/mach-versatile/spc.c-399- if (!opps)
--
arch/arm/mach-versatile/spc.c=442=int __init ve_spc_init(void __iomem *baseaddr, u32 a15_clusid, int irq)
--
arch/arm/mach-versatile/spc.c-444- int ret;
arch/arm/mach-versatile/spc.c:445: info = kzalloc_obj(*info);
arch/arm/mach-versatile/spc.c-446- if (!info)
--
arch/arm/mach-versatile/spc.c=523=static struct clk *ve_spc_clk_register(struct device *cpu_dev)
--
arch/arm/mach-versatile/spc.c-527-
arch/arm/mach-versatile/spc.c:528: spc = kzalloc_obj(*spc);
arch/arm/mach-versatile/spc.c-529- if (!spc)
--
arch/arm/mach-versatile/versatile.c=123=static void __init versatile_dt_pci_init(void)
--
arch/arm/mach-versatile/versatile.c-144-
arch/arm/mach-versatile/versatile.c:145: newprop = kzalloc_obj(*newprop);
arch/arm/mach-versatile/versatile.c-146- if (!newprop)
--
arch/arm/mach-zynq/common.c=105=static void __init zynq_init_machine(void)
--
arch/arm/mach-zynq/common.c-110-
arch/arm/mach-zynq/common.c:111: soc_dev_attr = kzalloc_obj(*soc_dev_attr);
arch/arm/mach-zynq/common.c-112- if (!soc_dev_attr)
--
arch/arm/mm/cache-l2x0-pmu.c=503=static __init int l2x0_pmu_init(void)
--
arch/arm/mm/cache-l2x0-pmu.c-509-
arch/arm/mm/cache-l2x0-pmu.c:510: l2x0_pmu = kzalloc_obj(*l2x0_pmu);
arch/arm/mm/cache-l2x0-pmu.c-511- if (!l2x0_pmu) {
--
arch/arm/mm/cache-uniphier.c=315=static int __init __uniphier_cache_init(struct device_node *np,
--
arch/arm/mm/cache-uniphier.c-344-
arch/arm/mm/cache-uniphier.c:345: data = kzalloc_obj(*data);
arch/arm/mm/cache-uniphier.c-346- if (!data)
--
arch/arm/mm/dma-mapping.c=533=static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
--
arch/arm/mm/dma-mapping.c-560-
arch/arm/mm/dma-mapping.c:561: buf = kzalloc_obj(*buf,
arch/arm/mm/dma-mapping.c-562- gfp & ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM));
--
arch/arm/mm/dma-mapping.c=1487=arm_iommu_create_mapping(struct device *dev, dma_addr_t base, u64 size)
--
arch/arm/mm/dma-mapping.c-1506-
arch/arm/mm/dma-mapping.c:1507: mapping = kzalloc_obj(struct dma_iommu_mapping);
arch/arm/mm/dma-mapping.c-1508- if (!mapping)
--
arch/arm/xen/enlighten.c=316=int __init arch_xen_unpopulated_init(struct resource **res)
--
arch/arm/xen/enlighten.c-343-
arch/arm/xen/enlighten.c:344: regs = kzalloc_objs(*regs, nr_reg);
arch/arm/xen/enlighten.c-345- if (!regs) {
--
arch/arm/xen/enlighten.c-387-
arch/arm/xen/enlighten.c:388: tmp_res = kzalloc_obj(*tmp_res);
arch/arm/xen/enlighten.c-389- if (!tmp_res) {
--
arch/arm/xen/p2m.c=150=bool __set_phys_to_machine_multi(unsigned long pfn,
--
arch/arm/xen/p2m.c-178-
arch/arm/xen/p2m.c:179: p2m_entry = kzalloc_obj(*p2m_entry, GFP_NOWAIT);
arch/arm/xen/p2m.c-180- if (!p2m_entry)
--
arch/arm64/kernel/vdso.c=68=static int __init __vdso_init(enum vdso_abi abi)
--
arch/arm64/kernel/vdso.c-83-
arch/arm64/kernel/vdso.c:84: vdso_pagelist = kzalloc_objs(struct page *, vdso_info[abi].vdso_pages);
arch/arm64/kernel/vdso.c-85- if (vdso_pagelist == NULL)
--
arch/arm64/kvm/mmu.c=480=static int share_pfn_hyp(u64 pfn)
--
arch/arm64/kvm/mmu.c-492-
arch/arm64/kvm/mmu.c:493: this = kzalloc_obj(*this);
arch/arm64/kvm/mmu.c-494- if (!this) {
--
arch/arm64/kvm/mmu.c=981=int kvm_init_stage2_mmu(struct kvm *kvm, struct kvm_s2_mmu *mmu, unsigned long type)
--
arch/arm64/kvm/mmu.c-1007-
arch/arm64/kvm/mmu.c:1008: pgt = kzalloc_obj(*pgt, GFP_KERNEL_ACCOUNT);
arch/arm64/kvm/mmu.c-1009- if (!pgt)
--
arch/arm64/kvm/mmu.c=1180=int topup_hyp_memcache(struct kvm_hyp_memcache *mc, unsigned long min_pages)
--
arch/arm64/kvm/mmu.c-1185- if (!mc->mapping) {
arch/arm64/kvm/mmu.c:1186: mc->mapping = kzalloc_obj(struct pkvm_mapping,
arch/arm64/kvm/mmu.c-1187- GFP_KERNEL_ACCOUNT);
--
arch/arm64/kvm/mmu.c=2510=int __init kvm_mmu_init(u32 hyp_va_bits)
--
arch/arm64/kvm/mmu.c-2543-
arch/arm64/kvm/mmu.c:2544: hyp_pgtable = kzalloc_obj(*hyp_pgtable);
arch/arm64/kvm/mmu.c-2545- if (!hyp_pgtable) {
--
arch/arm64/kvm/nested.c=1328=int kvm_vcpu_allocate_vncr_tlb(struct kvm_vcpu *vcpu)
--
arch/arm64/kvm/nested.c-1333- if (!vcpu->arch.vncr_tlb) {
arch/arm64/kvm/nested.c:1334: struct vncr_tlb *vt = kzalloc_obj(*vcpu->arch.vncr_tlb,
arch/arm64/kvm/nested.c-1335- GFP_KERNEL_ACCOUNT);
--
arch/arm64/kvm/nested.c=1793=int kvm_init_nv_sysregs(struct kvm_vcpu *vcpu)
--
arch/arm64/kvm/nested.c-1802-
arch/arm64/kvm/nested.c:1803: kvm->arch.sysreg_masks = kzalloc_obj(*(kvm->arch.sysreg_masks),
arch/arm64/kvm/nested.c-1804- GFP_KERNEL_ACCOUNT);
--
arch/arm64/kvm/ptdump.c=116=static struct kvm_ptdump_guest_state *kvm_ptdump_parser_create(struct kvm_s2_mmu *mmu)
--
arch/arm64/kvm/ptdump.c-121-
arch/arm64/kvm/ptdump.c:122: st = kzalloc_obj(struct kvm_ptdump_guest_state, GFP_KERNEL_ACCOUNT);
arch/arm64/kvm/ptdump.c-123- if (!st)
--
arch/arm64/kvm/vgic/vgic-init.c=207=static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)
--
arch/arm64/kvm/vgic/vgic-init.c-213- dist->active_spis = (atomic_t)ATOMIC_INIT(0);
arch/arm64/kvm/vgic/vgic-init.c:214: dist->spis = kzalloc_objs(struct vgic_irq, nr_spis, GFP_KERNEL_ACCOUNT);
arch/arm64/kvm/vgic/vgic-init.c-215- if (!dist->spis)
--
arch/arm64/kvm/vgic/vgic-init.c=316=static int vgic_allocate_private_irqs_locked(struct kvm_vcpu *vcpu, u32 type)
--
arch/arm64/kvm/vgic/vgic-init.c-331-
arch/arm64/kvm/vgic/vgic-init.c:332: vgic_cpu->private_irqs = kzalloc_objs(struct vgic_irq,
arch/arm64/kvm/vgic/vgic-init.c-333- num_private_irqs,
--
arch/arm64/kvm/vgic/vgic-irqfd.c=142=int kvm_vgic_setup_default_irq_routing(struct kvm *kvm)
--
arch/arm64/kvm/vgic/vgic-irqfd.c-148-
arch/arm64/kvm/vgic/vgic-irqfd.c:149: entries = kzalloc_objs(*entries, nr, GFP_KERNEL_ACCOUNT);
arch/arm64/kvm/vgic/vgic-irqfd.c-150- if (!entries)
--
arch/arm64/kvm/vgic/vgic-its.c=76=static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
--
arch/arm64/kvm/vgic/vgic-its.c-87-
arch/arm64/kvm/vgic/vgic-its.c:88: irq = kzalloc_obj(struct vgic_irq, GFP_KERNEL_ACCOUNT);
arch/arm64/kvm/vgic/vgic-its.c-89- if (!irq)
--
arch/arm64/kvm/vgic/vgic-its.c=960=static int vgic_its_alloc_collection(struct vgic_its *its,
--
arch/arm64/kvm/vgic/vgic-its.c-965-
arch/arm64/kvm/vgic/vgic-its.c:966: collection = kzalloc_obj(*collection, GFP_KERNEL_ACCOUNT);
arch/arm64/kvm/vgic/vgic-its.c-967- if (!collection)
--
arch/arm64/kvm/vgic/vgic-its.c=1004=static struct its_ite *vgic_its_alloc_ite(struct its_device *device,
--
arch/arm64/kvm/vgic/vgic-its.c-1009-
arch/arm64/kvm/vgic/vgic-its.c:1010: ite = kzalloc_obj(*ite, GFP_KERNEL_ACCOUNT);
arch/arm64/kvm/vgic/vgic-its.c-1011- if (!ite)
--
arch/arm64/kvm/vgic/vgic-its.c=1131=static struct its_device *vgic_its_alloc_device(struct vgic_its *its,
--
arch/arm64/kvm/vgic/vgic-its.c-1136-
arch/arm64/kvm/vgic/vgic-its.c:1137: device = kzalloc_obj(*device, GFP_KERNEL_ACCOUNT);
arch/arm64/kvm/vgic/vgic-its.c-1138- if (!device)
--
arch/arm64/kvm/vgic/vgic-its.c=1844=static int vgic_its_create(struct kvm_device *dev, u32 type)
--
arch/arm64/kvm/vgic/vgic-its.c-1851-
arch/arm64/kvm/vgic/vgic-its.c:1852: its = kzalloc_obj(struct vgic_its, GFP_KERNEL_ACCOUNT);
arch/arm64/kvm/vgic/vgic-its.c-1853- if (!its)
--
arch/arm64/kvm/vgic/vgic-mmio-v3.c=886=static int vgic_v3_alloc_redist_region(struct kvm *kvm, uint32_t index,
--
arch/arm64/kvm/vgic/vgic-mmio-v3.c-931-
arch/arm64/kvm/vgic/vgic-mmio-v3.c:932: rdreg = kzalloc_obj(*rdreg, GFP_KERNEL_ACCOUNT);
arch/arm64/kvm/vgic/vgic-mmio-v3.c-933- if (!rdreg)
--
arch/arm64/kvm/vgic/vgic-v4.c=242=int vgic_v4_init(struct kvm *kvm)
--
arch/arm64/kvm/vgic/vgic-v4.c-258-
arch/arm64/kvm/vgic/vgic-v4.c:259: dist->its_vm.vpes = kzalloc_objs(*dist->its_vm.vpes, nr_vcpus,
arch/arm64/kvm/vgic/vgic-v4.c-260- GFP_KERNEL_ACCOUNT);
--
arch/arm64/net/bpf_jit_comp.c=2080=struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_prog *prog)
--
arch/arm64/net/bpf_jit_comp.c-2101- if (!jit_data) {
arch/arm64/net/bpf_jit_comp.c:2102: jit_data = kzalloc_obj(*jit_data);
arch/arm64/net/bpf_jit_comp.c-2103- if (!jit_data)
--
arch/csky/kernel/vdso.c=17=static int __init vdso_init(void)
--
arch/csky/kernel/vdso.c-22- vdso_pagelist =
arch/csky/kernel/vdso.c:23: kzalloc_objs(struct page *, vdso_pages);
arch/csky/kernel/vdso.c-24- if (unlikely(vdso_pagelist == NULL)) {
--
arch/loongarch/kernel/setup.c=466=static int __init add_legacy_isa_io(struct fwnode_handle *fwnode,
--
arch/loongarch/kernel/setup.c-472-
arch/loongarch/kernel/setup.c:473: range = kzalloc_obj(*range, GFP_ATOMIC);
arch/loongarch/kernel/setup.c-474- if (!range)
--
arch/loongarch/kernel/vdso.c=45=static int __init init_vdso(void)
--
arch/loongarch/kernel/vdso.c-55- vdso_info.code_mapping.pages =
arch/loongarch/kernel/vdso.c:56: kzalloc_objs(struct page *, vdso_info.size / PAGE_SIZE);
arch/loongarch/kernel/vdso.c-57-
--
arch/loongarch/kvm/intc/eiointc.c=614=static int kvm_eiointc_create(struct kvm_device *dev, u32 type)
--
arch/loongarch/kvm/intc/eiointc.c-624-
arch/loongarch/kvm/intc/eiointc.c:625: s = kzalloc_obj(struct loongarch_eiointc);
arch/loongarch/kvm/intc/eiointc.c-626- if (!s)
--
arch/loongarch/kvm/intc/ipi.c=394=static int kvm_ipi_create(struct kvm_device *dev, u32 type)
--
arch/loongarch/kvm/intc/ipi.c-411-
arch/loongarch/kvm/intc/ipi.c:412: s = kzalloc_obj(struct loongarch_ipi);
arch/loongarch/kvm/intc/ipi.c-413- if (!s)
]
|
| 46/2 |
2026/06/29 00:39 |
llm |
expert |
0m
Model:
Tokens:
input: 57173
output: 66
thoughts: 1085
Thoughts: **My Analysis of the `ueagle-atm` USB Driver Vulnerability**
Okay, let's break this down. First, I see that `kzalloc_obj(*fw_done)` is essentially allocating memory the size of the object pointed to by `fw_done`, which is likely a 32-byte allocation. The call to `usbatm_usb_disconnect` accesses `instance->serialize` at offset 136, which suggests an out-of-bounds read. This definitely points to an exploitable bug, potentially leading to a denial of service. Since it involves a USB device, the trigger is likely a physical peripheral.
From the analysis, I've confirmed that this is, indeed, exploitable, and will result in Denial of Service. It's not remotely triggerable, requires no privileges, and doesn't involve user namespaces. It can be triggered by a VM host if in a confidential computing context. The VM guest can't directly trigger it because standard KVM guests don't expose host USB controllers and allow for arbitrary device definitions. Similarly, it's not a network or remote exploit, nor does it require a malicious filesystem.
Let's quickly recap: Exploitable? YES. Denial of Service? YES. Unprivileged? NO. User Namespace? NO. VMGuestTrigger? NO. VMHostTrigger? YES. Network Trigger? NO. Remote Trigger? NO. Peripheral Trigger? YES. Filesystem Trigger? NO.
Now, a critical question: is there any way for an unprivileged user to trigger this? I considered `dummy_hcd`, `raw-gadget`, and USB/IP, but each requires elevated privileges β `CAP_SYS_ADMIN` for the first two and `CAP_NET_ADMIN` to configure USB/IP and attach devices. The `usbip` tool needs root to write to `/sys/devices/platform/vhci_hcd.0/attach`, which is root-owned. So unprivileged users are out.
Now, about `usbatm_usb_disconnect`: can it be skipped? If `ifnum == 0` and `bNumInterfaces != 1`, it's called. If `ifnum == 1` and `bNumInterfaces != 1`, it's *not* called. Both scenarios seem problematic! The OOB access seems related to one scenario and the other points to a Use-After-Free (UAF). The UAF is definitely concerning because a UAF is trivially exploitable.
**Conclusion:**
This is a Use-After-Free vulnerability within the `ueagle-atm` USB driver. Here's what's happening: when a pre-firmware device is probed, `uea_probe` allocates a `struct completion` and stores it in the interface data. It then kicks off an asynchronous firmware load using `request_firmware_nowait`. The issue arises when the device has multiple interfaces (`bNumInterfaces != 1`). The disconnect handler, `uea_disconnect`, *doesn't* wait for the firmware load to complete for interfaces other than interface 0. So, for interfaces greater than 0, `uea_disconnect` simply returns, allowing the USB core to free the `struct usb_interface`.
When the asynchronous firmware load eventually runs, it attempts to access the freed `struct usb_interface` to get the `struct usb_device`, leading to a Use-After-Free. The attacker gains control of this freed memory and, therefore, can overwrite the `struct usb_device` pointer, which is later used in `usb_control_msg`. This control allows the attacker to hijack control flow (e.g., via `hcd->driver->urb_enqueue`) and achieve arbitrary code execution. The bug can be triggered by plugging in a malicious USB device or, potentially, by a malicious hypervisor in a Confidential Computing environment hotplugging a virtual USB device. It's not remotely exploitable or usable by unprivileged users.
|
| 47/2 |
2026/06/29 00:40 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:true]
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:true]
|
| 48/2 |
2026/06/29 00:40 |
llm |
expert |
0m
Model:
Tokens:
input: 59236
output: 953
thoughts: 13
Thoughts: Okay, here's the summary, formatted as you requested:
**Final Reasoning: Now We Put It All Together**
Alright, the data is in, the calculations are complete. No more adjustments needed β the outcome is fixed. Now comes the part I always enjoy: synthesizing everything into a coherent, defensible narrative. It's time to build the case, to lay out the final reasoning that connects the dots and justifies the conclusion. This isn't just a regurgitation of the data; itβs about drawing the essential linkages, weighing the nuances, and presenting a compelling argument that demonstrates a complete understanding of the topic at hand. It's about showing *why* the results are what they are, not just *that* they are. This is where the real expertise comes through β connecting evidence to the established body of knowledge, anticipating potential counterarguments, and ensuring the final analysis is both rigorous and easily understood. Let's get to work.
|
| 49/1 |
2026/06/29 00:40 |
action |
format-explanation |
0m
Results: map[Explanation:**Analysis of the Bug:**
The bug is a Use-After-Free (UAF) in the `ueagle-atm` USB driver, specifically
in the `uea_upload_pre_firmware` function.
When a pre-firmware USB device is plugged in, the `uea_probe` function is
called. It allocates a `struct completion` (`fw_done`), sets it as the interface
data (`usb_set_intfdata(intf, fw_done)`), and schedules an asynchronous firmware
load via `request_firmware_nowait`. The firmware load work item eventually
executes `uea_upload_pre_firmware`, which expects the `struct usb_interface`
pointer as its context.
If an attacker plugs in a malicious USB device that matches the pre-firmware
device ID (e.g., `VID=0x1110`, `PID=0x9010`) but presents multiple interfaces
(`bNumInterfaces > 1`), `uea_probe` will be called for each interface.
When the device is subsequently disconnected, `uea_disconnect` is invoked. The
disconnect handler contains the following logic:
```c
if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
mutex_lock(&uea_mutex);
usbatm_usb_disconnect(intf);
mutex_unlock(&uea_mutex);
} else if (usb->config->desc.bNumInterfaces == 1) {
struct completion *fw_done = usb_get_intfdata(intf);
wait_for_completion(fw_done);
kfree(fw_done);
}
```
If `bNumInterfaces != 1` and `ifnum != 0` (e.g., for the second interface),
`uea_disconnect` falls through and does **nothing**. It does not wait for the
asynchronous firmware load to complete. Consequently, the USB core frees the
`struct usb_interface` object.
When the scheduled `request_firmware_work_func` runs, it calls
`uea_upload_pre_firmware`, which accesses the now-freed `intf` to retrieve the
`struct usb_device` pointer (`interface_to_usbdev(intf)` accesses
`intf->dev.parent`). This results in a Use-After-Free.
*(Note: For `ifnum == 0`, `usbatm_usb_disconnect` is called, which incorrectly
casts the 32-byte `fw_done` completion object to a large `struct usbatm_data`
and accesses out-of-bounds memory at offset 136, leading to another severe
memory corruption / DoS).*
**Exploitability:**
The UAF is highly exploitable. The `struct usb_interface` is allocated in the
`kmalloc-2k` cache. An attacker can spray this cache to overwrite the freed
interface and control the `intf->dev.parent` pointer, effectively forging a fake
`struct usb_device`.
The `uea_upload_pre_firmware` function then passes this controlled `usb_device`
to `uea_send_modem_cmd`, which calls `usb_control_msg`. The USB core will use
the fake `usb_device` to submit an URB (`usb_submit_urb` -> `usb_hcd_submit_urb`
-> `hcd->driver->urb_enqueue`). By crafting the fake `usb_device` and its
associated `usb_bus` and `usb_hcd` structures, the attacker can hijack the
`urb_enqueue` function pointer, achieving arbitrary kernel code execution and
privilege escalation.
**Trigger Vectors:**
* **Peripheral Trigger:** The bug can be triggered by physically plugging a
malicious USB device into the system.
* **VM Host Trigger (Confidential Computing):** A malicious hypervisor can
emulate and hotplug this crafted USB device into a Confidential VM (e.g., AMD
SEV, Intel TDX) to compromise the guest kernel.
* **Unprivileged / Remote:** The bug cannot be triggered remotely or by
unprivileged users, as emulating USB devices (e.g., via Dummy HCD or Raw Gadget)
or attaching USB/IP devices requires root privileges (`CAP_SYS_ADMIN` or
`CAP_NET_ADMIN` + sysfs write access).]
|