| 0/0 |
2026/05/26 11:40 |
flow |
assessment-security |
36m
Results: map[DenialOfService:false Explanation:Based on the analysis of the bug report and the kernel source code, here is the
assessment of the vulnerability:
**Root Cause Analysis:**
The bug is caused by a typo in `drivers/media/rc/igorplugusb.c` within the
`igorplugusb_probe` function. When initializing the control URB, the driver
passes `(uint8_t *)&ir->request` to `usb_fill_control_urb` instead of `(uint8_t
*)ir->request`.
Because `ir->request` is a dynamically allocated pointer (`struct
usb_ctrlrequest *`), passing its address (`&ir->request`) means the USB core
will read the 8 bytes of the pointer's memory address itself and interpret it as
the USB setup packet, rather than reading the actual `usb_ctrlrequest` structure
it points to.
**Impact and Exploitability:**
When the driver attempts to submit this URB via `usb_submit_urb`, the USB core
validates the setup packet (which is now just the bytes of a kernel pointer):
1. The first byte of the pointer (the least significant byte of the address on
little-endian architectures) is interpreted as `bRequestType`. If this byte
happens to lack the `USB_DIR_IN` bit (`0x80`), `usb_submit_urb` detects a
direction mismatch with the IN pipe and prints the `BOGUS control dir` warning
seen in the crash report.
2. Bytes 6 and 7 of the pointer are interpreted as `wLength`. For a standard
64-bit kernel direct-mapping pointer (e.g., `0xffff8880...` or `0xffff0000...`),
these bytes are always `0xffff`.
3. `usb_submit_urb` strictly checks if `wLength` matches
`urb->transfer_buffer_length` (which is set to `MAX_PACKET`, i.e., 39). Since
`0xffff` (65535) will never match 39, `usb_submit_urb` immediately aborts and
returns `-EBADR` (`-53`).
Because the URB submission is reliably rejected by the USB core before it is
ever queued to the host controller, the kernel pointer is **never leaked** to
the USB device. Furthermore, the bug does not cause any memory corruption,
out-of-bounds accesses, or resource leaks. The `WARNING` generated does not halt
the kernel in production environments (where `panic_on_warn` is disabled). The
only consequence is that the driver fails to initialize the device properly.
**Trigger:**
The bug is triggered by the kernel probing a USB device that matches the
driver's supported Vendor/Product IDs (e.g., `03eb:0002`). This requires
physically plugging in a malicious/malfunctioning USB device or emulating one
(e.g., via the `dummy_hcd` and `raw-gadget` interfaces, which require root
privileges). It cannot be triggered by unprivileged users, network traffic, or
filesystem mounts.
**Conclusion:**
The bug is a functional defect resulting in a harmless warning. It is not a
security vulnerability, is not exploitable, and does not cause a Denial of
Service. Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/05/26 11:40 |
action |
syz-repro-to-c-repro |
0m
Results: map[SimplifiedCRepro:// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/usb/ch9.h>
static unsigned long long procid;
static void sleep_ms(uint64_t ms)
{
usleep(ms * 1000);
}
#define MAX_FDS 30
#define USB_MAX_IFACE_NUM 4
#define USB_MAX_EP_NUM 32
#define USB_MAX_FDS 6
struct usb_endpoint_index {
struct usb_endpoint_descriptor desc;
int handle;
};
struct usb_iface_index {
struct usb_interface_descriptor* iface;
uint8_t bInterfaceNumber;
uint8_t bAlternateSetting;
uint8_t bInterfaceClass;
struct usb_endpoint_index eps[USB_MAX_EP_NUM];
int eps_num;
};
struct usb_device_index {
struct usb_device_descriptor* dev;
struct usb_config_descriptor* config;
uint8_t bDeviceClass;
uint8_t bMaxPower;
int config_length;
struct usb_iface_index ifaces[USB_MAX_IFACE_NUM];
int ifaces_num;
int iface_cur;
};
struct usb_info {
int fd;
struct usb_device_index index;
};
static struct usb_info usb_devices[USB_MAX_FDS];
static struct usb_device_index* lookup_usb_index(int fd)
{
for (int i = 0; i < USB_MAX_FDS; i++) {
if (__atomic_load_n(&usb_devices[i].fd, __ATOMIC_ACQUIRE) == fd)
return &usb_devices[i].index;
}
return NULL;
}
static int usb_devices_num;
static bool parse_usb_descriptor(const char* buffer, size_t length, struct usb_device_index* index)
{
if (length < sizeof(*index->dev) + sizeof(*index->config))
return false;
memset(index, 0, sizeof(*index));
index->dev = (struct usb_device_descriptor*)buffer;
index->config = (struct usb_config_descriptor*)(buffer + sizeof(*index->dev));
index->bDeviceClass = index->dev->bDeviceClass;
index->bMaxPower = index->config->bMaxPower;
index->config_length = length - sizeof(*index->dev);
index->iface_cur = -1;
size_t offset = 0;
while (true) {
if (offset + 1 >= length)
break;
uint8_t desc_length = buffer[offset];
uint8_t desc_type = buffer[offset + 1];
if (desc_length <= 2)
break;
if (offset + desc_length > length)
break;
if (desc_type == USB_DT_INTERFACE && index->ifaces_num < USB_MAX_IFACE_NUM) {
struct usb_interface_descriptor* iface = (struct usb_interface_descriptor*)(buffer + offset);
index->ifaces[index->ifaces_num].iface = iface;
index->ifaces[index->ifaces_num].bInterfaceNumber = iface->bInterfaceNumber;
index->ifaces[index->ifaces_num].bAlternateSetting = iface->bAlternateSetting;
index->ifaces[index->ifaces_num].bInterfaceClass = iface->bInterfaceClass;
index->ifaces_num++;
}
if (desc_type == USB_DT_ENDPOINT && index->ifaces_num > 0) {
struct usb_iface_index* iface = &index->ifaces[index->ifaces_num - 1];
if (iface->eps_num < USB_MAX_EP_NUM) {
memcpy(&iface->eps[iface->eps_num].desc, buffer + offset, sizeof(iface->eps[iface->eps_num].desc));
iface->eps_num++;
}
}
offset += desc_length;
}
return true;
}
static struct usb_device_index* add_usb_index(int fd, const char* dev, size_t dev_len)
{
int i = __atomic_fetch_add(&usb_devices_num, 1, __ATOMIC_RELAXED);
if (i >= USB_MAX_FDS)
return NULL;
if (!parse_usb_descriptor(dev, dev_len, &usb_devices[i].index))
return NULL;
__atomic_store_n(&usb_devices[i].fd, fd, __ATOMIC_RELEASE);
return &usb_devices[i].index;
}
struct vusb_connect_string_descriptor {
uint32_t len;
char* str;
} __attribute__((packed));
struct vusb_connect_descriptors {
uint32_t qual_len;
char* qual;
uint32_t bos_len;
char* bos;
uint32_t strs_len;
struct vusb_connect_string_descriptor strs[0];
} __attribute__((packed));
static const char default_string[] = {
8, USB_DT_STRING,
's', 0, 'y', 0, 'z', 0
};
static const char default_lang_id[] = {
4, USB_DT_STRING,
0x09, 0x04
};
static bool lookup_connect_response_in(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl,
struct usb_qualifier_descriptor* qual,
char** response_data, uint32_t* response_length)
{
struct usb_device_index* index = lookup_usb_index(fd);
uint8_t str_idx;
if (!index)
return false;
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_GET_DESCRIPTOR:
switch (ctrl->wValue >> 8) {
case USB_DT_DEVICE:
*response_data = (char*)index->dev;
*response_length = sizeof(*index->dev);
return true;
case USB_DT_CONFIG:
*response_data = (char*)index->config;
*response_length = index->config_length;
return true;
case USB_DT_STRING:
str_idx = (uint8_t)ctrl->wValue;
if (descs && str_idx < descs->strs_len) {
*response_data = descs->strs[str_idx].str;
*response_length = descs->strs[str_idx].len;
return true;
}
if (str_idx == 0) {
*response_data = (char*)&default_lang_id[0];
*response_length = default_lang_id[0];
return true;
}
*response_data = (char*)&default_string[0];
*response_length = default_string[0];
return true;
case USB_DT_BOS:
*response_data = descs->bos;
*response_length = descs->bos_len;
return true;
case USB_DT_DEVICE_QUALIFIER:
if (!descs->qual) {
qual->bLength = sizeof(*qual);
qual->bDescriptorType = USB_DT_DEVICE_QUALIFIER;
qual->bcdUSB = index->dev->bcdUSB;
qual->bDeviceClass = index->dev->bDeviceClass;
qual->bDeviceSubClass = index->dev->bDeviceSubClass;
qual->bDeviceProtocol = index->dev->bDeviceProtocol;
qual->bMaxPacketSize0 = index->dev->bMaxPacketSize0;
qual->bNumConfigurations = index->dev->bNumConfigurations;
qual->bRESERVED = 0;
*response_data = (char*)qual;
*response_length = sizeof(*qual);
return true;
}
*response_data = descs->qual;
*response_length = descs->qual_len;
return true;
default:
break;
}
break;
default:
break;
}
break;
default:
break;
}
return false;
}
typedef bool (*lookup_connect_out_response_t)(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done);
static bool lookup_connect_response_out_generic(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done)
{
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_SET_CONFIGURATION:
*done = true;
return true;
default:
break;
}
break;
}
return false;
}
#define UDC_NAME_LENGTH_MAX 128
struct usb_raw_init {
__u8 driver_name[UDC_NAME_LENGTH_MAX];
__u8 device_name[UDC_NAME_LENGTH_MAX];
__u8 speed;
};
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID = 0,
USB_RAW_EVENT_CONNECT = 1,
USB_RAW_EVENT_CONTROL = 2,
};
struct usb_raw_event {
__u32 type;
__u32 length;
__u8 data[0];
};
struct usb_raw_ep_io {
__u16 ep;
__u16 flags;
__u32 length;
__u8 data[0];
};
#define USB_RAW_EPS_NUM_MAX 30
#define USB_RAW_EP_NAME_MAX 16
#define USB_RAW_EP_ADDR_ANY 0xff
struct usb_raw_ep_caps {
__u32 type_control : 1;
__u32 type_iso : 1;
__u32 type_bulk : 1;
__u32 type_int : 1;
__u32 dir_in : 1;
__u32 dir_out : 1;
};
struct usb_raw_ep_limits {
__u16 maxpacket_limit;
__u16 max_streams;
__u32 reserved;
};
struct usb_raw_ep_info {
__u8 name[USB_RAW_EP_NAME_MAX];
__u32 addr;
struct usb_raw_ep_caps caps;
struct usb_raw_ep_limits limits;
};
struct usb_raw_eps_info {
struct usb_raw_ep_info eps[USB_RAW_EPS_NUM_MAX];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
#define USB_RAW_IOCTL_RUN _IO('U', 1)
#define USB_RAW_IOCTL_EVENT_FETCH _IOR('U', 2, struct usb_raw_event)
#define USB_RAW_IOCTL_EP0_WRITE _IOW('U', 3, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP0_READ _IOWR('U', 4, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_ENABLE _IOW('U', 5, struct usb_endpoint_descriptor)
#define USB_RAW_IOCTL_EP_DISABLE _IOW('U', 6, __u32)
#define USB_RAW_IOCTL_EP_WRITE _IOW('U', 7, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_READ _IOWR('U', 8, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_CONFIGURE _IO('U', 9)
#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
#define USB_RAW_IOCTL_EPS_INFO _IOR('U', 11, struct usb_raw_eps_info)
#define USB_RAW_IOCTL_EP0_STALL _IO('U', 12)
#define USB_RAW_IOCTL_EP_SET_HALT _IOW('U', 13, __u32)
#define USB_RAW_IOCTL_EP_CLEAR_HALT _IOW('U', 14, __u32)
#define USB_RAW_IOCTL_EP_SET_WEDGE _IOW('U', 15, __u32)
static int usb_raw_open()
{
return open("/dev/raw-gadget", O_RDWR);
}
static int usb_raw_init(int fd, uint32_t speed, const char* driver, const char* device)
{
struct usb_raw_init arg;
strncpy((char*)&arg.driver_name[0], driver, sizeof(arg.driver_name));
strncpy((char*)&arg.device_name[0], device, sizeof(arg.device_name));
arg.speed = speed;
return ioctl(fd, USB_RAW_IOCTL_INIT, &arg);
}
static int usb_raw_run(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_RUN, 0);
}
static int usb_raw_configure(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_CONFIGURE, 0);
}
static int usb_raw_vbus_draw(int fd, uint32_t power)
{
return ioctl(fd, USB_RAW_IOCTL_VBUS_DRAW, power);
}
static int usb_raw_ep0_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_WRITE, io);
}
static int usb_raw_ep0_read(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_READ, io);
}
static int usb_raw_event_fetch(int fd, struct usb_raw_event* event)
{
return ioctl(fd, USB_RAW_IOCTL_EVENT_FETCH, event);
}
static int usb_raw_ep_enable(int fd, struct usb_endpoint_descriptor* desc)
{
return ioctl(fd, USB_RAW_IOCTL_EP_ENABLE, desc);
}
static int usb_raw_ep_disable(int fd, int ep)
{
return ioctl(fd, USB_RAW_IOCTL_EP_DISABLE, ep);
}
static int usb_raw_ep0_stall(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_STALL, 0);
}
#define USB_MAX_PACKET_SIZE 4096
struct usb_raw_control_event {
struct usb_raw_event inner;
struct usb_ctrlrequest ctrl;
char data[USB_MAX_PACKET_SIZE];
};
struct usb_raw_ep_io_data {
struct usb_raw_ep_io inner;
char data[USB_MAX_PACKET_SIZE];
};
static void set_interface(int fd, int n)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return;
if (index->iface_cur >= 0 && index->iface_cur < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++) {
int rv = usb_raw_ep_disable(fd, index->ifaces[index->iface_cur].eps[ep].handle);
if (rv < 0) {
} else {
}
}
}
if (n >= 0 && n < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[n].eps_num; ep++) {
int rv = usb_raw_ep_enable(fd, &index->ifaces[n].eps[ep].desc);
if (rv < 0) {
} else {
index->ifaces[n].eps[ep].handle = rv;
}
}
index->iface_cur = n;
}
}
static int configure_device(int fd)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
int rv = usb_raw_vbus_draw(fd, index->bMaxPower);
if (rv < 0) {
return rv;
}
rv = usb_raw_configure(fd);
if (rv < 0) {
return rv;
}
set_interface(fd, 0);
return 0;
}
static volatile long syz_usb_connect_impl(uint64_t speed, uint64_t dev_len, const char* dev,
const struct vusb_connect_descriptors* descs,
lookup_connect_out_response_t lookup_connect_response_out)
{
if (!dev) {
return -1;
}
int fd = usb_raw_open();
if (fd < 0) {
return fd;
}
if (fd >= MAX_FDS) {
close(fd);
return -1;
}
struct usb_device_index* index = add_usb_index(fd, dev, dev_len);
if (!index) {
return -1;
}
char device[32];
sprintf(&device[0], "dummy_udc.%llu", procid);
int rv = usb_raw_init(fd, speed, "dummy_udc", &device[0]);
if (rv < 0) {
return rv;
}
rv = usb_raw_run(fd);
if (rv < 0) {
return rv;
}
bool done = false;
while (!done) {
struct usb_raw_control_event event;
event.inner.type = 0;
event.inner.length = sizeof(event.ctrl);
rv = usb_raw_event_fetch(fd, (struct usb_raw_event*)&event);
if (rv < 0) {
return rv;
}
if (event.inner.type != USB_RAW_EVENT_CONTROL)
continue;
char* response_data = NULL;
uint32_t response_length = 0;
struct usb_qualifier_descriptor qual;
if (event.ctrl.bRequestType & USB_DIR_IN) {
if (!lookup_connect_response_in(fd, descs, &event.ctrl, &qual, &response_data, &response_length)) {
usb_raw_ep0_stall(fd);
continue;
}
} else {
if (!lookup_connect_response_out(fd, descs, &event.ctrl, &done)) {
usb_raw_ep0_stall(fd);
continue;
}
response_data = NULL;
response_length = event.ctrl.wLength;
}
if ((event.ctrl.bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD &&
event.ctrl.bRequest == USB_REQ_SET_CONFIGURATION) {
rv = configure_device(fd);
if (rv < 0) {
return rv;
}
}
struct usb_raw_ep_io_data response;
response.inner.ep = 0;
response.inner.flags = 0;
if (response_length > sizeof(response.data))
response_length = 0;
if (event.ctrl.wLength < response_length)
response_length = event.ctrl.wLength;
response.inner.length = response_length;
if (response_data)
memcpy(&response.data[0], response_data, response_length);
else
memset(&response.data[0], 0, response_length);
if (event.ctrl.bRequestType & USB_DIR_IN) {
rv = usb_raw_ep0_write(fd, (struct usb_raw_ep_io*)&response);
} else {
rv = usb_raw_ep0_read(fd, (struct usb_raw_ep_io*)&response);
}
if (rv < 0) {
return rv;
}
}
sleep_ms(200);
return fd;
}
static volatile long syz_usb_connect(volatile long a0, volatile long a1, volatile long a2, volatile long a3)
{
uint64_t speed = a0;
uint64_t dev_len = a1;
const char* dev = (const char*)a2;
const struct vusb_connect_descriptors* descs = (const struct vusb_connect_descriptors*)a3;
return syz_usb_connect_impl(speed, dev_len, dev, descs, &lookup_connect_response_out_generic);
}
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_usb_connect arguments: [
// speed: usb_device_speed = 0x0 (8 bytes)
// dev_len: len = 0x2d (8 bytes)
// dev: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {12 01 00 00 d5 e9 bd 40 eb 03 02 00 c0 ba 05 00 00 01 09 02 11 5c 01 00 00 00 00 09 04 00 00 01 b5 04 b1 00 09 05 81} (length 0x27)
// }
// }
// }
// conn_descs: nil
// ]
// returns fd_usb
memcpy((void*)0x200000000100, "... [truncated large byte array] ...", 39);
syz_usb_connect(/*speed=*/0, /*dev_len=*/0x2d, /*dev=*/0x200000000100, /*conn_descs=*/0);
return 0;
}
]
|
| 2/1 |
2026/05/26 11:40 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/9388d6f0d70f1b6f8c33c6e0674d61f3cd008b20]
|
| 3/1 |
2026/05/26 11:42 |
action |
kernel-builder |
19m
Results: map[KernelObj:/app/workdir/cache/build/8e41657562f2cddb05f209d33f5abde4a5e89f09]
|
| 4/1 |
2026/05/26 12:01 |
action |
codesearch-prepare |
8m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/05/26 12:09 |
agent |
expert |
7m
Model:
Results: map[DenialOfService:false Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
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 greeping
".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 or elevated privileges.
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 completly 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 tranfers, that's 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 exploitabability depends on how exactly the uninit value
is used in the code, and what it affects.
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 Confidetial 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:
input: IgorPlug-USB IR Receiver as /devices/platform/dummy_hcd.0/usb1/1-1/1-1:0.0/rc/rc0/input5
------------[ cut here ]------------
usb 1-1: BOGUS control dir, pipe 80000580 doesn't match bRequestType 20
WARNING: drivers/usb/core/urb.c:413 at usb_submit_urb+0x1190/0x1454 drivers/usb/core/urb.c:411, CPU#1: kworker/1:3/4432
Modules linked in:
CPU: 1 UID: 0 PID: 4432 Comm: kworker/1:3 Not tainted syzkaller #0 PREEMPT
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
Workqueue: usb_hub_wq hub_event
pstate: 63400005 (nZCv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : usb_submit_urb+0x1190/0x1454 drivers/usb/core/urb.c:411
lr : usb_submit_urb+0x1190/0x1454 drivers/usb/core/urb.c:411
sp : ffff800099ce6d00
x29: ffff800099ce6d40 x28: 0000000080000580 x27: ffff0000cdd9a058
x26: ffff0000d1d95898 x25: ffff800087065dc0 x24: dfff800000000000
x23: ffff0000d04fbf40 x22: ffff0000d04a0fe0 x21: 1fffe0001a3b2b13
x20: 0000000000000820 x19: ffff0000d04fbf00 x18: 1fffe00035c23420
x17: ffff8000888eb000 x16: ffff80008899dba0 x15: ffff0001ae11a10c
x14: 0000000000000000 x13: 0000000000000001 x12: 0000000000000000
x11: 0000000000000000 x10: 0000000000ff0100 x9 : 2212e0c7e7291f00
x8 : 2212e0c7e7291f00 x7 : ffff80008047caa0 x6 : 0000000000000000
x5 : 0000000000000000 x4 : 0000000000000000 x3 : ffff8000802f1374
x2 : 0000000100000000 x1 : ffff0000d3d68000 x0 : 0000000000000000
Call trace:
usb_submit_urb+0x1190/0x1454 drivers/usb/core/urb.c:411 (P)
igorplugusb_cmd+0xa0/0x144 drivers/media/rc/igorplugusb.c:127
igorplugusb_probe+0x5fc/0x940 drivers/media/rc/igorplugusb.c:225
usb_probe_interface+0x2fc/0x788 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x2a8/0x7e8 drivers/base/dd.c:709
__driver_probe_device+0x1e0/0x33c drivers/base/dd.c:871
driver_probe_device+0x6c/0x19c drivers/base/dd.c:901
__device_attach_driver+0x194/0x2f4 drivers/base/dd.c:1029
bus_for_each_drv+0x144/0x1dc drivers/base/bus.c:500
__device_attach+0x250/0x394 drivers/base/dd.c:1101
device_initial_probe+0x90/0xcc drivers/base/dd.c:1156
bus_probe_device+0x58/0x120 drivers/base/bus.c:613
device_add+0x6c4/0x9e4 drivers/base/core.c:3706
usb_set_configuration+0x1170/0x1588 drivers/usb/core/message.c:2268
usb_generic_driver_probe+0x8c/0x144 drivers/usb/core/generic.c:250
usb_probe_device+0x118/0x2b8 drivers/usb/core/driver.c:291
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x2a8/0x7e8 drivers/base/dd.c:709
__driver_probe_device+0x1e0/0x33c drivers/base/dd.c:871
driver_probe_device+0x6c/0x19c drivers/base/dd.c:901
__device_attach_driver+0x194/0x2f4 drivers/base/dd.c:1029
bus_for_each_drv+0x144/0x1dc drivers/base/bus.c:500
__device_attach+0x250/0x394 drivers/base/dd.c:1101
device_initial_probe+0x90/0xcc drivers/base/dd.c:1156
bus_probe_device+0x58/0x120 drivers/base/bus.c:613
device_add+0x6c4/0x9e4 drivers/base/core.c:3706
usb_new_device+0x7a8/0x1214 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+0x1f7c/0x3b20 drivers/usb/core/hub.c:5953
process_one_work kernel/workqueue.c:3314 [inline]
process_scheduled_works+0x79c/0x1098 kernel/workqueue.c:3397
worker_thread+0x754/0xba0 kernel/workqueue.c:3478
kthread+0x2f8/0x3c8 kernel/kthread.c:436
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:842
irq event stamp: 36390
hardirqs last enabled at (36389): [<ffff80008048000c>] vprintk_store+0x900/0xb70 kernel/printk/printk.c:2385
hardirqs last disabled at (36390): [<ffff80008673aac0>] el1_brk64+0x20/0x54 arch/arm64/kernel/entry-common.c:429
softirqs last enabled at (36334): [<ffff800084ac3a58>] __alloc_skb+0x1c0/0x5f8 net/core/skbuff.c:696
softirqs last disabled at (36332): [<ffff800084ac3a40>] local_bh_disable include/linux/bottom_half.h:20 [inline]
softirqs last disabled at (36332): [<ffff800084ac3a40>] __alloc_skb+0x1a8/0x5f8 net/core/skbuff.c:695
---[ end trace 0000000000000000 ]---
igorplugusb 1-1:0.0: submit urb failed: -53
usb 1-1: new high-speed USB device number 7 using dummy_hcd
usb 1-1: config index 0 descriptor too short (expected 23569, got 27)
usb 1-1: config 0 interface 0 altsetting 0 endpoint 0x81 has invalid wMaxPacketSize 0
usb 1-1: New USB device found, idVendor=03eb, idProduct=0002, bcdDevice=ba.c0
usb 1-1: New USB device strings: Mfr=5, Product=0, SerialNumber=0
usb 1-1: Manufacturer: syz
usb 1-1: config 0 descriptor??
Registered IR keymap rc-hauppauge
rc_core: Loaded IR protocol module ir-rc5-decoder, but protocol rc-5 still not available
rc rc0: IgorPlug-USB IR Receiver as /devices/platform/dummy_hcd.0/usb1/1-1/1-1:0.0/rc/rc0
input: IgorPlug-USB IR Receiver as /devices/platform/dummy_hcd.0/usb1/1-1/1-1:0.0/rc/rc0/input7
igorplugusb 1-1:0.0: submit urb failed: -53
It is reproducible with the followint program.
Keep in mind that it may lack the precise threading, sandboxing, and some arguments of a working reproducer.
But it should give an idea of the involved syscalls.
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/usb/ch9.h>
static unsigned long long procid;
static void sleep_ms(uint64_t ms)
{
usleep(ms * 1000);
}
#define MAX_FDS 30
#define USB_MAX_IFACE_NUM 4
#define USB_MAX_EP_NUM 32
#define USB_MAX_FDS 6
struct usb_endpoint_index {
struct usb_endpoint_descriptor desc;
int handle;
};
struct usb_iface_index {
struct usb_interface_descriptor* iface;
uint8_t bInterfaceNumber;
uint8_t bAlternateSetting;
uint8_t bInterfaceClass;
struct usb_endpoint_index eps[USB_MAX_EP_NUM];
int eps_num;
};
struct usb_device_index {
struct usb_device_descriptor* dev;
struct usb_config_descriptor* config;
uint8_t bDeviceClass;
uint8_t bMaxPower;
int config_length;
struct usb_iface_index ifaces[USB_MAX_IFACE_NUM];
int ifaces_num;
int iface_cur;
};
struct usb_info {
int fd;
struct usb_device_index index;
};
static struct usb_info usb_devices[USB_MAX_FDS];
static struct usb_device_index* lookup_usb_index(int fd)
{
for (int i = 0; i < USB_MAX_FDS; i++) {
if (__atomic_load_n(&usb_devices[i].fd, __ATOMIC_ACQUIRE) == fd)
return &usb_devices[i].index;
}
return NULL;
}
static int usb_devices_num;
static bool parse_usb_descriptor(const char* buffer, size_t length, struct usb_device_index* index)
{
if (length < sizeof(*index->dev) + sizeof(*index->config))
return false;
memset(index, 0, sizeof(*index));
index->dev = (struct usb_device_descriptor*)buffer;
index->config = (struct usb_config_descriptor*)(buffer + sizeof(*index->dev));
index->bDeviceClass = index->dev->bDeviceClass;
index->bMaxPower = index->config->bMaxPower;
index->config_length = length - sizeof(*index->dev);
index->iface_cur = -1;
size_t offset = 0;
while (true) {
if (offset + 1 >= length)
break;
uint8_t desc_length = buffer[offset];
uint8_t desc_type = buffer[offset + 1];
if (desc_length <= 2)
break;
if (offset + desc_length > length)
break;
if (desc_type == USB_DT_INTERFACE && index->ifaces_num < USB_MAX_IFACE_NUM) {
struct usb_interface_descriptor* iface = (struct usb_interface_descriptor*)(buffer + offset);
index->ifaces[index->ifaces_num].iface = iface;
index->ifaces[index->ifaces_num].bInterfaceNumber = iface->bInterfaceNumber;
index->ifaces[index->ifaces_num].bAlternateSetting = iface->bAlternateSetting;
index->ifaces[index->ifaces_num].bInterfaceClass = iface->bInterfaceClass;
index->ifaces_num++;
}
if (desc_type == USB_DT_ENDPOINT && index->ifaces_num > 0) {
struct usb_iface_index* iface = &index->ifaces[index->ifaces_num - 1];
if (iface->eps_num < USB_MAX_EP_NUM) {
memcpy(&iface->eps[iface->eps_num].desc, buffer + offset, sizeof(iface->eps[iface->eps_num].desc));
iface->eps_num++;
}
}
offset += desc_length;
}
return true;
}
static struct usb_device_index* add_usb_index(int fd, const char* dev, size_t dev_len)
{
int i = __atomic_fetch_add(&usb_devices_num, 1, __ATOMIC_RELAXED);
if (i >= USB_MAX_FDS)
return NULL;
if (!parse_usb_descriptor(dev, dev_len, &usb_devices[i].index))
return NULL;
__atomic_store_n(&usb_devices[i].fd, fd, __ATOMIC_RELEASE);
return &usb_devices[i].index;
}
struct vusb_connect_string_descriptor {
uint32_t len;
char* str;
} __attribute__((packed));
struct vusb_connect_descriptors {
uint32_t qual_len;
char* qual;
uint32_t bos_len;
char* bos;
uint32_t strs_len;
struct vusb_connect_string_descriptor strs[0];
} __attribute__((packed));
static const char default_string[] = {
8, USB_DT_STRING,
's', 0, 'y', 0, 'z', 0
};
static const char default_lang_id[] = {
4, USB_DT_STRING,
0x09, 0x04
};
static bool lookup_connect_response_in(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl,
struct usb_qualifier_descriptor* qual,
char** response_data, uint32_t* response_length)
{
struct usb_device_index* index = lookup_usb_index(fd);
uint8_t str_idx;
if (!index)
return false;
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_GET_DESCRIPTOR:
switch (ctrl->wValue >> 8) {
case USB_DT_DEVICE:
*response_data = (char*)index->dev;
*response_length = sizeof(*index->dev);
return true;
case USB_DT_CONFIG:
*response_data = (char*)index->config;
*response_length = index->config_length;
return true;
case USB_DT_STRING:
str_idx = (uint8_t)ctrl->wValue;
if (descs && str_idx < descs->strs_len) {
*response_data = descs->strs[str_idx].str;
*response_length = descs->strs[str_idx].len;
return true;
}
if (str_idx == 0) {
*response_data = (char*)&default_lang_id[0];
*response_length = default_lang_id[0];
return true;
}
*response_data = (char*)&default_string[0];
*response_length = default_string[0];
return true;
case USB_DT_BOS:
*response_data = descs->bos;
*response_length = descs->bos_len;
return true;
case USB_DT_DEVICE_QUALIFIER:
if (!descs->qual) {
qual->bLength = sizeof(*qual);
qual->bDescriptorType = USB_DT_DEVICE_QUALIFIER;
qual->bcdUSB = index->dev->bcdUSB;
qual->bDeviceClass = index->dev->bDeviceClass;
qual->bDeviceSubClass = index->dev->bDeviceSubClass;
qual->bDeviceProtocol = index->dev->bDeviceProtocol;
qual->bMaxPacketSize0 = index->dev->bMaxPacketSize0;
qual->bNumConfigurations = index->dev->bNumConfigurations;
qual->bRESERVED = 0;
*response_data = (char*)qual;
*response_length = sizeof(*qual);
return true;
}
*response_data = descs->qual;
*response_length = descs->qual_len;
return true;
default:
break;
}
break;
default:
break;
}
break;
default:
break;
}
return false;
}
typedef bool (*lookup_connect_out_response_t)(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done);
static bool lookup_connect_response_out_generic(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done)
{
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_SET_CONFIGURATION:
*done = true;
return true;
default:
break;
}
break;
}
return false;
}
#define UDC_NAME_LENGTH_MAX 128
struct usb_raw_init {
__u8 driver_name[UDC_NAME_LENGTH_MAX];
__u8 device_name[UDC_NAME_LENGTH_MAX];
__u8 speed;
};
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID = 0,
USB_RAW_EVENT_CONNECT = 1,
USB_RAW_EVENT_CONTROL = 2,
};
struct usb_raw_event {
__u32 type;
__u32 length;
__u8 data[0];
};
struct usb_raw_ep_io {
__u16 ep;
__u16 flags;
__u32 length;
__u8 data[0];
};
#define USB_RAW_EPS_NUM_MAX 30
#define USB_RAW_EP_NAME_MAX 16
#define USB_RAW_EP_ADDR_ANY 0xff
struct usb_raw_ep_caps {
__u32 type_control : 1;
__u32 type_iso : 1;
__u32 type_bulk : 1;
__u32 type_int : 1;
__u32 dir_in : 1;
__u32 dir_out : 1;
};
struct usb_raw_ep_limits {
__u16 maxpacket_limit;
__u16 max_streams;
__u32 reserved;
};
struct usb_raw_ep_info {
__u8 name[USB_RAW_EP_NAME_MAX];
__u32 addr;
struct usb_raw_ep_caps caps;
struct usb_raw_ep_limits limits;
};
struct usb_raw_eps_info {
struct usb_raw_ep_info eps[USB_RAW_EPS_NUM_MAX];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
#define USB_RAW_IOCTL_RUN _IO('U', 1)
#define USB_RAW_IOCTL_EVENT_FETCH _IOR('U', 2, struct usb_raw_event)
#define USB_RAW_IOCTL_EP0_WRITE _IOW('U', 3, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP0_READ _IOWR('U', 4, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_ENABLE _IOW('U', 5, struct usb_endpoint_descriptor)
#define USB_RAW_IOCTL_EP_DISABLE _IOW('U', 6, __u32)
#define USB_RAW_IOCTL_EP_WRITE _IOW('U', 7, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_READ _IOWR('U', 8, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_CONFIGURE _IO('U', 9)
#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
#define USB_RAW_IOCTL_EPS_INFO _IOR('U', 11, struct usb_raw_eps_info)
#define USB_RAW_IOCTL_EP0_STALL _IO('U', 12)
#define USB_RAW_IOCTL_EP_SET_HALT _IOW('U', 13, __u32)
#define USB_RAW_IOCTL_EP_CLEAR_HALT _IOW('U', 14, __u32)
#define USB_RAW_IOCTL_EP_SET_WEDGE _IOW('U', 15, __u32)
static int usb_raw_open()
{
return open("/dev/raw-gadget", O_RDWR);
}
static int usb_raw_init(int fd, uint32_t speed, const char* driver, const char* device)
{
struct usb_raw_init arg;
strncpy((char*)&arg.driver_name[0], driver, sizeof(arg.driver_name));
strncpy((char*)&arg.device_name[0], device, sizeof(arg.device_name));
arg.speed = speed;
return ioctl(fd, USB_RAW_IOCTL_INIT, &arg);
}
static int usb_raw_run(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_RUN, 0);
}
static int usb_raw_configure(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_CONFIGURE, 0);
}
static int usb_raw_vbus_draw(int fd, uint32_t power)
{
return ioctl(fd, USB_RAW_IOCTL_VBUS_DRAW, power);
}
static int usb_raw_ep0_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_WRITE, io);
}
static int usb_raw_ep0_read(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_READ, io);
}
static int usb_raw_event_fetch(int fd, struct usb_raw_event* event)
{
return ioctl(fd, USB_RAW_IOCTL_EVENT_FETCH, event);
}
static int usb_raw_ep_enable(int fd, struct usb_endpoint_descriptor* desc)
{
return ioctl(fd, USB_RAW_IOCTL_EP_ENABLE, desc);
}
static int usb_raw_ep_disable(int fd, int ep)
{
return ioctl(fd, USB_RAW_IOCTL_EP_DISABLE, ep);
}
static int usb_raw_ep0_stall(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_STALL, 0);
}
#define USB_MAX_PACKET_SIZE 4096
struct usb_raw_control_event {
struct usb_raw_event inner;
struct usb_ctrlrequest ctrl;
char data[USB_MAX_PACKET_SIZE];
};
struct usb_raw_ep_io_data {
struct usb_raw_ep_io inner;
char data[USB_MAX_PACKET_SIZE];
};
static void set_interface(int fd, int n)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return;
if (index->iface_cur >= 0 && index->iface_cur < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++) {
int rv = usb_raw_ep_disable(fd, index->ifaces[index->iface_cur].eps[ep].handle);
if (rv < 0) {
} else {
}
}
}
if (n >= 0 && n < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[n].eps_num; ep++) {
int rv = usb_raw_ep_enable(fd, &index->ifaces[n].eps[ep].desc);
if (rv < 0) {
} else {
index->ifaces[n].eps[ep].handle = rv;
}
}
index->iface_cur = n;
}
}
static int configure_device(int fd)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
int rv = usb_raw_vbus_draw(fd, index->bMaxPower);
if (rv < 0) {
return rv;
}
rv = usb_raw_configure(fd);
if (rv < 0) {
return rv;
}
set_interface(fd, 0);
return 0;
}
static volatile long syz_usb_connect_impl(uint64_t speed, uint64_t dev_len, const char* dev,
const struct vusb_connect_descriptors* descs,
lookup_connect_out_response_t lookup_connect_response_out)
{
if (!dev) {
return -1;
}
int fd = usb_raw_open();
if (fd < 0) {
return fd;
}
if (fd >= MAX_FDS) {
close(fd);
return -1;
}
struct usb_device_index* index = add_usb_index(fd, dev, dev_len);
if (!index) {
return -1;
}
char device[32];
sprintf(&device[0], "dummy_udc.%llu", procid);
int rv = usb_raw_init(fd, speed, "dummy_udc", &device[0]);
if (rv < 0) {
return rv;
}
rv = usb_raw_run(fd);
if (rv < 0) {
return rv;
}
bool done = false;
while (!done) {
struct usb_raw_control_event event;
event.inner.type = 0;
event.inner.length = sizeof(event.ctrl);
rv = usb_raw_event_fetch(fd, (struct usb_raw_event*)&event);
if (rv < 0) {
return rv;
}
if (event.inner.type != USB_RAW_EVENT_CONTROL)
continue;
char* response_data = NULL;
uint32_t response_length = 0;
struct usb_qualifier_descriptor qual;
if (event.ctrl.bRequestType & USB_DIR_IN) {
if (!lookup_connect_response_in(fd, descs, &event.ctrl, &qual, &response_data, &response_length)) {
usb_raw_ep0_stall(fd);
continue;
}
} else {
if (!lookup_connect_response_out(fd, descs, &event.ctrl, &done)) {
usb_raw_ep0_stall(fd);
continue;
}
response_data = NULL;
response_length = event.ctrl.wLength;
}
if ((event.ctrl.bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD &&
event.ctrl.bRequest == USB_REQ_SET_CONFIGURATION) {
rv = configure_device(fd);
if (rv < 0) {
return rv;
}
}
struct usb_raw_ep_io_data response;
response.inner.ep = 0;
response.inner.flags = 0;
if (response_length > sizeof(response.data))
response_length = 0;
if (event.ctrl.wLength < response_length)
response_length = event.ctrl.wLength;
response.inner.length = response_length;
if (response_data)
memcpy(&response.data[0], response_data, response_length);
else
memset(&response.data[0], 0, response_length);
if (event.ctrl.bRequestType & USB_DIR_IN) {
rv = usb_raw_ep0_write(fd, (struct usb_raw_ep_io*)&response);
} else {
rv = usb_raw_ep0_read(fd, (struct usb_raw_ep_io*)&response);
}
if (rv < 0) {
return rv;
}
}
sleep_ms(200);
return fd;
}
static volatile long syz_usb_connect(volatile long a0, volatile long a1, volatile long a2, volatile long a3)
{
uint64_t speed = a0;
uint64_t dev_len = a1;
const char* dev = (const char*)a2;
const struct vusb_connect_descriptors* descs = (const struct vusb_connect_descriptors*)a3;
return syz_usb_connect_impl(speed, dev_len, dev, descs, &lookup_connect_response_out_generic);
}
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_usb_connect arguments: [
// speed: usb_device_speed = 0x0 (8 bytes)
// dev_len: len = 0x2d (8 bytes)
// dev: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {12 01 00 00 d5 e9 bd 40 eb 03 02 00 c0 ba 05 00 00 01 09 02 11 5c 01 00 00 00 00 09 04 00 00 01 b5 04 b1 00 09 05 81} (length 0x27)
// }
// }
// }
// conn_descs: nil
// ]
// returns fd_usb
memcpy((void*)0x200000000100, "... [truncated large byte array] ...", 39);
syz_usb_connect(/*speed=*/0, /*dev_len=*/0x2d, /*dev=*/0x200000000100, /*conn_descs=*/0);
return 0;
}
Reply: Based on the analysis of the bug report and the kernel source code, here is the assessment of the vulnerability:
**Root Cause Analysis:**
The bug is caused by a typo in `drivers/media/rc/igorplugusb.c` within the `igorplugusb_probe` function. When initializing the control URB, the driver passes `(uint8_t *)&ir->request` to `usb_fill_control_urb` instead of `(uint8_t *)ir->request`.
Because `ir->request` is a dynamically allocated pointer (`struct usb_ctrlrequest *`), passing its address (`&ir->request`) means the USB core will read the 8 bytes of the pointer's memory address itself and interpret it as the USB setup packet, rather than reading the actual `usb_ctrlrequest` structure it points to.
**Impact and Exploitability:**
When the driver attempts to submit this URB via `usb_submit_urb`, the USB core validates the setup packet (which is now just the bytes of a kernel pointer):
1. The first byte of the pointer (the least significant byte of the address on little-endian architectures) is interpreted as `bRequestType`. If this byte happens to lack the `USB_DIR_IN` bit (`0x80`), `usb_submit_urb` detects a direction mismatch with the IN pipe and prints the `BOGUS control dir` warning seen in the crash report.
2. Bytes 6 and 7 of the pointer are interpreted as `wLength`. For a standard 64-bit kernel direct-mapping pointer (e.g., `0xffff8880...` or `0xffff0000...`), these bytes are always `0xffff`.
3. `usb_submit_urb` strictly checks if `wLength` matches `urb->transfer_buffer_length` (which is set to `MAX_PACKET`, i.e., 39). Since `0xffff` (65535) will never match 39, `usb_submit_urb` immediately aborts and returns `-EBADR` (`-53`).
Because the URB submission is reliably rejected by the USB core before it is ever queued to the host controller, the kernel pointer is **never leaked** to the USB device. Furthermore, the bug does not cause any memory corruption, out-of-bounds accesses, or resource leaks. The `WARNING` generated does not halt the kernel in production environments (where `panic_on_warn` is disabled). The only consequence is that the driver fails to initialize the device properly.
**Trigger:**
The bug is triggered by the kernel probing a USB device that matches the driver's supported Vendor/Product IDs (e.g., `03eb:0002`). This requires physically plugging in a malicious/malfunctioning USB device or emulating one (e.g., via the `dummy_hcd` and `raw-gadget` interfaces, which require root privileges). It cannot be triggered by unprivileged users, network traffic, or filesystem mounts.
**Conclusion:**
The bug is a functional defect resulting in a harmless warning. It is not a security vulnerability, is not exploitable, and does not cause a Denial of Service.
|
| 6/2 |
2026/05/26 12:09 |
llm |
expert |
0m
Model:
Tokens:
input: 14193
output: 45
thoughts: 252
Thoughts: **Debugging a USB Control Transfer Bug**
Okay, so I've got this bug report, and the error message immediately grabs my attention: "BOGUS control dir, pipe 80000580 doesn't match bRequestType 20." That's classic control transfer mismatch territory. The warning from `usb_submit_urb` points me right to the critical area, and I see the stack trace, which is incredibly useful.
Specifically, `igorplugusb_cmd` and `igorplugusb_probe` are the immediate culprits. That means this is specific to the `igorplugusb` driver. The warning from `usb_submit_urb` on line 411 within `drivers/usb/core/urb.c` and is the likely source of this issue. My first step, obviously, is diving into the `drivers/media/rc/igorplugusb.c` file. I need to understand what this driver is *doing* with its control transfers, and where the mismatch is occurring. The next lines to look at are likely line 127 and line 225 where the functions `igorplugusb_cmd` and `igorplugusb_probe` are located.
|
| 7/2 |
2026/05/26 12:10 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/media/rc/igorplugusb.c IncludeLines:true Name:igorplugusb_cmd]
Results: map[SourceCode: 121: static void igorplugusb_cmd(struct igorplugusb *ir, int cmd)
122: {
123: int ret;
124:
125: ir->request->bRequest = cmd;
126: ir->urb->transfer_flags = 0;
127: ret = usb_submit_urb(ir->urb, GFP_ATOMIC);
128: if (ret && ret != -EPERM)
129: dev_err(ir->dev, "submit urb failed: %d", ret);
130: }
SourceFile:drivers/media/rc/igorplugusb.c]
|
| 8/2 |
2026/05/26 12:10 |
llm |
expert |
0m
Model:
Tokens:
input: 14947
output: 45
thoughts: 12
Thoughts: Okay, here's my summary, taking on the persona you requested:
**Deconstructing `igorplugusb_probe`**
Alright, let's dive into this `igorplugusb_probe` function. Immediately, my mind goes to the potential hardware interaction. I need to understand what this probe function is *probing* for, the device it's targeting, and what the intended outcome of a successful probe would be.
My experience tells me this is likely tied to USB device detection, so I'm thinking about the standard USB device enumeration process. Are there any peculiarities or custom device-specific sequences within this `igorplugusb_probe`? Any vendor-specific requests or data formats I should be on the lookout for? I want to determine if it uses standard descriptors or custom ones.
I'm wondering if this utilizes the USB driver model's mechanisms for device matching. Is there a pre-defined ID table, or some form of dynamic matching taking place? My primary goal, as always, is to determine the device's capabilities, what resources it needs, and how it will integrate with the rest of the system. I also need to ascertain if the probe is responsible for initializing the device, setting up any necessary endpoints, or if it is just validating its presence.
I'm thinking about the potential failure modes as well. What error codes could arise, and what do they indicate about the device or the probe procedure? I need to understand the error handling: what's considered a critical failure vs. something that's gracefully handled? It is the code making any assumptions about the hardware? Perhaps I should see how it might play in a multi-device setup, where several Igorplugusb devices are present. I want to see how these devices are managed by the probe and by the kernel.
|
| 9/2 |
2026/05/26 12:10 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/media/rc/igorplugusb.c IncludeLines:true Name:igorplugusb_probe]
Results: map[SourceCode: 139: static int igorplugusb_probe(struct usb_interface *intf,
140: const struct usb_device_id *id)
141: {
142: struct usb_device *udev;
143: struct usb_host_interface *idesc;
144: struct usb_endpoint_descriptor *ep;
145: struct igorplugusb *ir;
146: struct rc_dev *rc;
147: int ret = -ENOMEM;
148:
149: udev = interface_to_usbdev(intf);
150: idesc = intf->cur_altsetting;
151:
152: if (idesc->desc.bNumEndpoints != 1) {
153: dev_err(&intf->dev, "incorrect number of endpoints");
154: return -ENODEV;
155: }
156:
157: ep = &idesc->endpoint[0].desc;
158: if (!usb_endpoint_dir_in(ep) || !usb_endpoint_xfer_control(ep)) {
159: dev_err(&intf->dev, "endpoint incorrect");
160: return -ENODEV;
161: }
162:
163: ir = devm_kzalloc(&intf->dev, sizeof(*ir), GFP_KERNEL);
164: if (!ir)
165: return -ENOMEM;
166:
167: ir->request = kzalloc_obj(*ir->request, GFP_KERNEL);
168: if (!ir->request)
169: goto fail;
170:
171: ir->dev = &intf->dev;
172:
173: timer_setup(&ir->timer, igorplugusb_timer, 0);
174:
175: ir->request->bRequest = GET_INFRACODE;
176: ir->request->bRequestType = USB_TYPE_VENDOR | USB_DIR_IN;
177: ir->request->wLength = cpu_to_le16(MAX_PACKET);
178:
179: ir->urb = usb_alloc_urb(0, GFP_KERNEL);
180: if (!ir->urb)
181: goto fail;
182:
183: ir->buf_in = kmalloc(MAX_PACKET, GFP_KERNEL);
184: if (!ir->buf_in)
185: goto fail;
186: usb_fill_control_urb(ir->urb, udev,
187: usb_rcvctrlpipe(udev, 0), (uint8_t *)&ir->request,
188: ir->buf_in, MAX_PACKET, igorplugusb_callback, ir);
189:
190: usb_make_path(udev, ir->phys, sizeof(ir->phys));
191:
192: rc = rc_allocate_device(RC_DRIVER_IR_RAW);
193: if (!rc)
194: goto fail;
195:
196: rc->device_name = DRIVER_DESC;
197: rc->input_phys = ir->phys;
198: usb_to_input_id(udev, &rc->input_id);
199: rc->dev.parent = &intf->dev;
200: /*
201: * This device can only store 36 pulses + spaces, which is not enough
202: * for the NEC protocol and many others.
203: */
204: rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER &
205: ~(RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 |
206: RC_PROTO_BIT_RC6_6A_20 | RC_PROTO_BIT_RC6_6A_24 |
207: RC_PROTO_BIT_RC6_6A_32 | RC_PROTO_BIT_RC6_MCE |
208: RC_PROTO_BIT_SONY20 | RC_PROTO_BIT_SANYO);
209:
210: rc->priv = ir;
211: rc->driver_name = DRIVER_NAME;
212: rc->map_name = RC_MAP_HAUPPAUGE;
213: rc->timeout = MS_TO_US(100);
214: rc->rx_resolution = 85;
215:
216: ir->rc = rc;
217: ret = rc_register_device(rc);
218: if (ret) {
219: dev_err(&intf->dev, "failed to register rc device: %d", ret);
220: goto fail;
221: }
222:
223: usb_set_intfdata(intf, ir);
224:
225: igorplugusb_cmd(ir, SET_INFRABUFFER_EMPTY);
226:
227: return 0;
228: fail:
229: usb_poison_urb(ir->urb);
230: timer_delete(&ir->timer);
231: usb_unpoison_urb(ir->urb);
232: usb_free_urb(ir->urb);
233: rc_free_device(ir->rc);
234: kfree(ir->buf_in);
235: kfree(ir->request);
236:
237: return ret;
238: }
SourceFile:drivers/media/rc/igorplugusb.c]
|
| 10/2 |
2026/05/26 12:10 |
llm |
expert |
0m
Model:
Tokens:
input: 17013
output: 43
thoughts: 508
Thoughts: **Debugging a USB Control Transfer Issue**
Okay, so I'm seeing this "BOGUS control dir" warning related to a USB device, specifically with a bRequestType mismatch. This is a bit odd, so I need to dig into the driver code for this "igorplugusb" device. The warning points to a problem with a control transfer, and the message indicates that the direction (DIR) doesn't align with the expected request type.
I'm focusing on the `igorplugusb_probe` function now, where the USB control URB is set up. Let's see... the code seems to be constructing a control transfer with `GET_INFRACODE` request. It sets `bRequest` to `GET_INFRACODE` and `bRequestType` to `USB_TYPE_VENDOR | USB_DIR_IN`, which is correct; it's a vendor-specific, input operation. The `wLength` field indicates how many bytes we expect in the input buffer. Then the function proceeds to allocate and populate the URB and buffer, and then it is passing in the request buffer to `usb_fill_control_urb`.
Hmm, this looks odd: `usb_fill_control_urb(ir->urb, udev, usb_rcvctrlpipe(udev, 0), (uint8_t *)&ir->request, ir->buf_in, MAX_PACKET, igorplugusb_callback, ir);`. I'm a bit concerned, it's passing the *address* of `ir->request` to `usb_fill_control_urb` instead of `ir->request`. This is likely where the error lies. If `ir->request` is a struct, then it should pass the pointer to the structure as `(uint8_t *)ir->request`. This is likely the root of the issue.
Let me verify that `ir->request` is a struct. Ah, the code allocates memory for it: `ir->request = kzalloc_obj(*ir->request, GFP_KERNEL);` *wait*. Hang on... `kzalloc_obj`? That's not a standard kernel function, that's definitely a custom macro or function. I need to be *sure* I understand the memory allocation here. Let me re-check the source code carefully... and again... and again. Okay, something isn't right here, I see the code says `ir->request = kzalloc_obj(*ir->request, GFP_KERNEL);` - wait, the *code* says that? I'll re-check the code again.
Right, the code *does* say that, and I know I have seen `kzalloc` used with `sizeof(*pointer)`, but where is this definition of `kzalloc_obj`? It is *not* a standard kernel function. This could be a macro, but I need to understand it better. This is the likely area of the bug. It looks like an error, where the programmer intended to allocate space with `kzalloc`. I have to find where `kzalloc_obj` is defined, or if there is some other code.
|
| 11/2 |
2026/05/26 12:10 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/media/rc/igorplugusb.c IncludeLines:true Name:igorplugusb]
Results: map[SourceCode: 32: struct igorplugusb {
33: struct rc_dev *rc;
34: struct device *dev;
35:
36: struct urb *urb;
37: struct usb_ctrlrequest *request;
38:
39: struct timer_list timer;
40:
41: u8 *buf_in;
42:
43: char phys[64];
44: };
SourceFile:drivers/media/rc/igorplugusb.c]
|
| 12/2 |
2026/05/26 12:10 |
llm |
expert |
0m
Model:
Tokens:
input: 18396
output: 45
thoughts: 109
Thoughts: **Debugging a Kernel Module Pointer**
Okay, so I'm looking at this `igorplugusb` code, and my first thought was, "Aha! `ir->request` is a pointer." Seems straightforward enough. The code then shows:
```c
ir->request = kzalloc_obj(*ir->request, GFP_KERNEL);
```
I was initially interpreting this as allocating memory for what `ir->request` *points* to. But something felt off. Let me re-examine the source. Ah, right. It's line 167 of `igorplugusb_probe`. Okay, better get it right this time. Gotta be precise.
|
| 13/2 |
2026/05/26 12:10 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/media/rc/igorplugusb.c IncludeLines:true Name:igorplugusb_probe]
Results: map[SourceCode: 139: static int igorplugusb_probe(struct usb_interface *intf,
140: const struct usb_device_id *id)
141: {
142: struct usb_device *udev;
143: struct usb_host_interface *idesc;
144: struct usb_endpoint_descriptor *ep;
145: struct igorplugusb *ir;
146: struct rc_dev *rc;
147: int ret = -ENOMEM;
148:
149: udev = interface_to_usbdev(intf);
150: idesc = intf->cur_altsetting;
151:
152: if (idesc->desc.bNumEndpoints != 1) {
153: dev_err(&intf->dev, "incorrect number of endpoints");
154: return -ENODEV;
155: }
156:
157: ep = &idesc->endpoint[0].desc;
158: if (!usb_endpoint_dir_in(ep) || !usb_endpoint_xfer_control(ep)) {
159: dev_err(&intf->dev, "endpoint incorrect");
160: return -ENODEV;
161: }
162:
163: ir = devm_kzalloc(&intf->dev, sizeof(*ir), GFP_KERNEL);
164: if (!ir)
165: return -ENOMEM;
166:
167: ir->request = kzalloc_obj(*ir->request, GFP_KERNEL);
168: if (!ir->request)
169: goto fail;
170:
171: ir->dev = &intf->dev;
172:
173: timer_setup(&ir->timer, igorplugusb_timer, 0);
174:
175: ir->request->bRequest = GET_INFRACODE;
176: ir->request->bRequestType = USB_TYPE_VENDOR | USB_DIR_IN;
177: ir->request->wLength = cpu_to_le16(MAX_PACKET);
178:
179: ir->urb = usb_alloc_urb(0, GFP_KERNEL);
180: if (!ir->urb)
181: goto fail;
182:
183: ir->buf_in = kmalloc(MAX_PACKET, GFP_KERNEL);
184: if (!ir->buf_in)
185: goto fail;
186: usb_fill_control_urb(ir->urb, udev,
187: usb_rcvctrlpipe(udev, 0), (uint8_t *)&ir->request,
188: ir->buf_in, MAX_PACKET, igorplugusb_callback, ir);
189:
190: usb_make_path(udev, ir->phys, sizeof(ir->phys));
191:
192: rc = rc_allocate_device(RC_DRIVER_IR_RAW);
193: if (!rc)
194: goto fail;
195:
196: rc->device_name = DRIVER_DESC;
197: rc->input_phys = ir->phys;
198: usb_to_input_id(udev, &rc->input_id);
199: rc->dev.parent = &intf->dev;
200: /*
201: * This device can only store 36 pulses + spaces, which is not enough
202: * for the NEC protocol and many others.
203: */
204: rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER &
205: ~(RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 |
206: RC_PROTO_BIT_RC6_6A_20 | RC_PROTO_BIT_RC6_6A_24 |
207: RC_PROTO_BIT_RC6_6A_32 | RC_PROTO_BIT_RC6_MCE |
208: RC_PROTO_BIT_SONY20 | RC_PROTO_BIT_SANYO);
209:
210: rc->priv = ir;
211: rc->driver_name = DRIVER_NAME;
212: rc->map_name = RC_MAP_HAUPPAUGE;
213: rc->timeout = MS_TO_US(100);
214: rc->rx_resolution = 85;
215:
216: ir->rc = rc;
217: ret = rc_register_device(rc);
218: if (ret) {
219: dev_err(&intf->dev, "failed to register rc device: %d", ret);
220: goto fail;
221: }
222:
223: usb_set_intfdata(intf, ir);
224:
225: igorplugusb_cmd(ir, SET_INFRABUFFER_EMPTY);
226:
227: return 0;
228: fail:
229: usb_poison_urb(ir->urb);
230: timer_delete(&ir->timer);
231: usb_unpoison_urb(ir->urb);
232: usb_free_urb(ir->urb);
233: rc_free_device(ir->rc);
234: kfree(ir->buf_in);
235: kfree(ir->request);
236:
237: return ret;
238: }
SourceFile:drivers/media/rc/igorplugusb.c]
|
| 14/2 |
2026/05/26 12:10 |
llm |
expert |
0m
Model:
Tokens:
input: 20327
output: 19
thoughts: 225
Thoughts: **Debugging a USB Control Transfer**
Okay, hold on a second. Let me re-examine this code snippet:
```c
usb_fill_control_urb(ir->urb, udev,
usb_rcvctrlpipe(udev, 0), (uint8_t *)&ir->request,
ir->buf_in, MAX_PACKET, igorplugusb_callback, ir);
```
Something's not right here. The line `(uint8_t *)&ir->request` is a red flag. I'm passing the *address* of the pointer `ir->request`, not the pointer itself. And `ir->request` is a pointer to a `struct usb_ctrlrequest`. So, `&ir->request` is a pointer to a pointer. Now, I remember `usb_fill_control_urb` expects an `unsigned char *setup_packet` argument. If I pass it the address of the pointer like this, it's going to interpret the *value* of that pointer as the setup packet! That's definitely going to cause issues. I need to make sure I'm passing the actual pointer `ir->request`. And that struct `usb_ctrlrequest` is allocated, it's either `kmalloc` or `kzalloc_obj`, let me verify this now... wait... `kzalloc_obj`... is that a macro? Let me check quickly... yes, it is. Right.
|
| 15/2 |
2026/05/26 12:10 |
tool |
grepper |
0m
Args: map[Expression:define kzalloc_obj]
Results: map[Output:include/linux/slab.h=958=void *kmalloc_nolock_noprof(size_t size, gfp_t gfp_flags, int node);
--
include/linux/slab.h-1038-/* All kzalloc aliases for kmalloc_(obj|objs|flex). */
include/linux/slab.h:1039:#define kzalloc_obj(P, ...) \
include/linux/slab.h-1040- __alloc_objs(kzalloc, default_gfp(__VA_ARGS__), typeof(P), 1)
include/linux/slab.h:1041:#define kzalloc_objs(P, COUNT, ...) \
include/linux/slab.h-1042- __alloc_objs(kzalloc, default_gfp(__VA_ARGS__), typeof(P), COUNT)
--
tools/include/linux/slab.h=200=static inline unsigned int kmem_cache_sheaf_size(struct slab_sheaf *sheaf)
--
tools/include/linux/slab.h-210-
tools/include/linux/slab.h:211:#define kzalloc_obj(P, ...) \
tools/include/linux/slab.h-212- __alloc_objs(kzalloc, default_gfp(__VA_ARGS__), typeof(P), 1)
]
|
| 16/2 |
2026/05/26 12:10 |
llm |
expert |
0m
Model:
Tokens:
input: 21222
output: 43
thoughts: 1354
Thoughts: **Analyzing a USB Driver Bug and Information Leak**
Okay, so I'm looking at this USB driver code, and immediately I see something amiss. The `kzalloc_obj` macro allocates memory for the `struct usb_ctrlrequest` and assigns it to `ir->request`, which makes sense. Then the code proceeds to fill in the request fields like `bRequest`, etc. But then things go sideways when it calls `usb_fill_control_urb` with `(uint8_t *)&ir->request`. My immediate reaction is, "Wait a second! That's not right!"
This means the *setup packet* is the address of the request structure, not the structure itself! On a 64-bit system, that's an 8-byte pointer being sent as the setup packet, which the device will misinterpret as `bRequestType`, `bRequest`, `wValue`, `wIndex`, and `wLength` fields. No wonder there's a "BOGUS control dir" warning! The code is essentially sending the *address* of the `struct usb_ctrlrequest` as the request itself.
This warning, coming from `usb_submit_urb`, seems to stem from a direction mismatch. It's an IN pipe, and the setup packet's direction byte must have the `USB_DIR_IN` bit set (0x80). Because the least significant byte of `ir->request` happens to be `0x20` which doesn't have 0x80 set, the direction will not match.
Now, let's step back and consider *why* this is happening. The key issue is that `setup_packet` in `igorplugusb_probe` points to `&ir->request`. When `usb_submit_urb` is called, it reads the setup packet from `&ir->request`, the *address of* the pointer, not the *pointer's contents*. Because `ir->request` is a pointer, its value is the address of the allocated `struct usb_ctrlrequest`. Thus, the device receives the pointer. The author probably had the correct approach, but a mistake was made in specifying the setup packet to be passed to the USB driver.
So the problem: theyβre passing the *address* of the pointer (`&ir->request`) as the setup packet, not the *contents* of the pointer (`ir->request`). The setup packet is the 8 bytes of the address of `ir->request`. The device is getting a kernel pointer.
Hold on... this is an information leak! The USB device is receiving a kernel pointer. A malicious USB device could read this setup packet and get a kernel address, effectively bypassing KASLR. This is exploitable, isn't it? It's a peripheral trigger that is accessible upon the plug-in of a USB device, providing the possibility of obtaining a kernel address.
This has security implications. The `usb_submit_urb` isn't rejecting the request; the warning is just a flag, but the data is sent. The device is receiving potentially random or uninitialized bytes (the pointer's value) as the setup packet, which leads to the warning, but more importantly, a kernel address leak.
|
| 17/2 |
2026/05/26 12:10 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/core/urb.c IncludeLines:true 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]
|
| 18/2 |
2026/05/26 12:10 |
llm |
expert |
1m
Model:
Tokens:
input: 29541
output: 19
thoughts: 395
Thoughts: **Analyzing USB Control Transfer Handling**
Okay, so I'm looking at this `usb_submit_urb` function and specifically the control transfer part. It starts with a check for control transfers, which makes sense. The first thing that jumps out is the handling of the `setup_packet`. If it's null, we return an error, which is expected (`-ENOEXEC`). Then, it determines the direction of the transfer (`is_out`) based on the `bRequestType` field. I see a `dev_WARN_ONCE`, which is a warning, not an error! That's something to remember. It's checking if the pipe direction matches what the `bRequestType` suggests. Even though there is a mismatch, the code does not stop and instead issues a warning.
Now, this is where it gets interesting: the length check! It compares `le16_to_cpu(setup->wLength)` with `urb->transfer_buffer_length`. If these lengths don't match, we immediately return `-EBADR`, a bad request error. I'm noting that `setup->wLength` is pulled from the setup packet, specifically bytes 5 and 6 of `ir->request`. On the other hand, `urb->transfer_buffer_length` is the length of the data buffer, which *should* be the maximum packet size for the control transfer. I should look into what `MAX_PACKET` is.
|
| 19/2 |
2026/05/26 12:11 |
tool |
grepper |
0m
Args: map[Expression:define MAX_PACKET]
Results: map[Output:drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h-21-/* Packet size value, the unit is 16 bytes */
drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h:22:#define MAX_PACKET_SIZE_VALUE_LNL 256
drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h-23-
--
drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h-52-#define DEFAULT_MIN_PACKET_SIZE_VALUE 4
drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h:53:#define MAX_PACKET_SIZE_VALUE_MTL 128
drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h:54:#define MAX_PACKET_SIZE_VALUE_LNL 256
drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h-55-
--
drivers/input/touchscreen/elants_i2c.c-89-/* Header (4 bytes) plus 3 full 10-finger packets */
drivers/input/touchscreen/elants_i2c.c:90:#define MAX_PACKET_SIZE 169
drivers/input/touchscreen/elants_i2c.c-91-
--
drivers/media/firewire/firedtv-fw.c=61=int fdtv_write(struct firedtv *fdtv, u64 addr, void *data, size_t len)
--
drivers/media/firewire/firedtv-fw.c-70-
drivers/media/firewire/firedtv-fw.c:71:#define MAX_PACKET_SIZE 1024 /* 776, rounded up to 2^n */
drivers/media/firewire/firedtv-fw.c-72-#define PACKETS_PER_PAGE (PAGE_SIZE / MAX_PACKET_SIZE)
--
drivers/media/rc/igorplugusb.c-25-#define BUFLEN 36
drivers/media/rc/igorplugusb.c:26:#define MAX_PACKET (HEADERLEN + BUFLEN)
drivers/media/rc/igorplugusb.c-27-
--
drivers/media/rc/ir_toy.c=30=static const u8 COMMAND_TXSTART[] = { 0x26, 0x24, 0x25, 0x03 };
--
drivers/media/rc/ir_toy.c-46-
drivers/media/rc/ir_toy.c:47:#define MAX_PACKET 64
drivers/media/rc/ir_toy.c-48-
--
drivers/net/ethernet/agere/et131x.c=87=MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver for the ET1310 by Agere Systems");
--
drivers/net/ethernet/agere/et131x.c-177-
drivers/net/ethernet/agere/et131x.c:178:#define MAX_PACKETS_HANDLED 256
drivers/net/ethernet/agere/et131x.c-179-#define ET131X_MIN_MTU 64
--
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c=32=typedef int (*read_sfp_module_eeprom_func_p)(struct bnx2x_phy *phy,
--
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c-191-
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c:192:#define MAX_PACKET_SIZE (9700)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c-193-#define MAX_KR_LINK_RETRY 4
--
drivers/net/ethernet/cavium/liquidio/octeon_droq.h-27-/* Default number of packets that will be processed in one iteration. */
drivers/net/ethernet/cavium/liquidio/octeon_droq.h:28:#define MAX_PACKET_BUDGET 0xFFFFFFFF
drivers/net/ethernet/cavium/liquidio/octeon_droq.h-29-
--
drivers/net/ethernet/dec/tulip/dmfe.c-112-#define TDES0_ERR_MASK 0x4302 /* TXJT, LC, EC, FUE */
drivers/net/ethernet/dec/tulip/dmfe.c:113:#define MAX_PACKET_SIZE 1514
drivers/net/ethernet/dec/tulip/dmfe.c-114-#define DMFE_MAX_MULTICAST 14
--
drivers/net/ethernet/dec/tulip/uli526x.c-55-#define TDES0_ERR_MASK 0x4302 /* TXJT, LC, EC, FUE */
drivers/net/ethernet/dec/tulip/uli526x.c:56:#define MAX_PACKET_SIZE 1514
drivers/net/ethernet/dec/tulip/uli526x.c-57-#define ULI5261_MAX_MULTICAST 14
--
drivers/net/ethernet/freescale/fman/fman_dtsec.c-143-
drivers/net/ethernet/freescale/fman/fman_dtsec.c:144:#define MAX_PACKET_ALIGNMENT 31
drivers/net/ethernet/freescale/fman/fman_dtsec.c-145-#define MAX_INTER_PACKET_GAP 0x7f
--
drivers/staging/greybus/loopback.c=114=module_param(kfifo_depth, uint, 0444);
--
drivers/staging/greybus/loopback.c-116-/* Maximum size of any one send data buffer we support */
drivers/staging/greybus/loopback.c:117:#define MAX_PACKET_SIZE (PAGE_SIZE * 2)
drivers/staging/greybus/loopback.c-118-
--
drivers/staging/greybus/raw.c=42=static DEFINE_IDA(minors);
--
drivers/staging/greybus/raw.c-47-/* Maximum size of any one send data buffer we support */
drivers/staging/greybus/raw.c:48:#define MAX_PACKET_SIZE (PAGE_SIZE * 2)
drivers/staging/greybus/raw.c-49-
--
drivers/usb/cdns3/cdnsp-gadget.h=646=struct cdnsp_ep_ctx {
--
drivers/usb/cdns3/cdnsp-gadget.h-702-#define CTX_TO_MAX_BURST(p) (((p) & GENMASK(15, 8)) >> 8)
drivers/usb/cdns3/cdnsp-gadget.h:703:#define MAX_PACKET(p) (((p) << 16) & GENMASK(31, 16))
drivers/usb/cdns3/cdnsp-gadget.h:704:#define MAX_PACKET_MASK GENMASK(31, 16)
drivers/usb/cdns3/cdnsp-gadget.h:705:#define MAX_PACKET_DECODED(p) (((p) & GENMASK(31, 16)) >> 16)
drivers/usb/cdns3/cdnsp-gadget.h-706-
--
drivers/usb/host/xhci.h=427=struct xhci_ep_ctx {
--
drivers/usb/host/xhci.h-490-#define CTX_TO_MAX_BURST(p) (((p) >> 8) & 0xff)
drivers/usb/host/xhci.h:491:#define MAX_PACKET(p) (((p)&0xffff) << 16)
drivers/usb/host/xhci.h:492:#define MAX_PACKET_MASK (0xffff << 16)
drivers/usb/host/xhci.h:493:#define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff)
drivers/usb/host/xhci.h-494-
--
include/linux/bpf_verifier.h=1436=static inline u64 bpf_map_key_immediate(const struct bpf_insn_aux_data *aux)
--
include/linux/bpf_verifier.h-1440-
include/linux/bpf_verifier.h:1441:#define MAX_PACKET_OFF 0xffff
include/linux/bpf_verifier.h-1442-#define CALLER_SAVED_REGS 6
--
sound/usb/misc/ua101.c=21=MODULE_LICENSE("GPL v2");
--
sound/usb/misc/ua101.c-37-
sound/usb/misc/ua101.c:38:#define MAX_PACKET_SIZE 672 /* hardware specific */
sound/usb/misc/ua101.c-39-#define MAX_MEMORY_BUFFERS DIV_ROUND_UP(MAX_QUEUE_LENGTH, \
--
tools/testing/selftests/bpf/progs/test_tcp_custom_syncookie.c-13-
tools/testing/selftests/bpf/progs/test_tcp_custom_syncookie.c:14:#define MAX_PACKET_OFF 0xffff
tools/testing/selftests/bpf/progs/test_tcp_custom_syncookie.c-15-
--
tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c-57-
tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c:58:#define MAX_PACKET_OFF 0xffff
tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c-59-
]
|
| 20/2 |
2026/05/26 12:11 |
llm |
expert |
0m
Model:
Tokens:
input: 32860
output: 17
thoughts: 64
Thoughts: **Analyzing the Igorplugusb.c Buffer Length**
Okay, so I'm looking at this `igorplugusb.c` file, specifically the buffer definitions. Right off the bat, I see `#define BUFLEN 36` and then `#define MAX_PACKET (HEADERLEN + BUFLEN)`. My immediate thought is, "Right, `BUFLEN` is the payload size, but what's `HEADERLEN`?" I'm betting it's probably just 3 or 4 bytes for the packet header. Standard stuff. I'm going to quickly glance at the header structure definition to confirm that, because, let's be honest, assumptions are the mother of all... you know. Gotta verify. Gotta make sure the header size is what I suspect, so the `MAX_PACKET` calc makes sense. It would be a silly bug if the calculation was wrong.
|
| 21/2 |
2026/05/26 12:11 |
tool |
grepper |
0m
Args: map[Expression:define HEADERLEN]
Results: map[Output:drivers/media/rc/igorplugusb.c-23-
drivers/media/rc/igorplugusb.c:24:#define HEADERLEN 3
drivers/media/rc/igorplugusb.c-25-#define BUFLEN 36
]
|
| 22/2 |
2026/05/26 12:12 |
llm |
expert |
0m
Model:
Tokens:
input: 33204
output: 46
thoughts: 984
Thoughts: **Analyzing a USB Control Transfer Issue**
Okay, so I'm looking at this USB control transfer scenario. It seems the code is rejecting the URB with `-EBADR`. My first thought was that `MAX_PACKET` is 39, `urb->transfer_buffer_length` is also 39, but `le16_to_cpu(setup->wLength)` is being read from the *address* of `ir->request` β specifically, bytes 5 and 6 of that pointer. And that's wrong; if it doesn't match 39, `usb_submit_urb` returns `-EBADR`.
Wait a minute, `ir->request` is a 64-bit pointer! Reading bytes 5 and 6 of the *pointer itself* makes no sense in terms of the transfer length! Those bytes are part of the upper address bits, usually something fixed like `0x80`, `0x88`, `0xff` from something like `0xffff8880...`. So the `wLength` value is going to be incredibly unlikely to be 39. It's almost certain to be some nonsensical value like `0xff88` or `0x8880` depending on endianness and the exact pointer value.
But then I see the warning is triggered *before* the length check! It's complaining about the direction of the control transfer. Okay, so that warning is happening, and *then* it's returning `-EBADR`. No memory corruption, just a rejected URB.
If `-EBADR` is returned, the `igorplugusb_cmd` function will print an error and return. That means the URB is *not* submitted to the host controller. If the URB isn't submitted, the setup packet isn't sent to the device.
Let me thinkβ¦`usb_submit_urb` rejects the URB if `wLength` doesn't match `transfer_buffer_length`. Ah, I see: it's not even reaching the host controller!
Okay, let me confirm. Yes, it's returning `-EBADR` before it calls `usb_hcd_submit_urb`. The URB is being rejected *before* it gets sent.
But, what if `bRequestType` *does* match the pipe direction, AND `wLength` *does* happen to match `transfer_buffer_length`? The probability of those address bytes *happening* to match 39 is ridiculously small, like 1 in 65536. If it miraculously does, the URB gets submitted, and the device receives the *pointer*... wait, I'm stuck on that pointer again! The 5th and 6th bytes of the pointer⦠let's say it's `0xffff8880...`.
So, the issue is, the `setup->wLength` is incorrectly reading the pointer `ir->request`. I am assuming `wLength` is read from `(struct usb_ctrlrequest *) urb->setup_packet`
`urb->setup_packet` which points to `&ir->request`. Thus `wLength` is read from bytes 6 and 7 of the data pointed to by `&ir->request`, instead of being populated with a *valid length*.
Okay, I need to check the `struct usb_ctrlrequest`. I think I might see the problem now. It looks like it is pointing to the wrong data.
|
| 23/2 |
2026/05/26 12:12 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/uapi/linux/usb/ch9.h IncludeLines:true Name:usb_ctrlrequest]
Results: map[SourceCode: 197: /**
198: * struct usb_ctrlrequest - SETUP data for a USB device control request
199: * @bRequestType: matches the USB bmRequestType field
200: * @bRequest: matches the USB bRequest field
201: * @wValue: matches the USB wValue field (le16 byte order)
202: * @wIndex: matches the USB wIndex field (le16 byte order)
203: * @wLength: matches the USB wLength field (le16 byte order)
204: *
205: * This structure is used to send control requests to a USB device. It matches
206: * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the
207: * USB spec for a fuller description of the different fields, and what they are
208: * used for.
209: *
210: * Note that the driver for any interface can issue control requests.
211: * For most devices, interfaces don't coordinate with each other, so
212: * such requests may be made at any time.
213: */
214: struct usb_ctrlrequest {
215: __u8 bRequestType;
216: __u8 bRequest;
217: __le16 wValue;
218: __le16 wIndex;
219: __le16 wLength;
220: } __attribute__ ((packed));
SourceFile:include/uapi/linux/usb/ch9.h]
|
| 24/2 |
2026/05/26 12:12 |
llm |
expert |
0m
Model:
Tokens:
input: 35439
output: 45
thoughts: 912
Thoughts: **Analyzing the `igorplugusb` Driver's Flawed URB Submission**
Okay, so let's break this down. It seems pretty clear now. I was initially focused on the comparison of `wLength` and `transfer_buffer_length`, and, yes, that's where the problem lies. Looking at the memory layout, `wLength` is definitely comprised of bytes 6 and 7 of the `setup` packet, which in this case, is a pointer to the `struct usb_ctrlrequest`. For a typical kernel pointer (little-endian), those bytes are `0xffff`.
Now, the code has `le16_to_cpu(setup->wLength)` which translates the little endian 0xffff to 65535, whereas `urb->transfer_buffer_length` is 39. So the `if` statement, `le16_to_cpu(setup->wLength) != urb->transfer_buffer_length` will *always* be true. The `wLength` will *always* be `0xffff` because of the nature of the pointer. This means the URB is never submitted as the check causes it to return EBADR.
I needed to re-evaluate how the `usb_ctrlrequest` is used within the driver. So, the `kzalloc`'d `ir->request` is initialized during probe. Specifically, when `usb_fill_control_urb` is called, it takes `(uint8_t *)&ir->request`, which is, crucially, the address of the `usb_ctrlrequest` structure, not the data within it. That address is then used as the `setup_packet`. Then, further down the line `igorplugusb_cmd` is called, which changes the `bRequest` field of the *same* `usb_ctrlrequest` structure. However the URB is already filled with a pointer to the struct which `usb_submit_urb` will then dereference.
So, when `usb_submit_urb` is called, it's interpreting the pointer itself as the `setup_packet`. Since `wLength` (bytes 6 and 7 of the pointer's value) are `0xffff`, it consistently returns `-EBADR` or -53.
This is consistent with the error in the bug report: "submit urb failed: -53." That -EBADR confirms the issue is the URB submission failing. The timer hasn't caused this yet, because the function never returns.
The issue isn't a *leak* per se. The pointer is just being used incorrectly as the setup packet in the URB, and causing an error.
|
| 25/2 |
2026/05/26 12:12 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/media/rc/igorplugusb.c IncludeLines:true Name:igorplugusb_timer]
Results: map[SourceCode: 132: static void igorplugusb_timer(struct timer_list *t)
133: {
134: struct igorplugusb *ir = timer_container_of(ir, t, timer);
135:
136: igorplugusb_cmd(ir, GET_INFRACODE);
137: }
SourceFile:drivers/media/rc/igorplugusb.c]
|
| 26/2 |
2026/05/26 12:12 |
llm |
expert |
1m
Model:
Tokens:
input: 37098
output: 42
thoughts: 391
Thoughts: **My Analysis of the USB Driver Issue**
Okay, so I've traced the issue. It looks like the core problem boils down to how the `GET_INFRACODE` command is handled in the `igorplugusb_cmd` function. Specifically, it seems like the code simply calls `igorplugusb_cmd(ir, GET_INFRACODE)`. This is where the failure will occur, resulting in an `-EBADR` error.
I checked if the `ir->urb` (USB Request Block) is submitted anywhere else, but it isn't. This is critical. The URB isn't being submitted, which means the device never actually receives the pointer or, consequently, the data.
I've ruled out memory corruption; it's just a warning and an error return. The warning message is the key: `drivers/usb/core/urb.c:413 at usb_submit_urb+0x1190/0x1454 drivers/usb/core/urb.c:411`. This is a `dev_WARN_ONCE`. Thankfully, in production builds, this only prints a warning and then continues, returning `-EBADR`. So, it's not a kernel panic, thankfully.
It doesn't seem to cause a denial-of-service, it just means the device isn't initialized correctly - it won't be able to receive IR codes. However, I noticed that `igorplugusb_probe` actually calls `igorplugusb_cmd(ir, SET_INFRABUFFER_EMPTY)`. This call also returns `-EBADR`, but `igorplugusb_cmd` ignores the return value, just printing an error. The probe function then returns 0 (success). So the device registers successfully even though the URB submissions will always fail because of this - meaning the device *appears* functional, but it's not.
I checked for resource leaks, and it appears there aren't any. `igorplugusb_probe` succeeds, so the driver tracks the resources, and they'll be freed on disconnect. The only other thing I noted is that `igorplugusb_timer` is set up during `probe` but not started. I'll need to figure out where that timer is started to fully understand the flow.
|
| 27/2 |
2026/05/26 12:13 |
tool |
codesearch-find-references |
0m
Error:
Args: map[ContextFile:drivers/media/rc/igorplugusb.c IncludeSnippetLines:0 Name:timer]
Results: map[References:<nil> TruncatedOutput:false]
|
| 28/2 |
2026/05/26 12:13 |
llm |
expert |
0m
Model:
Tokens:
input: 38047
output: 19
thoughts: 11
Thoughts: Okay, here's my attempt at summarizing that thought process, tailored for an expert audience:
**Analyzing the `ir->timer` Context**
Alright, so the first thing that jumps into my mind is to zero in on any references to `ir->timer`. This immediately tells me we're dealing with interrupt request (ir) and a timer, which suggests we are interacting with hardware timers. Given my expertise, my mental database starts to churn, looking for potential areas that use this construct: Is this in the kernel? User space? A device driver? What architecture are we dealing with? Is this related to scheduling, real-time operation, or perhaps power management? Is `ir` an interrupt request structure or something else?
I need more context, because `ir->timer` could be used in a myriad of ways depending on the operating system and hardware platform. I'm going to start mentally tracing the code paths where `ir` is used, and more specifically, where its `timer` member might be accessed. I will be looking for places where itβs initialized, updated, or read. Any associated function calls will be of significant interest and I'll make a note of any data structures involved. Time to dive into the codebase.
|
| 29/2 |
2026/05/26 12:13 |
tool |
grepper |
0m
Args: map[Expression:timer.*igorplugusb]
Results: map[Output:drivers/media/rc/igorplugusb.c=139=static int igorplugusb_probe(struct usb_interface *intf,
--
drivers/media/rc/igorplugusb.c-172-
drivers/media/rc/igorplugusb.c:173: timer_setup(&ir->timer, igorplugusb_timer, 0);
drivers/media/rc/igorplugusb.c-174-
]
|
| 30/2 |
2026/05/26 12:13 |
llm |
expert |
0m
Model:
Tokens:
input: 38453
output: 45
thoughts: 11
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:
**Investigating the `igorplugusb_callback` Function**
Alright, time to dive in. My immediate thought is, "Let's check `igorplugusb_callback`." That name alone suggests it's a critical piece, likely handling events or data flow related to the USB interface and, specifically, probably something related to IgorPlugUSB itself. I need to understand its role in the larger system. I'm going to start by tracing the calls to this function, looking for the input parameters, and what it does with them. I'll need to identify the data structures that it operates on or that it interacts with. Is it thread-safe? Does it handle interrupts? Is it related to the I/O system, or does it interface directly with the device driver? These are the initial questions that are immediately floating in my mind. The answers to those questions will give me a better understanding of the code and how it could potentially be used. Iβm thinking, could this be a bottleneck? Or maybe a potential point of failure? I need to get the bottom of this.
|
| 31/2 |
2026/05/26 12:13 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/media/rc/igorplugusb.c IncludeLines:true Name:igorplugusb_callback]
Results: map[SourceCode: 94: static void igorplugusb_callback(struct urb *urb)
95: {
96: struct usb_ctrlrequest *req;
97: struct igorplugusb *ir = urb->context;
98:
99: req = (struct usb_ctrlrequest *)urb->setup_packet;
100:
101: switch (urb->status) {
102: case 0:
103: if (req->bRequest == GET_INFRACODE &&
104: urb->actual_length > HEADERLEN)
105: igorplugusb_irdata(ir, urb->actual_length);
106: else /* request IR */
107: mod_timer(&ir->timer, jiffies + msecs_to_jiffies(50));
108: break;
109: case -EPROTO:
110: case -ECONNRESET:
111: case -ENOENT:
112: case -ESHUTDOWN:
113: return;
114: default:
115: dev_warn(ir->dev, "Error: urb status = %d\n", urb->status);
116: igorplugusb_cmd(ir, SET_INFRABUFFER_EMPTY);
117: break;
118: }
119: }
SourceFile:drivers/media/rc/igorplugusb.c]
|
| 32/2 |
2026/05/26 12:13 |
llm |
expert |
0m
Model:
Tokens:
input: 39171
output: 45
thoughts: 93
Thoughts: Okay, here's my breakdown of this.
**Debugging a USB Driver Failure**
Right, so `usb_submit_urb` is failing. That's the core of the problem. That means the intended asynchronous callback, `igorplugusb_callback`, is never executed. And because of that, the associated timer is never initiated either. The device is effectively stuck in a holding pattern, doing absolutely nothing useful. I need to figure out *why* `usb_submit_urb` is failing. Is the URB malformed? Are resources unavailable? Is there a driver issue?
Let me thinkβ¦is there any other *path* to trigger the timer functionality? If not, my focus needs to be on why this submission is going wrong. Ah, wait, this is all happening during the `igorplugusb_probe` function. That's the function called when a USB device matching this driver gets plugged in. So the bug is in the device probe routine...and the driver is, obviously, `igorplugusb`. And the driver is matching specific USB IDs, which means it knows the specific device. I need to look closer at what conditions are not met to allow `usb_submit_urb` to execute successfully. I suspect the issue is in the `igorplugusb_probe` routine.
|
| 33/2 |
2026/05/26 12:13 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/media/rc/igorplugusb.c IncludeLines:true Name:igorplugusb_table]
Results: map[SourceCode: 255: static const struct usb_device_id igorplugusb_table[] = {
256: /* Igor Plug USB (Atmel's Manufact. ID) */
257: { USB_DEVICE(0x03eb, 0x0002) },
258: /* Fit PC2 Infrared Adapter */
259: { USB_DEVICE(0x03eb, 0x21fe) },
260: /* Terminating entry */
261: { }
262: };
SourceFile:drivers/media/rc/igorplugusb.c]
|
| 34/2 |
2026/05/26 12:13 |
llm |
expert |
0m
Model:
Tokens:
input: 39756
output: 39
thoughts: 643
Thoughts: **Analyzing a USB Warning**
Okay, so I've been looking at this USB device with `idVendor=0x03eb` and `idProduct=0x0002` or `0x21fe`. Plugging it in triggers `igorplugusb_probe`, which in turn leads to a warning in `usb_submit_urb`. The warning is a `dev_WARN_ONCE`, which, as we know, doesn't crash the kernel in production unless `panic_on_warn` is set β and that's usually not the case. So, no denial-of-service, good.
But is it exploitable? It just returns `-EBADR` and fails to submit the URB. No pointer leakage either, since the URB is rejected before going to the host controller.
Now, let's think about this `wLength` and `transfer_buffer_length` pairing. `transfer_buffer_length` is `MAX_PACKET`, which is 39. `wLength` is pulled from the 5th and 6th bytes of `ir->request`. On a 64-bit kernel, kernel pointers are usually something like `0xffff8880` or `0xffffc900`. So, the 5th and 6th bytes would be `0x8880` or `0xc900` or `0xffff`. None of those are 39.
However... what about a 32-bit kernel? On a 32-bit system, pointers are only 4 bytes. And the `setup_packet` is still 8 bytes. If `ir->request` is a 32-bit pointer, `&ir->request` would point to the 4-byte value itself.
Wait, `&ir->request` is the address of the `request` field in `struct igorplugusb`. What does that structure look like again? Ah yes:
```c
struct igorplugusb {
struct rc_dev *rc;
struct device *dev;
struct urb *urb;
struct usb_ctrlrequest *request;
struct timer_list timer;
u8 *buf_in;
char phys[64];
};
```
On a 32-bit system, `request` would be at offset 12. The `setup_packet` would then read 8 bytes, starting from the address of `request`. So, it'll read the `request` pointer (4 bytes) and then the first 4 bytes of `timer`. Now, `wLength` is those first 2 bytes from `timer`. The `timer` is initialized with `timer_setup(&ir->timer, igorplugusb_timer, 0);`. So the contents of those bytes in the timer are the keys. Now I need to see the layout of `struct timer_list` to see if that leads somewhere interesting.
|
| 35/2 |
2026/05/26 12:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/linux/timer.h IncludeLines:true Name:timer_list]
Results: map[SourceCode: 8: struct timer_list {
9: /*
10: * All fields that change during normal runtime grouped to the
11: * same cacheline
12: */
13: struct hlist_node entry;
14: unsigned long expires;
15: void (*function)(struct timer_list *);
16: u32 flags;
17:
18: #ifdef CONFIG_LOCKDEP
19: struct lockdep_map lockdep_map;
20: #endif
21: };
SourceFile:include/linux/timer_types.h]
|
| 36/2 |
2026/05/26 12:14 |
llm |
expert |
0m
Model:
Tokens:
input: 41266
output: 39
thoughts: 148
Thoughts: **Analyzing the Timer List Structure**
Okay, so I'm looking at the `struct timer_list` definition. The first field, as always, is this `struct hlist_node entry`. Right, and that `hlist_node` is defined with `next` and `pprev` pointers, the usual suspects for a doubly-linked list, or in this case a hashed list, which is essentially what `hlist_node` is.
Now, I'm trying to recall how this `entry` field gets initialized. My initial thought was that it would be set during the `timer_setup` call, maybe setting `entry.next` to `NULL` or even that `LIST_POISON1` value as an initial default. But, hang on... no, that's not quite right. After a bit more thought, I'm pretty sure `timer_setup` doesn't actually initialize `entry` itself. Looking deeper I see that `timer_setup` calls `__init_timer`, which sets `entry.next = NULL` and `entry.pprev = NULL`. Wait, I was right the first time. The `entry` field *isn't* directly initialized in `timer_setup`, because that field is only relevant when the timer is actually enqueued on a list. So, it's not initialized at setup time. Okay, I'm going to quickly verify that using the code.
|
| 37/2 |
2026/05/26 12:14 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:include/linux/timer.h IncludeLines:true Name:timer_setup]
Results: map[SourceCode: SourceFile:]
|
| 38/2 |
2026/05/26 12:14 |
llm |
expert |
0m
Model:
Tokens:
input: 41777
output: 18
thoughts: 10
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Initial Assessment: Grep Time!**
Alright, so the initial thought is pretty straightforward: I need to find something related to `timer_setup`. This is likely a debugging or investigation phase. `grep` is my go-to tool when I'm quickly trying to locate specific function names, macros, or even just string occurrences within a codebase. The focus here is efficiency; I need to quickly identify where `timer_setup` is defined, used, or modified. My expectation is that this function, based on its name, is part of a timer management system, likely dealing with interrupt configurations, timeout handling, or something similar. Depending on the size of the codebase, the search could return a handful of results or hundreds. The next step will be to filter and analyze the output to determine the context.
|
| 39/2 |
2026/05/26 12:14 |
tool |
grepper |
0m
Args: map[Expression:define timer_setup]
Results: map[Output:include/linux/timer.h=80=static inline void timer_init_key_on_stack(struct timer_list *timer,
--
include/linux/timer.h-119- */
include/linux/timer.h:120:#define timer_setup(timer, callback, flags) \
include/linux/timer.h-121- __timer_init((timer), (callback), (flags))
include/linux/timer.h-122-
include/linux/timer.h:123:#define timer_setup_on_stack(timer, callback, flags) \
include/linux/timer.h-124- __timer_init_on_stack((timer), (callback), (flags))
]
|
| 40/2 |
2026/05/26 12:14 |
llm |
expert |
0m
Model:
Tokens:
input: 42185
output: 40
thoughts: 10
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:
**Investigating `__timer_init`**
Alright, time to dig in. The system is behaving in an unexpected manner and my instinct is screaming "timing!" So, let's start with `__timer_init`. Itβs the obvious first stop. It's the cornerstone of the timer system, so a problem here would cascade everywhere. Gotta confirm this is set up as I would expect it to be. Is the hardware being configured correctly? Are the interrupt vectors pointing to the right place? I need to quickly run through the initialization sequence. I'm going to quickly check for any obvious red flags in there, looking for any silly mistakes or misconfigurations.
|
| 41/2 |
2026/05/26 12:14 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:include/linux/timer.h IncludeLines:true Name:__timer_init]
Results: map[SourceCode: SourceFile:]
|
| 42/2 |
2026/05/26 12:14 |
llm |
expert |
0m
Model:
Tokens:
input: 42421
output: 18
thoughts: 11
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:
**Investigating Initialization Routines**
Right, let's dive in. I need to understand how this timer functionality is being set up. My immediate instinct is to start digging into the initialization routines. The quickest way to do that in a codebase like this is usually to go straight for the jugular β a well-chosen search term. I'm going to leverage `grep` β that's the tool for this kind of quick, dirty, but often effective search. The key I'm going to start with is `__timer_init`. This looks like a reasonable candidate for a function or macro name related to timer initialization, likely from a kernel or embedded system perspective, given the double underscores. That double underscore is a strong hint that it's probably not a public API function that is supposed to be exposed to userspace. If it hits, it will get me right to the critical setup code, or at least a good starting point for tracing the initialization process. Now let's see what `grep` turns up...
|
| 43/2 |
2026/05/26 12:14 |
tool |
grepper |
0m
Args: map[Expression:__timer_init]
Results: map[Output:include/linux/timer.h=80=static inline void timer_init_key_on_stack(struct timer_list *timer,
--
include/linux/timer.h-90-#ifdef CONFIG_LOCKDEP
include/linux/timer.h:91:#define __timer_init(_timer, _fn, _flags) \
include/linux/timer.h-92- do { \
--
include/linux/timer.h-96-
include/linux/timer.h:97:#define __timer_init_on_stack(_timer, _fn, _flags) \
include/linux/timer.h-98- do { \
--
include/linux/timer.h-103-#else
include/linux/timer.h:104:#define __timer_init(_timer, _fn, _flags) \
include/linux/timer.h-105- timer_init_key((_timer), (_fn), (_flags), NULL, NULL)
include/linux/timer.h:106:#define __timer_init_on_stack(_timer, _fn, _flags) \
include/linux/timer.h-107- timer_init_key_on_stack((_timer), (_fn), (_flags), NULL, NULL)
--
include/linux/timer.h-120-#define timer_setup(timer, callback, flags) \
include/linux/timer.h:121: __timer_init((timer), (callback), (flags))
include/linux/timer.h-122-
include/linux/timer.h-123-#define timer_setup_on_stack(timer, callback, flags) \
include/linux/timer.h:124: __timer_init_on_stack((timer), (callback), (flags))
include/linux/timer.h-125-
--
include/linux/workqueue.h=273=static inline unsigned int work_static(struct work_struct *work) { return 0; }
--
include/linux/workqueue.h-320- INIT_WORK(&(_work)->work, (_func)); \
include/linux/workqueue.h:321: __timer_init(&(_work)->timer, \
include/linux/workqueue.h-322- delayed_work_timer_fn, \
--
include/linux/workqueue.h-328- INIT_WORK_ONSTACK(&(_work)->work, (_func)); \
include/linux/workqueue.h:329: __timer_init_on_stack(&(_work)->timer, \
include/linux/workqueue.h-330- delayed_work_timer_fn, \
]
|
| 44/2 |
2026/05/26 12:14 |
llm |
expert |
1m
Model:
Tokens:
input: 43365
output: 41
thoughts: 11
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, and delivered as a first-person summary:
**Digging into `timer_init_key`**
Right, let's dive into this `timer_init_key` thing. My immediate thought process is: I need to quickly establish *what* this key actually *is* and *where* it's used. Is this some kind of critical identifier for timer initialization within a specific framework, or is it related to a more general concept of timer management across a system? I need to understand its scope. My focus will be on quickly finding the call sites. I will be looking for context to see what kind of operations are being done with the key and what the implications of its usage are. What is being initialized? What data structures, if any, are dependent on it? And, what will break if it goes wrong?
|
| 45/2 |
2026/05/26 12:15 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/linux/timer.h IncludeLines:true Name:timer_init_key]
Results: map[SourceCode: 864: /**
865: * timer_init_key - initialize a timer
866: * @timer: the timer to be initialized
867: * @func: timer callback function
868: * @flags: timer flags
869: * @name: name of the timer
870: * @key: lockdep class key of the fake lock used for tracking timer
871: * sync lock dependencies
872: *
873: * timer_init_key() must be done to a timer prior to calling *any* of the
874: * other timer functions.
875: */
876: void timer_init_key(struct timer_list *timer,
877: void (*func)(struct timer_list *), unsigned int flags,
878: const char *name, struct lock_class_key *key)
879: {
880: debug_init(timer);
881: do_init_timer(timer, func, flags, name, key);
882: }
SourceFile:kernel/time/timer.c]
|
| 46/2 |
2026/05/26 12:15 |
llm |
expert |
0m
Model:
Tokens:
input: 43928
output: 41
thoughts: 11
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:
**Diving into `do_init_timer`**
Alright, time to dig into this `do_init_timer` function. I see it mentioned in the context of [mention the relevant context or project if it's clear]. My immediate thought is to understand its role in the overall timing architecture. Is this a core initialization routine for the system timer, or a specific timer type? I need to quickly establish its scope and purpose. Are we dealing with hardware registers directly, or is there an abstraction layer involved? Any pre-existing documentation or comments on this function would be greatly appreciated. I'll be looking for potential race conditions, edge cases, and of course any assumptions this function makes about the hardware or the operating environment. A quick scan will give me a base understanding. Let's see what's what.
|
| 47/2 |
2026/05/26 12:15 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/timer.c IncludeLines:true Name:do_init_timer]
Results: map[SourceCode: 851: static void do_init_timer(struct timer_list *timer,
852: void (*func)(struct timer_list *),
853: unsigned int flags,
854: const char *name, struct lock_class_key *key)
855: {
856: timer->entry.pprev = NULL;
857: timer->function = func;
858: if (WARN_ON_ONCE(flags & ~TIMER_INIT_FLAGS))
859: flags &= TIMER_INIT_FLAGS;
860: timer->flags = flags | raw_smp_processor_id();
861: lockdep_init_map(&timer->lockdep_map, name, key, 0);
862: }
SourceFile:kernel/time/timer.c]
|
| 48/2 |
2026/05/26 12:15 |
llm |
expert |
0m
Model:
Tokens:
input: 44416
output: 43
thoughts: 1822
Thoughts: **Analysis of the USB Driver Bug**
Okay, let's break this down systematically. The initial observation is about `timer->entry.pprev = NULL;` and a potential initialization issue related to `timer->entry.next`. However, `timer` is part of `struct igorplugusb`, allocated with `devm_kzalloc`, so this resolves to zeros. That's fine; `timer->entry` is initialized to all zeroes.
Then comes the critical part. We're reading `setup_packet` data, but there's an issue with how it is being read. The code's using `(uint8_t *)&ir->request` where it should be using `(uint8_t *)ir->request`. On a 32-bit system, the `setup_packet` pointer is pointing to the start of `ir->request`, a pointer to a `struct usb_ctrlrequest`, and is thus reading the data for the setup packet from the pointer value itself, rather than the `struct usb_ctrlrequest` the pointer is meant to point at.
On 64-bit, we are essentially reading 8 bytes of garbage.
This means `wLength` from the control request is being set to 0. With `urb->transfer_buffer_length` set to 39, the check `le16_to_cpu(setup->wLength) != urb->transfer_buffer_length` will always be true and the URB gets rejected.
Crucially, the URB is never submitted because of the invalid `wLength` value. This means a pointer is NEVER leaked.
The next question: what if `urb->transfer_buffer_length` is 0? The code inside `igorplugusb_probe` sets `urb->transfer_buffer_length` to `MAX_PACKET` (39) when calling `usb_fill_control_urb`. So `wLength` should be 39. So the code still has a problem. `wLength` is always being read from garbage because of the bug.
Now, could there be an exploit? No. It's just a non-functional driver. The code is reading a pointer address as control setup, it will never match the requested length or type. The key issue is a typo: the incorrect casting of the `ir->request` field to `uint8_t *`.
The analysis considers the case of a 64-bit system. `ir->request` is allocated via `kzalloc_obj`, which allocates in the direct mapping space. This means bytes 6 and 7 of the pointer address would always be `0xffff`, resulting in `wLength` being 65535, which doesn't match the expected 39. So the URB is NEVER submitted in this case either.
I'm confirming there's NO memory corruption, NO information leak, and NO denial of service (other than a non-functioning driver).
The bug report mentions the error "BOGUS control dir" from `usb_submit_urb`, resulting in a warning message. In syzkaller, this is treated as a crash due to `panic_on_warn` but is not a crash in production. So it's not a denial of service in a standard production environment.
Let's do a quick audit of `igorplugusb_probe`. Is there any other issues? The use of `kzalloc_obj` looks right; it's correctly allocating the size of the `struct usb_ctrlrequest`.
The use of `(uint8_t *)&ir->request` is the crucial bug. The correct cast is `(uint8_t *)ir->request`. This is a pointer to a pointer bug. This is exactly what we analyzed.
Finally, what happens during failure? At the `fail:` label, URBs are unpoisoned, timers deleted, URBs freed, and memory freed. I don't see any immediate issues from this cleanup path, even if `ir->urb` is `NULL`.
So, it's just this bug that is the issue. Nothing else is wrong!
|
| 49/2 |
2026/05/26 12:15 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/core/urb.c IncludeLines:true Name:usb_poison_urb]
Results: map[SourceCode: 723: /**
724: * usb_poison_urb - reliably kill a transfer and prevent further use of an URB
725: * @urb: pointer to URB describing a previously submitted request,
726: * may be NULL
727: *
728: * This routine cancels an in-progress request. It is guaranteed that
729: * upon return all completion handlers will have finished and the URB
730: * will be totally idle and cannot be reused. These features make
731: * this an ideal way to stop I/O in a disconnect() callback.
732: * If the request has not already finished or been unlinked
733: * the completion handler will see urb->status == -ENOENT.
734: *
735: * After and while the routine runs, attempts to resubmit the URB will fail
736: * with error -EPERM. Thus even if the URB's completion handler always
737: * tries to resubmit, it will not succeed and the URB will become idle.
738: *
739: * The URB must not be deallocated while this routine is running. In
740: * particular, when a driver calls this routine, it must insure that the
741: * completion handler cannot deallocate the URB.
742: *
743: * This routine may not be used in an interrupt context (such as a bottom
744: * half or a completion handler), or when holding a spinlock, or in other
745: * situations where the caller can't schedule().
746: *
747: * This routine should not be called by a driver after its disconnect
748: * method has returned.
749: */
750: void usb_poison_urb(struct urb *urb)
751: {
752: might_sleep();
753: if (!urb)
754: return;
755: atomic_inc(&urb->reject);
756: /*
757: * Order the write of urb->reject above before the read
758: * of urb->use_count below. Pairs with the barriers in
759: * __usb_hcd_giveback_urb() and usb_hcd_submit_urb().
760: */
761: smp_mb__after_atomic();
762:
763: if (!urb->dev || !urb->ep)
764: return;
765:
766: usb_hcd_unlink_urb(urb, -ENOENT);
767: wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
768: }
SourceFile:drivers/usb/core/urb.c]
|
| 50/2 |
2026/05/26 12:15 |
llm |
expert |
0m
Model:
Tokens:
input: 47950
output: 44
thoughts: 217
Thoughts: **Analyzing the USB Driver Code**
Okay, let's break this down. First, `usb_poison_urb(NULL)` β that's definitely safe; no issues there. And `timer_delete(&ir->timer)`? Seems safe too... assuming `timer_setup` has been called prior. Aha! Let me double-check... Yes! `timer_setup` *is* called *before* the `ir->urb` allocation. Good.
```c
timer_setup(&ir->timer, igorplugusb_timer, 0);
ir->request->bRequest = GET_INFRACODE;
ir->request->bRequestType = USB_TYPE_VENDOR | USB_DIR_IN;
ir->request->wLength = cpu_to_le16(MAX_PACKET);
ir->urb = usb_alloc_urb(0, GFP_KERNEL);
if (!ir->urb)
goto fail;
```
So, the timer is set up first, then the USB request is constructed, and finally, we allocate the URB. Now, if the `usb_alloc_urb` fails, we jump to `fail:`. In that `fail:` block, `timer_delete(&ir->timer)` is called. That's still safe, because `timer_setup` *was* definitely called. Now, where was I... yes, `usb_unpoison_urb(NULL)`... is *that* safe? I'll need to check the exact conditions again but, at first glance, I believe it's safe.
|
| 51/2 |
2026/05/26 12:15 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/core/urb.c IncludeLines:true Name:usb_unpoison_urb]
Results: map[SourceCode: 771: void usb_unpoison_urb(struct urb *urb)
772: {
773: if (!urb)
774: return;
775:
776: atomic_dec(&urb->reject);
777: }
SourceFile:drivers/usb/core/urb.c]
|
| 52/2 |
2026/05/26 12:15 |
llm |
expert |
0m
Model:
Tokens:
input: 48665
output: 45
thoughts: 251
Thoughts: **My Analysis of Resource Cleanup**
Okay, so I'm walking through this cleanup logic, making sure we haven't introduced any vulnerabilities or memory leaks. Let's see: `usb_free_urb(NULL)` is safe, no issues there. Same with `rc_free_device(NULL)`, and freeing `ir->buf_in` and `ir->request` using `kfree` β that all looks clean.
Hmm, but what about allocation failures? I see `rc_allocate_device` being called, and if it fails, we `goto fail;`. Inside `fail:`, the code calls `rc_free_device(NULL)`. That's good, handles a null pointer, so that's safe.
Now, hold on. What if `rc_register_device` fails? It also jumps to `fail:`. In that case, the code calls `rc_free_device(ir->rc)`. But... does `rc_register_device` itself potentially free `rc` on failure? We *have* to check that function's implementation. If `rc_register_device` frees the device on a register failure, then we'd be trying to free something already freed, which could be very bad. Let me go look at `rc_register_device`.
|
| 53/2 |
2026/05/26 12:16 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/media/rc/rc-main.c IncludeLines:true Name:rc_register_device]
Results: map[SourceCode:1891: int rc_register_device(struct rc_dev *dev)
1892: {
1893: const char *path;
1894: int attr = 0;
1895: int minor;
1896: int rc;
1897:
1898: if (!dev)
1899: return -EINVAL;
1900:
1901: minor = ida_alloc_max(&rc_ida, RC_DEV_MAX - 1, GFP_KERNEL);
1902: if (minor < 0)
1903: return minor;
1904:
1905: dev->minor = minor;
1906: dev_set_name(&dev->dev, "rc%u", dev->minor);
1907: dev_set_drvdata(&dev->dev, dev);
1908:
1909: dev->dev.groups = dev->sysfs_groups;
1910: if (dev->driver_type == RC_DRIVER_SCANCODE && !dev->change_protocol)
1911: dev->sysfs_groups[attr++] = &rc_dev_ro_protocol_attr_grp;
1912: else if (dev->driver_type != RC_DRIVER_IR_RAW_TX)
1913: dev->sysfs_groups[attr++] = &rc_dev_rw_protocol_attr_grp;
1914: if (dev->s_filter)
1915: dev->sysfs_groups[attr++] = &rc_dev_filter_attr_grp;
1916: if (dev->s_wakeup_filter)
1917: dev->sysfs_groups[attr++] = &rc_dev_wakeup_filter_attr_grp;
1918: dev->sysfs_groups[attr++] = NULL;
1919:
1920: if (dev->driver_type == RC_DRIVER_IR_RAW) {
1921: rc = ir_raw_event_prepare(dev);
1922: if (rc < 0)
1923: goto out_minor;
1924: }
1925:
1926: if (dev->driver_type != RC_DRIVER_IR_RAW_TX) {
1927: rc = rc_prepare_rx_device(dev);
1928: if (rc)
1929: goto out_raw;
1930: }
1931:
1932: dev->registered = true;
1933:
1934: rc = device_add(&dev->dev);
1935: if (rc)
1936: goto out_rx_free;
1937:
1938: path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
1939: dev_info(&dev->dev, "%s as %s\n",
1940: dev->device_name ?: "Unspecified device", path ?: "N/A");
1941: kfree(path);
1942:
1943: /*
1944: * once the input device is registered in rc_setup_rx_device,
1945: * userspace can open the input device and rc_open() will be called
1946: * as a result. This results in driver code being allowed to submit
1947: * keycodes with rc_keydown, so lirc must be registered first.
1948: */
1949: if (dev->allowed_protocols != RC_PROTO_BIT_CEC) {
1950: rc = lirc_register(dev);
1951: if (rc < 0)
1952: goto out_dev;
1953: }
1954:
1955: if (dev->driver_type != RC_DRIVER_IR_RAW_TX) {
1956: rc = rc_setup_rx_device(dev);
1957: if (rc)
1958: goto out_lirc;
1959: }
1960:
1961: if (dev->driver_type == RC_DRIVER_IR_RAW) {
1962: rc = ir_raw_event_register(dev);
1963: if (rc < 0)
1964: goto out_rx;
1965: }
1966:
1967: dev_dbg(&dev->dev, "Registered rc%u (driver: %s)\n", dev->minor,
1968: dev->driver_name ? dev->driver_name : "unknown");
1969:
1970: return 0;
1971:
1972: out_rx:
1973: rc_free_rx_device(dev);
1974: out_lirc:
1975: if (dev->allowed_protocols != RC_PROTO_BIT_CEC)
1976: lirc_unregister(dev);
1977: out_dev:
1978: device_del(&dev->dev);
1979: out_rx_free:
1980: ir_free_table(&dev->rc_map);
1981: out_raw:
1982: ir_raw_event_free(dev);
1983: out_minor:
1984: ida_free(&rc_ida, minor);
1985: return rc;
1986: }
SourceFile:drivers/media/rc/rc-main.c]
|
| 54/2 |
2026/05/26 12:16 |
llm |
expert |
0m
Model:
Tokens:
input: 50738
output: 45
thoughts: 57
Thoughts: Here's my summary, as the expert:
**Understanding Device Registration and Cleanup**
Okay, so I'm digging into this `rc_register_device` function and it's clear: it *doesn't* free the `dev` pointer on a failure. It just handles its own internal allocations and cleans those up. Good. That's important to remember.
So, the `rc_free_device(ir->rc)` call in the `fail:` section is indeed the correct way to handle deallocation in this context. Makes perfect sense given the design.
Hold on... I need to consider `igorplugusb_disconnect` though. Where does that fit in? I have to look more closely and determine if there are dependencies or overlapping responsibilities regarding this `dev` pointer. Gotta be sure we're not double-freeing or leaking memory here. Back to the code!
|
| 55/2 |
2026/05/26 12:16 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/media/rc/igorplugusb.c IncludeLines:true Name:igorplugusb_disconnect]
Results: map[SourceCode: 240: static void igorplugusb_disconnect(struct usb_interface *intf)
241: {
242: struct igorplugusb *ir = usb_get_intfdata(intf);
243:
244: rc_unregister_device(ir->rc);
245: usb_poison_urb(ir->urb);
246: timer_delete_sync(&ir->timer);
247: usb_set_intfdata(intf, NULL);
248: usb_unpoison_urb(ir->urb);
249: usb_free_urb(ir->urb);
250: rc_free_device(ir->rc);
251: kfree(ir->buf_in);
252: kfree(ir->request);
253: }
SourceFile:drivers/media/rc/igorplugusb.c]
|
| 56/2 |
2026/05/26 12:16 |
llm |
expert |
0m
Model:
Tokens:
input: 51287
output: 45
thoughts: 25
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Unraveling the Device Unregistration**
Okay, hold on a second... `rc_unregister_device` is the function responsible for *freeing* the device itself, isn't it? That's a critical detail that needs immediate verification. I need to drill down and examine the implementation of `rc_unregister_device` right now. I'm going to carefully review the code to confirm that my initial assumption is correct, because if it frees it, that will change the assumptions of how to use it!
|
| 57/2 |
2026/05/26 12:16 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/media/rc/rc-main.c IncludeLines:true Name:rc_unregister_device]
Results: map[SourceCode:2016: void rc_unregister_device(struct rc_dev *dev)
2017: {
2018: if (!dev)
2019: return;
2020:
2021: if (dev->driver_type == RC_DRIVER_IR_RAW)
2022: ir_raw_event_unregister(dev);
2023:
2024: timer_delete_sync(&dev->timer_keyup);
2025: timer_delete_sync(&dev->timer_repeat);
2026:
2027: mutex_lock(&dev->lock);
2028: if (dev->users && dev->close)
2029: dev->close(dev);
2030: dev->registered = false;
2031: mutex_unlock(&dev->lock);
2032:
2033: rc_free_rx_device(dev);
2034:
2035: /*
2036: * lirc device should be freed with dev->registered = false, so
2037: * that userspace polling will get notified.
2038: */
2039: if (dev->allowed_protocols != RC_PROTO_BIT_CEC)
2040: lirc_unregister(dev);
2041:
2042: device_del(&dev->dev);
2043:
2044: ida_free(&rc_ida, dev->minor);
2045: }
SourceFile:drivers/media/rc/rc-main.c]
|
| 58/2 |
2026/05/26 12:16 |
llm |
expert |
0m
Model:
Tokens:
input: 51917
output: 45
thoughts: 39
Thoughts: Here's my take on the situation:
**Device Registration and Deregistration in the RC Subsystem**
Okay, so I'm looking at how devices are handled during registration and deregistration in the RC (Remote Control) subsystem. It looks like `rc_unregister_device` is calling `device_del`. That makes sense; we want to remove the device from the system's device tree. However, it *doesn't* appear to be calling `put_device`. Now, that's a key point, and it immediately raises a flag.
Hold on... I need to see what's happening with `put_device`, since we definitely *need* to decrement that reference count at some point. Ah, there it is! `rc_free_device` does call `put_device`. That likely means that `rc_free_device` is the final step in the device's lifecycle in this subsystem.
Good, it appears this code is managing the reference counts correctly, just across two function calls instead of one. Now I need to consider why they are split, to avoid any race conditions.
|
| 59/2 |
2026/05/26 12:16 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/media/rc/rc-main.c IncludeLines:true Name:rc_free_device]
Results: map[SourceCode:1740: void rc_free_device(struct rc_dev *dev)
1741: {
1742: if (!dev)
1743: return;
1744:
1745: input_free_device(dev->input_dev);
1746:
1747: put_device(&dev->dev);
1748:
1749: /* kfree(dev) will be called by the callback function
1750: rc_dev_release() */
1751:
1752: module_put(THIS_MODULE);
1753: }
SourceFile:drivers/media/rc/rc-main.c]
|
| 60/2 |
2026/05/26 12:16 |
llm |
expert |
0m
Model:
Tokens:
input: 52441
output: 66
thoughts: 2523
Thoughts: **My Analysis of the USB Driver Bug**
Okay, let me walk through this. It looks like the core issue boils down to a single typo in how a USB control transfer is set up. Let's see... the `rc_unregister_device` and `rc_free_device` calls appear in the correct order, ensuring the device is properly managed during disconnect. The use of `devm_kzalloc` to allocate `ir` guarantees it's freed on device unbind, and the timer handling with `timer_delete_sync` seems robust against race conditions. Specifically, `usb_poison_urb` and `timer_delete_sync` work in concert to prevent timer-related issues during disconnect. Good.
The problem, as I see it, centers on this: a typo. Instead of referencing the `request` buffer itself, the code accidentally passes the *address* of that buffer to `usb_submit_urb`. This causes `usb_submit_urb` to interpret the *pointer* value as the setup packet, which causes a mismatch between what's expected in `wLength` and `bRequestType` and what's actually there. Specifically, `wLength` is taken from the address pointer, not the intended value. Given that pointers are allocated from memory, `wLength` will never actually match the intended transfer length (39 bytes). This always leads to `usb_submit_urb` rejecting the URB.
Okay, let me back up a minute to double-check that conclusion. On x86_64, pointers allocated in the direct mapping region will have `wLength` set to `0xffff`. This makes the mismatch inevitable. It looks like it is the same on ARM64 as well. On 32-bit architectures, `wLength` becomes zero, which still doesn't match the required 39. So it's a guaranteed failure across all architectures.
So the bug, in essence, makes the driver non-functional, printing a warning message, but it does NOT cause memory corruption or a denial-of-service condition. The syzkaller report confirms this β the warning is the key symptom. The warning, specifically, indicates that the `bRequestType` is wrong. Since the first byte of `ir->request` is being misinterpreted as `bRequestType` this makes sense.
Given the analysis, and that there are no other uses of `ir->request`, the only issue is the driver becoming unusable because of the invalid request being sent.
The `syz_usb_connect` reproducer simply emulates the USB device connection, triggering the buggy code path within `igorplugusb_probe`. The result is a warning.
Thus, the bug is not exploitable, does not pose a denial-of-service risk, and cannot be triggered by unprivileged processes or user namespaces. It is purely a peripheral trigger, specifically plugging in a specific USB device. It is not a network, filesystem, VM guest, or host trigger, nor is it remotely triggered.
|
| 61/2 |
2026/05/26 12:16 |
tool |
set-results |
0m
Args: map[DenialOfService:false Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:false Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 62/2 |
2026/05/26 12:16 |
llm |
expert |
0m
Model:
Tokens:
input: 55734
output: 694
thoughts: 423
Thoughts: **My Assessment of the Bug**
Okay, the analysis is done, and it's pretty clear what's going on. Time to put this into words. This bug boils down to a simple typo in `igorplugusb_probe`. We're passing the *address* of `ir->request` to `usb_fill_control_urb` when we should be passing `ir->request` itself. This means we're providing the USB core with the memory location of the pointer, instead of the structure it points to.
Specifically, we're giving it the 8 bytes of the pointer to interpret as the USB setup packet. And since `ir->request` is a `struct usb_ctrlrequest` allocated with `kzalloc`, we know what this pointer's address holds: we're going to get some weird behavior.
When `usb_submit_urb` gets called, it validates this "setup packet." The first byte, which ends up being the least significant byte of the pointer value on a little-endian system, is incorrectly read as `bRequestType`. Since this byte *probably* won't have the `USB_DIR_IN` bit (0x80) set, the system prints a "BOGUS control dir" warning because we set up an IN pipe.
The fun doesn't stop there. Bytes 6 and 7 of the pointer get misinterpreted as `wLength`. On a 64-bit kernel, that's going to be a large value, like `0xffff`. The system compares this misread length (65535) against `urb->transfer_buffer_length` (which is 39). Obviously, there's no match. This leads to `usb_submit_urb` returning `-EBADR` and rejecting the URB entirely.
The good news? The URB is rejected *before* ever touching the USB host controller, so we're not leaking any kernel pointers to the device. So, the impact is limited. Essentially, this is just a kernel warning and a driver that won't work. No memory corruption, no information leaks, and the warnings aren't critical in production, so there is no DoS either.
This bug is triggered by the presence of a USB device, or more specifically, the act of plugging one in, meaning this is a peripheral trigger. And since it's all happening within the kernel, unprivileged processes or user namespaces can't exploit it.
|
| 63/1 |
2026/05/26 12:17 |
action |
format-explanation |
0m
Results: map[Explanation:Based on the analysis of the bug report and the kernel source code, here is the
assessment of the vulnerability:
**Root Cause Analysis:**
The bug is caused by a typo in `drivers/media/rc/igorplugusb.c` within the
`igorplugusb_probe` function. When initializing the control URB, the driver
passes `(uint8_t *)&ir->request` to `usb_fill_control_urb` instead of `(uint8_t
*)ir->request`.
Because `ir->request` is a dynamically allocated pointer (`struct
usb_ctrlrequest *`), passing its address (`&ir->request`) means the USB core
will read the 8 bytes of the pointer's memory address itself and interpret it as
the USB setup packet, rather than reading the actual `usb_ctrlrequest` structure
it points to.
**Impact and Exploitability:**
When the driver attempts to submit this URB via `usb_submit_urb`, the USB core
validates the setup packet (which is now just the bytes of a kernel pointer):
1. The first byte of the pointer (the least significant byte of the address on
little-endian architectures) is interpreted as `bRequestType`. If this byte
happens to lack the `USB_DIR_IN` bit (`0x80`), `usb_submit_urb` detects a
direction mismatch with the IN pipe and prints the `BOGUS control dir` warning
seen in the crash report.
2. Bytes 6 and 7 of the pointer are interpreted as `wLength`. For a standard
64-bit kernel direct-mapping pointer (e.g., `0xffff8880...` or `0xffff0000...`),
these bytes are always `0xffff`.
3. `usb_submit_urb` strictly checks if `wLength` matches
`urb->transfer_buffer_length` (which is set to `MAX_PACKET`, i.e., 39). Since
`0xffff` (65535) will never match 39, `usb_submit_urb` immediately aborts and
returns `-EBADR` (`-53`).
Because the URB submission is reliably rejected by the USB core before it is
ever queued to the host controller, the kernel pointer is **never leaked** to
the USB device. Furthermore, the bug does not cause any memory corruption,
out-of-bounds accesses, or resource leaks. The `WARNING` generated does not halt
the kernel in production environments (where `panic_on_warn` is disabled). The
only consequence is that the driver fails to initialize the device properly.
**Trigger:**
The bug is triggered by the kernel probing a USB device that matches the
driver's supported Vendor/Product IDs (e.g., `03eb:0002`). This requires
physically plugging in a malicious/malfunctioning USB device or emulating one
(e.g., via the `dummy_hcd` and `raw-gadget` interfaces, which require root
privileges). It cannot be triggered by unprivileged users, network traffic, or
filesystem mounts.
**Conclusion:**
The bug is a functional defect resulting in a harmless warning. It is not a
security vulnerability, is not exploitable, and does not cause a Denial of
Service.]
|