| 0/0 |
2026/07/05 07:19 |
flow |
assessment-security |
39m
Results: map[DenialOfService:true Explanation:**Bug Analysis:**
The bug report indicates a `WARNING` in `__local_bh_enable_ip()` triggered by
`lockdep_assert_irqs_enabled()`.
By analyzing the stack trace and the source code, the sequence of events is as
follows:
1. The `dummy_hcd` driver (used for emulating USB devices) completes an URB by
calling `usb_hcd_giveback_urb()`. Because `dummy_hcd` does not set the `HCD_BH`
flag, the completion handler is invoked synchronously in the context of the
`dummy_timer` hrtimer, where hardware interrupts are disabled (via
`spin_lock_irqsave`).
2. The URB completion handler for the `carl9170` WiFi driver
(`carl9170_usb_rx_irq_complete()`) is executed.
3. The driver processes a TX completion response (`CARL9170_RSP_TXCOMP`) from
the device, eventually calling `carl9170_get_queued_skb()`.
4. Inside `carl9170_get_queued_skb()`, the driver uses `spin_lock_bh()` and
`spin_unlock_bh()` to protect the queue.
5. `spin_unlock_bh()` calls `__local_bh_enable_ip()`, which expects hardware
interrupts to be enabled. Since they are currently disabled by the HCD, lockdep
throws a warning.
**Security Impact:**
* **Exploitable:** **No.** This is purely an API usage violation caught by
lockdep and debug assertions. There is no memory corruption, out-of-bounds
access, or information leak.
* **Denial of Service:** **No.** In production builds (where lockdep,
`CONFIG_TRACE_IRQFLAGS`, and `panic_on_warn` are disabled), calling
`spin_unlock_bh()` with interrupts disabled is harmless. The function will
simply decrement the preempt count and skip running softirqs because
`in_interrupt()` evaluates to true. It does not inadvertently re-enable hardware
interrupts, nor does it cause a deadlock or system crash.
* **Accessible From Unprivileged Processes:** **Yes.** An unprivileged local
user can trigger this warning by simply sending network traffic (e.g., UDP
packets) over the WiFi interface, which naturally generates TX completion events
from the firmware.
* **Peripheral Trigger:** **Yes.** A malicious USB device can spoof
`CARL9170_RSP_TXCOMP` responses on the interrupt endpoint to trigger this code
path.
In summary, this is a benign lockdep warning resulting from the `carl9170`
driver using bottom-half (BH) spinlocks inside an URB completion handler that
may be called with hardware interrupts disabled (depending on the specific USB
Host Controller). It poses no security risk in production environments. Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:true Unprivileged:true UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/07/05 07:19 |
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 ATH9K_FIRMWARE_DOWNLOAD 0x30
#define ATH9K_FIRMWARE_DOWNLOAD_COMP 0x31
static bool lookup_connect_response_out_ath9k(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:
return true;
default:
break;
}
break;
case USB_TYPE_VENDOR:
switch (ctrl->bRequest) {
case ATH9K_FIRMWARE_DOWNLOAD:
return true;
case ATH9K_FIRMWARE_DOWNLOAD_COMP:
*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_ep_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP_WRITE, io);
}
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);
}
static int lookup_endpoint(int fd, uint8_t bEndpointAddress)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
if (index->iface_cur < 0)
return -1;
for (int ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++)
if (index->ifaces[index->iface_cur].eps[ep].desc.bEndpointAddress == bEndpointAddress)
return index->ifaces[index->iface_cur].eps[ep].handle;
return -1;
}
#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);
}
static volatile long syz_usb_connect_ath9k(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_ath9k);
}
static volatile long syz_usb_ep_write(volatile long a0, volatile long a1, volatile long a2, volatile long a3)
{
int fd = a0;
uint8_t ep = a1;
uint32_t len = a2;
char* data = (char*)a3;
int ep_handle = lookup_endpoint(fd, ep);
if (ep_handle < 0) {
return -1;
}
struct usb_raw_ep_io_data io_data;
io_data.inner.ep = ep_handle;
io_data.inner.flags = 0;
if (len > sizeof(io_data.data))
len = sizeof(io_data.data);
io_data.inner.length = len;
memcpy(&io_data.data[0], data, len);
int rv = usb_raw_ep_write(fd, (struct usb_raw_ep_io*)&io_data);
if (rv < 0) {
return rv;
}
sleep_ms(200);
return 0;
}
static volatile long syz_usb_disconnect(volatile long a0)
{
int fd = a0;
int rv = close(fd);
sleep_ms(200);
return rv;
}
uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*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=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_usb_connect_ath9k arguments: [
// speed: const = 0x3 (8 bytes)
// dev_len: len = 0x67 (8 bytes)
// dev: ptr[in, usb_device_descriptor_ath9k] {
// usb_device_descriptor_ath9k {
// inner: usb_device_descriptor_verbose_t[const[0x200, int16], USB_CLASS_VENDOR_SPEC, USB_SUBCLASS_VENDOR_SPEC, 0xff, const[64, int8], 0xcf3, 0x9271, 0x108, array[usb_config_descriptor_ath9k, 1]] {
// bLength: const = 0x12 (1 bytes)
// bDescriptorType: const = 0x1 (1 bytes)
// bcdUSB: const = 0x200 (2 bytes)
// bDeviceClass: const = 0xff (1 bytes)
// bDeviceSubClass: const = 0xff (1 bytes)
// bDeviceProtocol: const = 0xff (1 bytes)
// bMaxPacketSize0: const = 0x40 (1 bytes)
// idVendor: const = 0xcf3 (2 bytes)
// idProduct: const = 0x9271 (2 bytes)
// bcdDevice: const = 0x108 (2 bytes)
// iManufacturer: const = 0x1 (1 bytes)
// iProduct: const = 0x2 (1 bytes)
// iSerialNumber: const = 0x3 (1 bytes)
// bNumConfigurations: len = 0x1 (1 bytes)
// configs: array[usb_config_descriptor_ath9k] {
// usb_config_descriptor_ath9k {
// inner: usb_config_descriptor_verbose_t[const[1, int8], const[1, int8], const[0, int8], const[USB_CONFIG_ATT_ONE, int8], const[250, int8], void, usb_interface_descriptor_ath9k] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x2 (1 bytes)
// wTotalLength: len = 0x48 (2 bytes)
// bNumInterfaces: const = 0x1 (1 bytes)
// bConfigurationValue: const = 0x1 (1 bytes)
// iConfiguration: const = 0x0 (1 bytes)
// bmAttributes: const = 0x80 (1 bytes)
// bMaxPower: const = 0xfa (1 bytes)
// extra: buffer: {} (length 0x0)
// interfaces: usb_interface_descriptor_ath9k {
// iface: usb_interface_descriptor_verbose_t[const[0, int8], const[0, int8], const[6, int8], const[USB_CLASS_VENDOR_SPEC, int8], const[0, int8], const[0, int8], const[0, int8], void, usb_endpoint_descriptors_ath9k] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x4 (1 bytes)
// bInterfaceNumber: const = 0x0 (1 bytes)
// bAlternateSetting: const = 0x0 (1 bytes)
// bNumEndpoints: const = 0x6 (1 bytes)
// bInterfaceClass: const = 0xff (1 bytes)
// bInterfaceSubClass: const = 0x0 (1 bytes)
// bInterfaceProtocol: const = 0x0 (1 bytes)
// iInterface: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// endpoints: usb_endpoint_descriptors_ath9k {
// bulk_out: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_OUT_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x1 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_in: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_IN_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x82 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// int_in: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_INT_IN_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_INT_ATTRIBUTES, int8], const[64, int16], const[1, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x83 (1 bytes)
// bmAttributes: const = 0x3 (1 bytes)
// wMaxPacketSize: const = 0x40 (2 bytes)
// bInterval: const = 0x1 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// int_out: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_INT_OUT_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_INT_ATTRIBUTES, int8], const[64, int16], const[1, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x4 (1 bytes)
// bmAttributes: const = 0x3 (1 bytes)
// wMaxPacketSize: const = 0x40 (2 bytes)
// bInterval: const = 0x1 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_extra1: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_EXTRA1_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x5 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_extra2: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_EXTRA2_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x6 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// }
// }
// }
// }
// }
// }
// }
// }
// }
// conn_descs: const = 0x0 (8 bytes)
// ]
// returns fd_usb_ath9k
*(uint8_t*)0x2000000001c0 = 0x12;
*(uint8_t*)0x2000000001c1 = 1;
*(uint16_t*)0x2000000001c2 = 0x200;
*(uint8_t*)0x2000000001c4 = -1;
*(uint8_t*)0x2000000001c5 = -1;
*(uint8_t*)0x2000000001c6 = -1;
*(uint8_t*)0x2000000001c7 = 0x40;
*(uint16_t*)0x2000000001c8 = 0xcf3;
*(uint16_t*)0x2000000001ca = 0x9271;
*(uint16_t*)0x2000000001cc = 0x108;
*(uint8_t*)0x2000000001ce = 1;
*(uint8_t*)0x2000000001cf = 2;
*(uint8_t*)0x2000000001d0 = 3;
*(uint8_t*)0x2000000001d1 = 1;
*(uint8_t*)0x2000000001d2 = 9;
*(uint8_t*)0x2000000001d3 = 2;
*(uint16_t*)0x2000000001d4 = 0x48;
*(uint8_t*)0x2000000001d6 = 1;
*(uint8_t*)0x2000000001d7 = 1;
*(uint8_t*)0x2000000001d8 = 0;
*(uint8_t*)0x2000000001d9 = 0x80;
*(uint8_t*)0x2000000001da = 0xfa;
*(uint8_t*)0x2000000001db = 9;
*(uint8_t*)0x2000000001dc = 4;
*(uint8_t*)0x2000000001dd = 0;
*(uint8_t*)0x2000000001de = 0;
*(uint8_t*)0x2000000001df = 6;
*(uint8_t*)0x2000000001e0 = -1;
*(uint8_t*)0x2000000001e1 = 0;
*(uint8_t*)0x2000000001e2 = 0;
*(uint8_t*)0x2000000001e3 = 0;
*(uint8_t*)0x2000000001e4 = 9;
*(uint8_t*)0x2000000001e5 = 5;
*(uint8_t*)0x2000000001e6 = 1;
*(uint8_t*)0x2000000001e7 = 2;
*(uint16_t*)0x2000000001e8 = 0x200;
*(uint8_t*)0x2000000001ea = 0;
*(uint8_t*)0x2000000001eb = 0;
*(uint8_t*)0x2000000001ec = 0;
*(uint8_t*)0x2000000001ed = 9;
*(uint8_t*)0x2000000001ee = 5;
*(uint8_t*)0x2000000001ef = 0x82;
*(uint8_t*)0x2000000001f0 = 2;
*(uint16_t*)0x2000000001f1 = 0x200;
*(uint8_t*)0x2000000001f3 = 0;
*(uint8_t*)0x2000000001f4 = 0;
*(uint8_t*)0x2000000001f5 = 0;
*(uint8_t*)0x2000000001f6 = 9;
*(uint8_t*)0x2000000001f7 = 5;
*(uint8_t*)0x2000000001f8 = 0x83;
*(uint8_t*)0x2000000001f9 = 3;
*(uint16_t*)0x2000000001fa = 0x40;
*(uint8_t*)0x2000000001fc = 1;
*(uint8_t*)0x2000000001fd = 0;
*(uint8_t*)0x2000000001fe = 0;
*(uint8_t*)0x2000000001ff = 9;
*(uint8_t*)0x200000000200 = 5;
*(uint8_t*)0x200000000201 = 4;
*(uint8_t*)0x200000000202 = 3;
*(uint16_t*)0x200000000203 = 0x40;
*(uint8_t*)0x200000000205 = 1;
*(uint8_t*)0x200000000206 = 0;
*(uint8_t*)0x200000000207 = 0;
*(uint8_t*)0x200000000208 = 9;
*(uint8_t*)0x200000000209 = 5;
*(uint8_t*)0x20000000020a = 5;
*(uint8_t*)0x20000000020b = 2;
*(uint16_t*)0x20000000020c = 0x200;
*(uint8_t*)0x20000000020e = 0;
*(uint8_t*)0x20000000020f = 0;
*(uint8_t*)0x200000000210 = 0;
*(uint8_t*)0x200000000211 = 9;
*(uint8_t*)0x200000000212 = 5;
*(uint8_t*)0x200000000213 = 6;
*(uint8_t*)0x200000000214 = 2;
*(uint16_t*)0x200000000215 = 0x200;
*(uint8_t*)0x200000000217 = 0;
*(uint8_t*)0x200000000218 = 0;
*(uint8_t*)0x200000000219 = 0;
res = -1;
res = syz_usb_connect_ath9k(/*speed=*/3, /*dev_len=*/0x67, /*dev=*/0x2000000001c0, /*conn_descs=*/0);
if (res != -1)
r[0] = res;
// syz_usb_ep_write arguments: [
// fd: fd_usb (resource)
// ep: int8 = 0x6 (1 bytes)
// len: len = 0x4 (8 bytes)
// data: ptr[in, buffer] {
// buffer: {3c c1 e6 77} (length 0x4)
// }
// ]
memcpy((void*)0x200000000080, "\x3c\xc1\xe6\x77", 4);
syz_usb_ep_write(/*fd=*/-1, /*ep=*/6, /*len=*/4, /*data=*/0x200000000080);
// syz_usb_disconnect arguments: [
// fd: fd_usb (resource)
// ]
syz_usb_disconnect(/*fd=*/r[0]);
// syz_usb_connect arguments: [
// speed: usb_device_speed = 0x0 (8 bytes)
// dev_len: len = 0x36 (8 bytes)
// dev: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {12 01 00 00 ad 18 38 40 f3 0c 02 10} (length 0xc)
// }
// }
// }
// conn_descs: nil
// ]
// returns fd_usb
memcpy((void*)0x2000000001c0, "\x12\x01\x00\x00\xad\x18\x38\x40\xf3\x0c\x02\x10", 12);
res = -1;
res = syz_usb_connect(/*speed=*/0, /*dev_len=*/0x36, /*dev=*/0x2000000001c0, /*conn_descs=*/0);
if (res != -1)
r[1] = res;
// syz_usb_disconnect arguments: [
// fd: fd_usb (resource)
// ]
syz_usb_disconnect(/*fd=*/r[1]);
// syz_usb_connect_ath9k arguments: [
// speed: const = 0x3 (8 bytes)
// dev_len: len = 0xfdf9 (8 bytes)
// dev: ptr[in, usb_device_descriptor_ath9k] {
// usb_device_descriptor_ath9k {
// inner: usb_device_descriptor_verbose_t[const[0x200, int16], USB_CLASS_VENDOR_SPEC, USB_SUBCLASS_VENDOR_SPEC, 0xff, const[64, int8], 0xcf3, 0x9271, 0x108, array[usb_config_descriptor_ath9k, 1]] {
// bLength: const = 0x12 (1 bytes)
// bDescriptorType: const = 0x1 (1 bytes)
// bcdUSB: const = 0x200 (2 bytes)
// bDeviceClass: const = 0xff (1 bytes)
// bDeviceSubClass: const = 0xff (1 bytes)
// bDeviceProtocol: const = 0xff (1 bytes)
// bMaxPacketSize0: const = 0x40 (1 bytes)
// idVendor: const = 0xcf3 (2 bytes)
// idProduct: const = 0x9271 (2 bytes)
// bcdDevice: const = 0x108 (2 bytes)
// iManufacturer: const = 0x1 (1 bytes)
// iProduct: const = 0x2 (1 bytes)
// iSerialNumber: const = 0x3 (1 bytes)
// bNumConfigurations: len = 0x31 (1 bytes)
// configs: array[usb_config_descriptor_ath9k] {
// usb_config_descriptor_ath9k {
// inner: usb_config_descriptor_verbose_t[const[1, int8], const[1, int8], const[0, int8], const[USB_CONFIG_ATT_ONE, int8], const[250, int8], void, usb_interface_descriptor_ath9k] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x2 (1 bytes)
// wTotalLength: len = 0xfffffffffffffe9f (2 bytes)
// bNumInterfaces: const = 0x1 (1 bytes)
// bConfigurationValue: const = 0x1 (1 bytes)
// iConfiguration: const = 0x0 (1 bytes)
// bmAttributes: const = 0x80 (1 bytes)
// bMaxPower: const = 0xfa (1 bytes)
// extra: buffer: {} (length 0x0)
// interfaces: usb_interface_descriptor_ath9k {
// iface: usb_interface_descriptor_verbose_t[const[0, int8], const[0, int8], const[6, int8], const[USB_CLASS_VENDOR_SPEC, int8], const[0, int8], const[0, int8], const[0, int8], void, usb_endpoint_descriptors_ath9k] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x4 (1 bytes)
// bInterfaceNumber: const = 0x0 (1 bytes)
// bAlternateSetting: const = 0x0 (1 bytes)
// bNumEndpoints: const = 0x6 (1 bytes)
// bInterfaceClass: const = 0xff (1 bytes)
// bInterfaceSubClass: const = 0x0 (1 bytes)
// bInterfaceProtocol: const = 0x0 (1 bytes)
// iInterface: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// endpoints: usb_endpoint_descriptors_ath9k {
// bulk_out: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_OUT_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x1 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_in: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_IN_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x82 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// int_in: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_INT_IN_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_INT_ATTRIBUTES, int8], const[64, int16], const[1, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x83 (1 bytes)
// bmAttributes: const = 0x3 (1 bytes)
// wMaxPacketSize: const = 0x40 (2 bytes)
// bInterval: const = 0x1 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// int_out: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_INT_OUT_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_INT_ATTRIBUTES, int8], const[64, int16], const[1, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x4 (1 bytes)
// bmAttributes: const = 0x3 (1 bytes)
// wMaxPacketSize: const = 0x40 (2 bytes)
// bInterval: const = 0x1 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_extra1: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_EXTRA1_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x5 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_extra2: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_EXTRA2_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x6 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// }
// }
// }
// }
// }
// }
// }
// }
// }
// conn_descs: const = 0x0 (8 bytes)
// ]
// returns fd_usb_ath9k
*(uint8_t*)0x200000000000 = 0x12;
*(uint8_t*)0x200000000001 = 1;
*(uint16_t*)0x200000000002 = 0x200;
*(uint8_t*)0x200000000004 = -1;
*(uint8_t*)0x200000000005 = -1;
*(uint8_t*)0x200000000006 = -1;
*(uint8_t*)0x200000000007 = 0x40;
*(uint16_t*)0x200000000008 = 0xcf3;
*(uint16_t*)0x20000000000a = 0x9271;
*(uint16_t*)0x20000000000c = 0x108;
*(uint8_t*)0x20000000000e = 1;
*(uint8_t*)0x20000000000f = 2;
*(uint8_t*)0x200000000010 = 3;
*(uint8_t*)0x200000000011 = 0x31;
*(uint8_t*)0x200000000012 = 9;
*(uint8_t*)0x200000000013 = 2;
*(uint16_t*)0x200000000014 = 0xfe9f;
*(uint8_t*)0x200000000016 = 1;
*(uint8_t*)0x200000000017 = 1;
*(uint8_t*)0x200000000018 = 0;
*(uint8_t*)0x200000000019 = 0x80;
*(uint8_t*)0x20000000001a = 0xfa;
*(uint8_t*)0x20000000001b = 9;
*(uint8_t*)0x20000000001c = 4;
*(uint8_t*)0x20000000001d = 0;
*(uint8_t*)0x20000000001e = 0;
*(uint8_t*)0x20000000001f = 6;
*(uint8_t*)0x200000000020 = -1;
*(uint8_t*)0x200000000021 = 0;
*(uint8_t*)0x200000000022 = 0;
*(uint8_t*)0x200000000023 = 0;
*(uint8_t*)0x200000000024 = 9;
*(uint8_t*)0x200000000025 = 5;
*(uint8_t*)0x200000000026 = 1;
*(uint8_t*)0x200000000027 = 2;
*(uint16_t*)0x200000000028 = 0x200;
*(uint8_t*)0x20000000002a = 0;
*(uint8_t*)0x20000000002b = 0;
*(uint8_t*)0x20000000002c = 0;
*(uint8_t*)0x20000000002d = 9;
*(uint8_t*)0x20000000002e = 5;
*(uint8_t*)0x20000000002f = 0x82;
*(uint8_t*)0x200000000030 = 2;
*(uint16_t*)0x200000000031 = 0x200;
*(uint8_t*)0x200000000033 = 0;
*(uint8_t*)0x200000000034 = 0;
*(uint8_t*)0x200000000035 = 0;
*(uint8_t*)0x200000000036 = 9;
*(uint8_t*)0x200000000037 = 5;
*(uint8_t*)0x200000000038 = 0x83;
*(uint8_t*)0x200000000039 = 3;
*(uint16_t*)0x20000000003a = 0x40;
*(uint8_t*)0x20000000003c = 1;
*(uint8_t*)0x20000000003d = 0;
*(uint8_t*)0x20000000003e = 0;
*(uint8_t*)0x20000000003f = 9;
*(uint8_t*)0x200000000040 = 5;
*(uint8_t*)0x200000000041 = 4;
*(uint8_t*)0x200000000042 = 3;
*(uint16_t*)0x200000000043 = 0x40;
*(uint8_t*)0x200000000045 = 1;
*(uint8_t*)0x200000000046 = 0;
*(uint8_t*)0x200000000047 = 0;
*(uint8_t*)0x200000000048 = 9;
*(uint8_t*)0x200000000049 = 5;
*(uint8_t*)0x20000000004a = 5;
*(uint8_t*)0x20000000004b = 2;
*(uint16_t*)0x20000000004c = 0x200;
*(uint8_t*)0x20000000004e = 0;
*(uint8_t*)0x20000000004f = 0;
*(uint8_t*)0x200000000050 = 0;
*(uint8_t*)0x200000000051 = 9;
*(uint8_t*)0x200000000052 = 5;
*(uint8_t*)0x200000000053 = 6;
*(uint8_t*)0x200000000054 = 2;
*(uint16_t*)0x200000000055 = 0x200;
*(uint8_t*)0x200000000057 = 0;
*(uint8_t*)0x200000000058 = 0;
*(uint8_t*)0x200000000059 = 0;
syz_usb_connect_ath9k(/*speed=*/3, /*dev_len=*/0xfdf9, /*dev=*/0x200000000000, /*conn_descs=*/0);
// syz_usb_ep_write$ath9k_ep2 arguments: [
// fd: fd_usb_ath9k (resource)
// ep: const = 0x83 (1 bytes)
// len: bytesize = 0x82 (8 bytes)
// data: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// }
// }
// ]
syz_usb_ep_write(/*fd=*/r[1], /*ep=*/0x83, /*len=*/0x82, /*data=*/0x200000000080);
return 0;
}
]
|
| 2/1 |
2026/07/05 07:19 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/7be5f73ee7b4d1978813accf8bb54cd892ccd800]
|
| 3/1 |
2026/07/05 07:19 |
action |
kernel-builder |
15m
Results: map[KernelObj:/app/workdir/cache/build/8383720067e5ed14263ab4ae4e33e9b235dd9f79]
|
| 4/1 |
2026/07/05 07:35 |
action |
codesearch-prepare |
15m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/07/05 07:50 |
agent |
expert |
7m
Model:
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:true Unprivileged:true 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 grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption, elevated privileges, or an information leak.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completely wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control transfers, that also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Information leaks are exploitable on their own and should be classified as such. A bug that copies kernel
memory contents to userspace (e.g. an out-of-bounds read whose result is returned to the caller, or
uninitialized stack/heap bytes written to a user buffer) is exploitable: it can reveal kernel pointer
values and defeat KASLR, expose sensitive data such as cryptographic keys or other processes' memory, and
serves as a necessary building block in most modern kernel privilege-escalation exploit chains. Do not classify
an information leak as non-exploitable solely because it does not directly cause a memory write or control-flow
hijack; the leak itself is the exploit primitive.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
------------[ cut here ]------------
__lockdep_enabled && !this_cpu_read(hardirqs_enabled)
WARNING: kernel/softirq.c:430 at __local_bh_enable_ip+0xbd/0x120 kernel/softirq.c:430, CPU#0: swapper/0/0
Modules linked in:
CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted syzkaller #0 PREEMPT(lazy)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/09/2026
RIP: 0010:__local_bh_enable_ip+0xbd/0x120 kernel/softirq.c:430
Code: 00 e8 a7 d1 0b 00 e8 62 10 45 00 fb 65 8b 05 7a c3 86 0b 85 c0 74 50 5b 5d c3 cc cc cc cc 65 8b 05 04 03 87 0b 85 c0 75 a0 90 <0f> 0b 90 eb 9a e8 59 12 45 00 eb 9b 48 89 ef e8 0f 0b 19 00 eb a4
RSP: 0018:ffffc90000007aa8 EFLAGS: 00010046
RAX: 0000000000000000 RBX: 0000000000000201 RCX: 1ffffffff15e7114
RDX: 0000000000000001 RSI: 0000000000000201 RDI: ffffffff8446537b
RBP: ffffffff8446537b R08: 0000000000000000 R09: ffffed1023c4ca8b
R10: ffff88811e26545b R11: 0000000000000000 R12: ffff88811d71f585
R13: dffffc0000000000 R14: ffff88811e263220 R15: ffff88811e265440
FS: 0000000000000000(0000) GS:ffff888268640000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055d2294bcd98 CR3: 0000000124272000 CR4: 00000000003506f0
Call Trace:
<IRQ>
spin_unlock_bh include/linux/spinlock.h:396 [inline]
carl9170_get_queued_skb drivers/net/wireless/ath/carl9170/tx.c:531 [inline]
__carl9170_tx_process_status+0x13b/0x620 drivers/net/wireless/ath/carl9170/tx.c:668
carl9170_tx_process_status+0xf6/0x230 drivers/net/wireless/ath/carl9170/tx.c:701
carl9170_handle_command_response+0x3c8/0xc50 drivers/net/wireless/ath/carl9170/rx.c:219
carl9170_usb_rx_irq_complete+0xfc/0x1b0 drivers/net/wireless/ath/carl9170/usb.c:307
__usb_hcd_giveback_urb+0x38d/0x610 drivers/usb/core/hcd.c:1657
usb_hcd_giveback_urb+0x3ca/0x4a0 drivers/usb/core/hcd.c:1741
dummy_timer+0xda1/0x36c0 drivers/usb/gadget/udc/dummy_hcd.c:2005
__run_hrtimer kernel/time/hrtimer.c:2032 [inline]
__hrtimer_run_queues+0x462/0x9c0 kernel/time/hrtimer.c:2096
hrtimer_run_softirq+0x17d/0x2c0 kernel/time/hrtimer.c:2113
handle_softirqs+0x1dd/0x990 kernel/softirq.c:622
__do_softirq kernel/softirq.c:656 [inline]
invoke_softirq kernel/softirq.c:496 [inline]
__irq_exit_rcu+0x160/0x210 kernel/softirq.c:735
irq_exit_rcu+0x9/0x30 kernel/softirq.c:752
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline]
sysvec_apic_timer_interrupt+0x8f/0xb0 arch/x86/kernel/apic/apic.c:1062
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674
RIP: 0010:pv_native_safe_halt+0xf/0x20 arch/x86/kernel/paravirt.c:64
Code: 90 ac 01 c3 cc cc cc cc 0f 1f 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 66 90 0f 00 2d 03 8f 0b 00 fb f4 <e9> 3c f6 02 00 66 2e 0f 1f 84 00 00 00 00 00 66 90 90 90 90 90 90
RSP: 0018:ffffffff89407e20 EFLAGS: 00000242
RAX: 00000000000951ab RBX: ffffffff8942c8c0 RCX: ffffffff877af8e5
RDX: 0000000000000000 RSI: ffffffff890edf5a RDI: ffffffff87b15200
RBP: fffffbfff1285918 R08: 0000000000000001 R09: ffffed103eac670d
R10: ffff8881f563386b R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: 1ffffffff1280fc8 R15: dffffc0000000000
arch_safe_halt arch/x86/include/asm/paravirt.h:62 [inline]
default_idle+0x9/0x10 arch/x86/kernel/process.c:768
default_idle_call+0x6c/0xb0 kernel/sched/idle.c:122
cpuidle_idle_call kernel/sched/idle.c:199 [inline]
do_idle+0x3a7/0x5b0 kernel/sched/idle.c:355
cpu_startup_entry+0x4f/0x60 kernel/sched/idle.c:454
rest_init+0x251/0x260 init/main.c:717
start_kernel+0x489/0x490 init/main.c:1175
x86_64_start_reservations+0x24/0x30 arch/x86/kernel/head64.c:310
x86_64_start_kernel+0x12b/0x130 arch/x86/kernel/head64.c:291
common_startup_64+0x13e/0x158
</TASK>
----------------
Code disassembly (best guess):
0: 90 nop
1: ac lods %ds:(%rsi),%al
2: 01 c3 add %eax,%ebx
4: cc int3
5: cc int3
6: cc int3
7: cc int3
8: 0f 1f 00 nopl (%rax)
b: 90 nop
c: 90 nop
d: 90 nop
e: 90 nop
f: 90 nop
10: 90 nop
11: 90 nop
12: 90 nop
13: 90 nop
14: 90 nop
15: 90 nop
16: 90 nop
17: 90 nop
18: 90 nop
19: 90 nop
1a: 90 nop
1b: f3 0f 1e fa endbr64
1f: 66 90 xchg %ax,%ax
21: 0f 00 2d 03 8f 0b 00 verw 0xb8f03(%rip) # 0xb8f2b
28: fb sti
29: f4 hlt
* 2a: e9 3c f6 02 00 jmp 0x2f66b <-- trapping instruction
2f: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1)
36: 00 00 00
39: 66 90 xchg %ax,%ax
3b: 90 nop
3c: 90 nop
3d: 90 nop
3e: 90 nop
3f: 90 nop
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 ATH9K_FIRMWARE_DOWNLOAD 0x30
#define ATH9K_FIRMWARE_DOWNLOAD_COMP 0x31
static bool lookup_connect_response_out_ath9k(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:
return true;
default:
break;
}
break;
case USB_TYPE_VENDOR:
switch (ctrl->bRequest) {
case ATH9K_FIRMWARE_DOWNLOAD:
return true;
case ATH9K_FIRMWARE_DOWNLOAD_COMP:
*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_ep_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP_WRITE, io);
}
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);
}
static int lookup_endpoint(int fd, uint8_t bEndpointAddress)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
if (index->iface_cur < 0)
return -1;
for (int ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++)
if (index->ifaces[index->iface_cur].eps[ep].desc.bEndpointAddress == bEndpointAddress)
return index->ifaces[index->iface_cur].eps[ep].handle;
return -1;
}
#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);
}
static volatile long syz_usb_connect_ath9k(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_ath9k);
}
static volatile long syz_usb_ep_write(volatile long a0, volatile long a1, volatile long a2, volatile long a3)
{
int fd = a0;
uint8_t ep = a1;
uint32_t len = a2;
char* data = (char*)a3;
int ep_handle = lookup_endpoint(fd, ep);
if (ep_handle < 0) {
return -1;
}
struct usb_raw_ep_io_data io_data;
io_data.inner.ep = ep_handle;
io_data.inner.flags = 0;
if (len > sizeof(io_data.data))
len = sizeof(io_data.data);
io_data.inner.length = len;
memcpy(&io_data.data[0], data, len);
int rv = usb_raw_ep_write(fd, (struct usb_raw_ep_io*)&io_data);
if (rv < 0) {
return rv;
}
sleep_ms(200);
return 0;
}
static volatile long syz_usb_disconnect(volatile long a0)
{
int fd = a0;
int rv = close(fd);
sleep_ms(200);
return rv;
}
uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*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=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_usb_connect_ath9k arguments: [
// speed: const = 0x3 (8 bytes)
// dev_len: len = 0x67 (8 bytes)
// dev: ptr[in, usb_device_descriptor_ath9k] {
// usb_device_descriptor_ath9k {
// inner: usb_device_descriptor_verbose_t[const[0x200, int16], USB_CLASS_VENDOR_SPEC, USB_SUBCLASS_VENDOR_SPEC, 0xff, const[64, int8], 0xcf3, 0x9271, 0x108, array[usb_config_descriptor_ath9k, 1]] {
// bLength: const = 0x12 (1 bytes)
// bDescriptorType: const = 0x1 (1 bytes)
// bcdUSB: const = 0x200 (2 bytes)
// bDeviceClass: const = 0xff (1 bytes)
// bDeviceSubClass: const = 0xff (1 bytes)
// bDeviceProtocol: const = 0xff (1 bytes)
// bMaxPacketSize0: const = 0x40 (1 bytes)
// idVendor: const = 0xcf3 (2 bytes)
// idProduct: const = 0x9271 (2 bytes)
// bcdDevice: const = 0x108 (2 bytes)
// iManufacturer: const = 0x1 (1 bytes)
// iProduct: const = 0x2 (1 bytes)
// iSerialNumber: const = 0x3 (1 bytes)
// bNumConfigurations: len = 0x1 (1 bytes)
// configs: array[usb_config_descriptor_ath9k] {
// usb_config_descriptor_ath9k {
// inner: usb_config_descriptor_verbose_t[const[1, int8], const[1, int8], const[0, int8], const[USB_CONFIG_ATT_ONE, int8], const[250, int8], void, usb_interface_descriptor_ath9k] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x2 (1 bytes)
// wTotalLength: len = 0x48 (2 bytes)
// bNumInterfaces: const = 0x1 (1 bytes)
// bConfigurationValue: const = 0x1 (1 bytes)
// iConfiguration: const = 0x0 (1 bytes)
// bmAttributes: const = 0x80 (1 bytes)
// bMaxPower: const = 0xfa (1 bytes)
// extra: buffer: {} (length 0x0)
// interfaces: usb_interface_descriptor_ath9k {
// iface: usb_interface_descriptor_verbose_t[const[0, int8], const[0, int8], const[6, int8], const[USB_CLASS_VENDOR_SPEC, int8], const[0, int8], const[0, int8], const[0, int8], void, usb_endpoint_descriptors_ath9k] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x4 (1 bytes)
// bInterfaceNumber: const = 0x0 (1 bytes)
// bAlternateSetting: const = 0x0 (1 bytes)
// bNumEndpoints: const = 0x6 (1 bytes)
// bInterfaceClass: const = 0xff (1 bytes)
// bInterfaceSubClass: const = 0x0 (1 bytes)
// bInterfaceProtocol: const = 0x0 (1 bytes)
// iInterface: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// endpoints: usb_endpoint_descriptors_ath9k {
// bulk_out: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_OUT_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x1 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_in: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_IN_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x82 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// int_in: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_INT_IN_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_INT_ATTRIBUTES, int8], const[64, int16], const[1, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x83 (1 bytes)
// bmAttributes: const = 0x3 (1 bytes)
// wMaxPacketSize: const = 0x40 (2 bytes)
// bInterval: const = 0x1 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// int_out: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_INT_OUT_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_INT_ATTRIBUTES, int8], const[64, int16], const[1, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x4 (1 bytes)
// bmAttributes: const = 0x3 (1 bytes)
// wMaxPacketSize: const = 0x40 (2 bytes)
// bInterval: const = 0x1 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_extra1: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_EXTRA1_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x5 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_extra2: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_EXTRA2_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x6 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// }
// }
// }
// }
// }
// }
// }
// }
// }
// conn_descs: const = 0x0 (8 bytes)
// ]
// returns fd_usb_ath9k
*(uint8_t*)0x2000000001c0 = 0x12;
*(uint8_t*)0x2000000001c1 = 1;
*(uint16_t*)0x2000000001c2 = 0x200;
*(uint8_t*)0x2000000001c4 = -1;
*(uint8_t*)0x2000000001c5 = -1;
*(uint8_t*)0x2000000001c6 = -1;
*(uint8_t*)0x2000000001c7 = 0x40;
*(uint16_t*)0x2000000001c8 = 0xcf3;
*(uint16_t*)0x2000000001ca = 0x9271;
*(uint16_t*)0x2000000001cc = 0x108;
*(uint8_t*)0x2000000001ce = 1;
*(uint8_t*)0x2000000001cf = 2;
*(uint8_t*)0x2000000001d0 = 3;
*(uint8_t*)0x2000000001d1 = 1;
*(uint8_t*)0x2000000001d2 = 9;
*(uint8_t*)0x2000000001d3 = 2;
*(uint16_t*)0x2000000001d4 = 0x48;
*(uint8_t*)0x2000000001d6 = 1;
*(uint8_t*)0x2000000001d7 = 1;
*(uint8_t*)0x2000000001d8 = 0;
*(uint8_t*)0x2000000001d9 = 0x80;
*(uint8_t*)0x2000000001da = 0xfa;
*(uint8_t*)0x2000000001db = 9;
*(uint8_t*)0x2000000001dc = 4;
*(uint8_t*)0x2000000001dd = 0;
*(uint8_t*)0x2000000001de = 0;
*(uint8_t*)0x2000000001df = 6;
*(uint8_t*)0x2000000001e0 = -1;
*(uint8_t*)0x2000000001e1 = 0;
*(uint8_t*)0x2000000001e2 = 0;
*(uint8_t*)0x2000000001e3 = 0;
*(uint8_t*)0x2000000001e4 = 9;
*(uint8_t*)0x2000000001e5 = 5;
*(uint8_t*)0x2000000001e6 = 1;
*(uint8_t*)0x2000000001e7 = 2;
*(uint16_t*)0x2000000001e8 = 0x200;
*(uint8_t*)0x2000000001ea = 0;
*(uint8_t*)0x2000000001eb = 0;
*(uint8_t*)0x2000000001ec = 0;
*(uint8_t*)0x2000000001ed = 9;
*(uint8_t*)0x2000000001ee = 5;
*(uint8_t*)0x2000000001ef = 0x82;
*(uint8_t*)0x2000000001f0 = 2;
*(uint16_t*)0x2000000001f1 = 0x200;
*(uint8_t*)0x2000000001f3 = 0;
*(uint8_t*)0x2000000001f4 = 0;
*(uint8_t*)0x2000000001f5 = 0;
*(uint8_t*)0x2000000001f6 = 9;
*(uint8_t*)0x2000000001f7 = 5;
*(uint8_t*)0x2000000001f8 = 0x83;
*(uint8_t*)0x2000000001f9 = 3;
*(uint16_t*)0x2000000001fa = 0x40;
*(uint8_t*)0x2000000001fc = 1;
*(uint8_t*)0x2000000001fd = 0;
*(uint8_t*)0x2000000001fe = 0;
*(uint8_t*)0x2000000001ff = 9;
*(uint8_t*)0x200000000200 = 5;
*(uint8_t*)0x200000000201 = 4;
*(uint8_t*)0x200000000202 = 3;
*(uint16_t*)0x200000000203 = 0x40;
*(uint8_t*)0x200000000205 = 1;
*(uint8_t*)0x200000000206 = 0;
*(uint8_t*)0x200000000207 = 0;
*(uint8_t*)0x200000000208 = 9;
*(uint8_t*)0x200000000209 = 5;
*(uint8_t*)0x20000000020a = 5;
*(uint8_t*)0x20000000020b = 2;
*(uint16_t*)0x20000000020c = 0x200;
*(uint8_t*)0x20000000020e = 0;
*(uint8_t*)0x20000000020f = 0;
*(uint8_t*)0x200000000210 = 0;
*(uint8_t*)0x200000000211 = 9;
*(uint8_t*)0x200000000212 = 5;
*(uint8_t*)0x200000000213 = 6;
*(uint8_t*)0x200000000214 = 2;
*(uint16_t*)0x200000000215 = 0x200;
*(uint8_t*)0x200000000217 = 0;
*(uint8_t*)0x200000000218 = 0;
*(uint8_t*)0x200000000219 = 0;
res = -1;
res = syz_usb_connect_ath9k(/*speed=*/3, /*dev_len=*/0x67, /*dev=*/0x2000000001c0, /*conn_descs=*/0);
if (res != -1)
r[0] = res;
// syz_usb_ep_write arguments: [
// fd: fd_usb (resource)
// ep: int8 = 0x6 (1 bytes)
// len: len = 0x4 (8 bytes)
// data: ptr[in, buffer] {
// buffer: {3c c1 e6 77} (length 0x4)
// }
// ]
memcpy((void*)0x200000000080, "\x3c\xc1\xe6\x77", 4);
syz_usb_ep_write(/*fd=*/-1, /*ep=*/6, /*len=*/4, /*data=*/0x200000000080);
// syz_usb_disconnect arguments: [
// fd: fd_usb (resource)
// ]
syz_usb_disconnect(/*fd=*/r[0]);
// syz_usb_connect arguments: [
// speed: usb_device_speed = 0x0 (8 bytes)
// dev_len: len = 0x36 (8 bytes)
// dev: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {12 01 00 00 ad 18 38 40 f3 0c 02 10} (length 0xc)
// }
// }
// }
// conn_descs: nil
// ]
// returns fd_usb
memcpy((void*)0x2000000001c0, "\x12\x01\x00\x00\xad\x18\x38\x40\xf3\x0c\x02\x10", 12);
res = -1;
res = syz_usb_connect(/*speed=*/0, /*dev_len=*/0x36, /*dev=*/0x2000000001c0, /*conn_descs=*/0);
if (res != -1)
r[1] = res;
// syz_usb_disconnect arguments: [
// fd: fd_usb (resource)
// ]
syz_usb_disconnect(/*fd=*/r[1]);
// syz_usb_connect_ath9k arguments: [
// speed: const = 0x3 (8 bytes)
// dev_len: len = 0xfdf9 (8 bytes)
// dev: ptr[in, usb_device_descriptor_ath9k] {
// usb_device_descriptor_ath9k {
// inner: usb_device_descriptor_verbose_t[const[0x200, int16], USB_CLASS_VENDOR_SPEC, USB_SUBCLASS_VENDOR_SPEC, 0xff, const[64, int8], 0xcf3, 0x9271, 0x108, array[usb_config_descriptor_ath9k, 1]] {
// bLength: const = 0x12 (1 bytes)
// bDescriptorType: const = 0x1 (1 bytes)
// bcdUSB: const = 0x200 (2 bytes)
// bDeviceClass: const = 0xff (1 bytes)
// bDeviceSubClass: const = 0xff (1 bytes)
// bDeviceProtocol: const = 0xff (1 bytes)
// bMaxPacketSize0: const = 0x40 (1 bytes)
// idVendor: const = 0xcf3 (2 bytes)
// idProduct: const = 0x9271 (2 bytes)
// bcdDevice: const = 0x108 (2 bytes)
// iManufacturer: const = 0x1 (1 bytes)
// iProduct: const = 0x2 (1 bytes)
// iSerialNumber: const = 0x3 (1 bytes)
// bNumConfigurations: len = 0x31 (1 bytes)
// configs: array[usb_config_descriptor_ath9k] {
// usb_config_descriptor_ath9k {
// inner: usb_config_descriptor_verbose_t[const[1, int8], const[1, int8], const[0, int8], const[USB_CONFIG_ATT_ONE, int8], const[250, int8], void, usb_interface_descriptor_ath9k] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x2 (1 bytes)
// wTotalLength: len = 0xfffffffffffffe9f (2 bytes)
// bNumInterfaces: const = 0x1 (1 bytes)
// bConfigurationValue: const = 0x1 (1 bytes)
// iConfiguration: const = 0x0 (1 bytes)
// bmAttributes: const = 0x80 (1 bytes)
// bMaxPower: const = 0xfa (1 bytes)
// extra: buffer: {} (length 0x0)
// interfaces: usb_interface_descriptor_ath9k {
// iface: usb_interface_descriptor_verbose_t[const[0, int8], const[0, int8], const[6, int8], const[USB_CLASS_VENDOR_SPEC, int8], const[0, int8], const[0, int8], const[0, int8], void, usb_endpoint_descriptors_ath9k] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x4 (1 bytes)
// bInterfaceNumber: const = 0x0 (1 bytes)
// bAlternateSetting: const = 0x0 (1 bytes)
// bNumEndpoints: const = 0x6 (1 bytes)
// bInterfaceClass: const = 0xff (1 bytes)
// bInterfaceSubClass: const = 0x0 (1 bytes)
// bInterfaceProtocol: const = 0x0 (1 bytes)
// iInterface: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// endpoints: usb_endpoint_descriptors_ath9k {
// bulk_out: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_OUT_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x1 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_in: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_IN_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x82 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// int_in: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_INT_IN_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_INT_ATTRIBUTES, int8], const[64, int16], const[1, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x83 (1 bytes)
// bmAttributes: const = 0x3 (1 bytes)
// wMaxPacketSize: const = 0x40 (2 bytes)
// bInterval: const = 0x1 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// int_out: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_INT_OUT_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_INT_ATTRIBUTES, int8], const[64, int16], const[1, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x4 (1 bytes)
// bmAttributes: const = 0x3 (1 bytes)
// wMaxPacketSize: const = 0x40 (2 bytes)
// bInterval: const = 0x1 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_extra1: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_EXTRA1_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x5 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_extra2: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_EXTRA2_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x6 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// }
// }
// }
// }
// }
// }
// }
// }
// }
// conn_descs: const = 0x0 (8 bytes)
// ]
// returns fd_usb_ath9k
*(uint8_t*)0x200000000000 = 0x12;
*(uint8_t*)0x200000000001 = 1;
*(uint16_t*)0x200000000002 = 0x200;
*(uint8_t*)0x200000000004 = -1;
*(uint8_t*)0x200000000005 = -1;
*(uint8_t*)0x200000000006 = -1;
*(uint8_t*)0x200000000007 = 0x40;
*(uint16_t*)0x200000000008 = 0xcf3;
*(uint16_t*)0x20000000000a = 0x9271;
*(uint16_t*)0x20000000000c = 0x108;
*(uint8_t*)0x20000000000e = 1;
*(uint8_t*)0x20000000000f = 2;
*(uint8_t*)0x200000000010 = 3;
*(uint8_t*)0x200000000011 = 0x31;
*(uint8_t*)0x200000000012 = 9;
*(uint8_t*)0x200000000013 = 2;
*(uint16_t*)0x200000000014 = 0xfe9f;
*(uint8_t*)0x200000000016 = 1;
*(uint8_t*)0x200000000017 = 1;
*(uint8_t*)0x200000000018 = 0;
*(uint8_t*)0x200000000019 = 0x80;
*(uint8_t*)0x20000000001a = 0xfa;
*(uint8_t*)0x20000000001b = 9;
*(uint8_t*)0x20000000001c = 4;
*(uint8_t*)0x20000000001d = 0;
*(uint8_t*)0x20000000001e = 0;
*(uint8_t*)0x20000000001f = 6;
*(uint8_t*)0x200000000020 = -1;
*(uint8_t*)0x200000000021 = 0;
*(uint8_t*)0x200000000022 = 0;
*(uint8_t*)0x200000000023 = 0;
*(uint8_t*)0x200000000024 = 9;
*(uint8_t*)0x200000000025 = 5;
*(uint8_t*)0x200000000026 = 1;
*(uint8_t*)0x200000000027 = 2;
*(uint16_t*)0x200000000028 = 0x200;
*(uint8_t*)0x20000000002a = 0;
*(uint8_t*)0x20000000002b = 0;
*(uint8_t*)0x20000000002c = 0;
*(uint8_t*)0x20000000002d = 9;
*(uint8_t*)0x20000000002e = 5;
*(uint8_t*)0x20000000002f = 0x82;
*(uint8_t*)0x200000000030 = 2;
*(uint16_t*)0x200000000031 = 0x200;
*(uint8_t*)0x200000000033 = 0;
*(uint8_t*)0x200000000034 = 0;
*(uint8_t*)0x200000000035 = 0;
*(uint8_t*)0x200000000036 = 9;
*(uint8_t*)0x200000000037 = 5;
*(uint8_t*)0x200000000038 = 0x83;
*(uint8_t*)0x200000000039 = 3;
*(uint16_t*)0x20000000003a = 0x40;
*(uint8_t*)0x20000000003c = 1;
*(uint8_t*)0x20000000003d = 0;
*(uint8_t*)0x20000000003e = 0;
*(uint8_t*)0x20000000003f = 9;
*(uint8_t*)0x200000000040 = 5;
*(uint8_t*)0x200000000041 = 4;
*(uint8_t*)0x200000000042 = 3;
*(uint16_t*)0x200000000043 = 0x40;
*(uint8_t*)0x200000000045 = 1;
*(uint8_t*)0x200000000046 = 0;
*(uint8_t*)0x200000000047 = 0;
*(uint8_t*)0x200000000048 = 9;
*(uint8_t*)0x200000000049 = 5;
*(uint8_t*)0x20000000004a = 5;
*(uint8_t*)0x20000000004b = 2;
*(uint16_t*)0x20000000004c = 0x200;
*(uint8_t*)0x20000000004e = 0;
*(uint8_t*)0x20000000004f = 0;
*(uint8_t*)0x200000000050 = 0;
*(uint8_t*)0x200000000051 = 9;
*(uint8_t*)0x200000000052 = 5;
*(uint8_t*)0x200000000053 = 6;
*(uint8_t*)0x200000000054 = 2;
*(uint16_t*)0x200000000055 = 0x200;
*(uint8_t*)0x200000000057 = 0;
*(uint8_t*)0x200000000058 = 0;
*(uint8_t*)0x200000000059 = 0;
syz_usb_connect_ath9k(/*speed=*/3, /*dev_len=*/0xfdf9, /*dev=*/0x200000000000, /*conn_descs=*/0);
// syz_usb_ep_write$ath9k_ep2 arguments: [
// fd: fd_usb_ath9k (resource)
// ep: const = 0x83 (1 bytes)
// len: bytesize = 0x82 (8 bytes)
// data: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// }
// }
// ]
syz_usb_ep_write(/*fd=*/r[1], /*ep=*/0x83, /*len=*/0x82, /*data=*/0x200000000080);
return 0;
}
Reply: **Bug Analysis:**
The bug report indicates a `WARNING` in `__local_bh_enable_ip()` triggered by `lockdep_assert_irqs_enabled()`.
By analyzing the stack trace and the source code, the sequence of events is as follows:
1. The `dummy_hcd` driver (used for emulating USB devices) completes an URB by calling `usb_hcd_giveback_urb()`. Because `dummy_hcd` does not set the `HCD_BH` flag, the completion handler is invoked synchronously in the context of the `dummy_timer` hrtimer, where hardware interrupts are disabled (via `spin_lock_irqsave`).
2. The URB completion handler for the `carl9170` WiFi driver (`carl9170_usb_rx_irq_complete()`) is executed.
3. The driver processes a TX completion response (`CARL9170_RSP_TXCOMP`) from the device, eventually calling `carl9170_get_queued_skb()`.
4. Inside `carl9170_get_queued_skb()`, the driver uses `spin_lock_bh()` and `spin_unlock_bh()` to protect the queue.
5. `spin_unlock_bh()` calls `__local_bh_enable_ip()`, which expects hardware interrupts to be enabled. Since they are currently disabled by the HCD, lockdep throws a warning.
**Security Impact:**
* **Exploitable:** **No.** This is purely an API usage violation caught by lockdep and debug assertions. There is no memory corruption, out-of-bounds access, or information leak.
* **Denial of Service:** **No.** In production builds (where lockdep, `CONFIG_TRACE_IRQFLAGS`, and `panic_on_warn` are disabled), calling `spin_unlock_bh()` with interrupts disabled is harmless. The function will simply decrement the preempt count and skip running softirqs because `in_interrupt()` evaluates to true. It does not inadvertently re-enable hardware interrupts, nor does it cause a deadlock or system crash.
* **Accessible From Unprivileged Processes:** **Yes.** An unprivileged local user can trigger this warning by simply sending network traffic (e.g., UDP packets) over the WiFi interface, which naturally generates TX completion events from the firmware.
* **Peripheral Trigger:** **Yes.** A malicious USB device can spoof `CARL9170_RSP_TXCOMP` responses on the interrupt endpoint to trigger this code path.
In summary, this is a benign lockdep warning resulting from the `carl9170` driver using bottom-half (BH) spinlocks inside an URB completion handler that may be called with hardware interrupts disabled (depending on the specific USB Host Controller). It poses no security risk in production environments.
|
| 6/2 |
2026/07/05 07:50 |
llm |
expert |
0m
Model:
Tokens:
input: 25397
output: 43
thoughts: 998
Thoughts: **Analyzing a `__local_bh_enable_ip` Warning in the Kernel**
Okay, so I'm looking at this warning in `__local_bh_enable_ip` within `kernel/softirq.c:430`. The trigger is the classic `__lockdep_enabled && !this_cpu_read(hardirqs_enabled)` scenario. This immediately makes me think, "Why is this function, which is supposed to *enable* bottom halves, being called when hard interrupts are disabled?" That's a red flag.
Let's dive into the stack trace. The problem seems to originate in `carl9170_get_queued_skb` with the call to `spin_unlock_bh`. Tracing back, `carl9170_get_queued_skb` is called from `__carl9170_tx_process_status`, which calls `carl9170_tx_process_status`, which in turn is called from `carl9170_handle_command_response`, and then we get to `carl9170_usb_rx_irq_complete`.
Aha! `carl9170_usb_rx_irq_complete` is a USB URB completion handler. And I know that URB completion handlers can be invoked with interrupts disabled, or even from a softirq context. The trace shows `dummy_timer` being called from `hrtimer_run_softirq`. Bingo, `hrtimer_run_softirq` runs in softirq context. So `dummy_timer` is likely the culprit. But wait, `dummy_timer` disables interrupts? That's not what I expected.
Now, I need to understand what `dummy_timer` is actually doing. My immediate next step is to examine the source code for `dummy_timer` located in `drivers/usb/gadget/udc/dummy_hcd.c`. I'm going to leverage the `codesearch-definition-source` command to get the full picture. I need to understand the interaction between this timer function and the interrupt state. This is starting to look like a classic locking issue within the USB stack, possibly related to how the dummy HCD interacts with the carl9170 driver during interrupt processing or bottom half handling. I need to pinpoint where and how interrupts get disabled, and how that interacts with the spinlock in `carl9170_get_queued_skb`. This will allow me to determine if the locking hierarchy is correct.
|
| 7/2 |
2026/07/05 07:50 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/gadget/udc/dummy_hcd.c Name:dummy_timer]
Results: map[SourceCode:1793: /*
1794: * Drive both sides of the transfers; looks like irq handlers to both
1795: * drivers except that the callbacks are invoked from soft interrupt
1796: * context.
1797: */
1798: static enum hrtimer_restart dummy_timer(struct hrtimer *t)
1799: {
1800: struct dummy_hcd *dum_hcd = timer_container_of(dum_hcd, t,
1801: timer);
1802: struct dummy *dum = dum_hcd->dum;
1803: struct urbp *urbp, *tmp;
1804: unsigned long flags;
1805: int limit, total;
1806: int i;
1807:
1808: /* simplistic model for one frame's bandwidth */
1809: /* FIXME: account for transaction and packet overhead */
1810: switch (dum->gadget.speed) {
1811: case USB_SPEED_LOW:
1812: total = 8/*bytes*/ * 12/*packets*/;
1813: break;
1814: case USB_SPEED_FULL:
1815: total = 64/*bytes*/ * 19/*packets*/;
1816: break;
1817: case USB_SPEED_HIGH:
1818: total = 512/*bytes*/ * 13/*packets*/ * 8/*uframes*/;
1819: break;
1820: case USB_SPEED_SUPER:
1821: /* Bus speed is 500000 bytes/ms, so use a little less */
1822: total = 490000;
1823: break;
1824: default: /* Can't happen */
1825: dev_err(dummy_dev(dum_hcd), "bogus device speed\n");
1826: total = 0;
1827: break;
1828: }
1829:
1830: /* look at each urb queued by the host side driver */
1831: spin_lock_irqsave(&dum->lock, flags);
1832: dum_hcd->timer_pending = 0;
1833:
1834: if (!dum_hcd->udev) {
1835: dev_err(dummy_dev(dum_hcd),
1836: "timer fired with no URBs pending?\n");
1837: spin_unlock_irqrestore(&dum->lock, flags);
1838: return HRTIMER_NORESTART;
1839: }
1840: dum_hcd->next_frame_urbp = NULL;
1841:
1842: for (i = 0; i < DUMMY_ENDPOINTS; i++) {
1843: if (!ep_info[i].name)
1844: break;
1845: dum->ep[i].already_seen = 0;
1846: }
1847:
1848: restart:
1849: list_for_each_entry_safe(urbp, tmp, &dum_hcd->urbp_list, urbp_list) {
1850: struct urb *urb;
1851: struct dummy_request *req;
1852: u8 address;
1853: struct dummy_ep *ep = NULL;
1854: int status = -EINPROGRESS;
1855:
1856: /* stop when we reach URBs queued after the timer interrupt */
1857: if (urbp == dum_hcd->next_frame_urbp)
1858: break;
1859:
1860: urb = urbp->urb;
1861: if (urb->unlinked)
1862: goto return_urb;
1863: else if (dum_hcd->rh_state != DUMMY_RH_RUNNING)
1864: continue;
1865:
1866: /* Used up this frame's bandwidth? */
1867: if (total <= 0)
1868: continue;
1869:
1870: /* find the gadget's ep for this request (if configured) */
1871: address = usb_pipeendpoint (urb->pipe);
1872: if (usb_urb_dir_in(urb))
1873: address |= USB_DIR_IN;
1874: ep = find_endpoint(dum, address);
1875: if (!ep) {
1876: /* set_configuration() disagreement */
1877: dev_dbg(dummy_dev(dum_hcd),
1878: "no ep configured for urb %p\n",
1879: urb);
1880: status = -EPROTO;
1881: goto return_urb;
1882: }
1883:
1884: if (ep->already_seen)
1885: continue;
1886: ep->already_seen = 1;
1887: if (ep == &dum->ep[0] && urb->error_count) {
1888: ep->setup_stage = 1; /* a new urb */
1889: urb->error_count = 0;
1890: }
1891: if (ep->halted && !ep->setup_stage) {
1892: /* NOTE: must not be iso! */
1893: dev_dbg(dummy_dev(dum_hcd), "ep %s halted, urb %p\n",
1894: ep->ep.name, urb);
1895: status = -EPIPE;
1896: goto return_urb;
1897: }
1898: /* FIXME make sure both ends agree on maxpacket */
1899:
1900: /* handle control requests */
1901: if (ep == &dum->ep[0] && ep->setup_stage) {
1902: struct usb_ctrlrequest setup;
1903: int value;
1904:
1905: setup = *(struct usb_ctrlrequest *) urb->setup_packet;
1906: /* paranoia, in case of stale queued data */
1907: list_for_each_entry(req, &ep->queue, queue) {
1908: list_del_init(&req->queue);
1909: req->req.status = -EOVERFLOW;
1910: dev_dbg(udc_dev(dum), "stale req = %p\n",
1911: req);
1912:
1913: spin_unlock(&dum->lock);
1914: usb_gadget_giveback_request(&ep->ep, &req->req);
1915: spin_lock(&dum->lock);
1916: ep->already_seen = 0;
1917: goto restart;
1918: }
1919:
1920: /* gadget driver never sees set_address or operations
1921: * on standard feature flags. some hardware doesn't
1922: * even expose them.
1923: */
1924: ep->last_io = jiffies;
1925: ep->setup_stage = 0;
1926: ep->halted = 0;
1927:
1928: value = handle_control_request(dum_hcd, urb, &setup,
1929: &status);
1930:
1931: /* gadget driver handles all other requests. block
1932: * until setup() returns; no reentrancy issues etc.
1933: */
1934: if (value > 0) {
1935: ++dum->callback_usage;
1936: spin_unlock(&dum->lock);
1937: value = dum->driver->setup(&dum->gadget,
1938: &setup);
1939: spin_lock(&dum->lock);
1940: --dum->callback_usage;
1941:
1942: if (value >= 0) {
1943: /* no delays (max 64KB data stage) */
1944: limit = 64*1024;
1945: goto treat_control_like_bulk;
1946: }
1947: /* error, see below */
1948: }
1949:
1950: if (value < 0) {
1951: if (value != -EOPNOTSUPP)
1952: dev_dbg(udc_dev(dum),
1953: "setup --> %d\n",
1954: value);
1955: status = -EPIPE;
1956: urb->actual_length = 0;
1957: }
1958:
1959: goto return_urb;
1960: }
1961:
1962: /* non-control requests */
1963: limit = total;
1964: switch (usb_pipetype(urb->pipe)) {
1965: case PIPE_ISOCHRONOUS:
1966: /*
1967: * We don't support isochronous. But if we did,
1968: * here are some of the issues we'd have to face:
1969: *
1970: * Is it urb->interval since the last xfer?
1971: * Use urb->iso_frame_desc[i].
1972: * Complete whether or not ep has requests queued.
1973: * Report random errors, to debug drivers.
1974: */
1975: limit = max(limit, periodic_bytes(dum, ep));
1976: status = -EINVAL; /* fail all xfers */
1977: break;
1978:
1979: case PIPE_INTERRUPT:
1980: /* FIXME is it urb->interval since the last xfer?
1981: * this almost certainly polls too fast.
1982: */
1983: limit = max(limit, periodic_bytes(dum, ep));
1984: fallthrough;
1985:
1986: default:
1987: treat_control_like_bulk:
1988: ep->last_io = jiffies;
1989: total -= transfer(dum_hcd, urb, ep, limit, &status);
1990: break;
1991: }
1992:
1993: /* incomplete transfer? */
1994: if (status == -EINPROGRESS)
1995: continue;
1996:
1997: return_urb:
1998: list_del(&urbp->urbp_list);
1999: kfree(urbp);
2000: if (ep)
2001: ep->already_seen = ep->setup_stage = 0;
2002:
2003: usb_hcd_unlink_urb_from_ep(dummy_hcd_to_hcd(dum_hcd), urb);
2004: spin_unlock(&dum->lock);
2005: usb_hcd_giveback_urb(dummy_hcd_to_hcd(dum_hcd), urb, status);
2006: spin_lock(&dum->lock);
2007:
2008: goto restart;
2009: }
2010:
2011: if (list_empty(&dum_hcd->urbp_list)) {
2012: usb_put_dev(dum_hcd->udev);
2013: dum_hcd->udev = NULL;
2014: } else if (!dum_hcd->timer_pending &&
2015: dum_hcd->rh_state == DUMMY_RH_RUNNING) {
2016: /* want a 1 msec delay here */
2017: dum_hcd->timer_pending = 1;
2018: hrtimer_start(&dum_hcd->timer, ns_to_ktime(DUMMY_TIMER_INT_NSECS),
2019: HRTIMER_MODE_REL_SOFT);
2020: }
2021:
2022: spin_unlock_irqrestore(&dum->lock, flags);
2023:
2024: return HRTIMER_NORESTART;
2025: }
SourceFile:drivers/usb/gadget/udc/dummy_hcd.c]
|
| 8/2 |
2026/07/05 07:50 |
llm |
expert |
0m
Model:
Tokens:
input: 29491
output: 43
thoughts: 963
Thoughts: **Debugging a `WARN_ON_ONCE` in `__local_bh_enable_ip`**
Okay, so I'm staring at this `WARN_ON_ONCE` in `__local_bh_enable_ip`, specifically the one triggered in `kernel/softirq.c:430`. The warning condition is related to interrupts being disabled, which is unusual. But wait, it's actually `WARN_ON_ONCE(in_hardirq() || irqs_disabled())`. The stack trace gives us a good clue: it's hitting `spin_unlock_bh` from within `carl9170_get_queued_skb`, which itself is being called from the USB driver's interrupt handling path. It's: `dummy_timer` calls `usb_hcd_giveback_urb` with the `dum->lock` unlocked. Hmm, `dummy_timer` is an hrtimer callback in a softirq context.
The code for `dummy_timer` has a `spin_lock_irqsave(&dum->lock, flags);` then a `spin_unlock(&dum->lock);` before calling `usb_hcd_giveback_urb`. Bingo! The problem's right there. `spin_unlock` *doesn't* restore interrupts, only unlocks the spinlock. `spin_lock_irqsave` disables interrupts, saves the flags, and then `spin_unlock` just leaves them disabled! The code snippet confirms it:
```c
spin_lock_irqsave(&dum->lock, flags);
...
usb_hcd_unlink_urb_from_ep(dummy_hcd_to_hcd(dum_hcd), urb);
spin_unlock(&dum->lock);
usb_hcd_giveback_urb(dummy_hcd_to_hcd(dum_hcd), urb, status);
spin_lock(&dum->lock);
```
So, `usb_hcd_giveback_urb` is being called *with* interrupts disabled. Then `carl9170_usb_rx_irq_complete` goes down the call stack, hitting `spin_unlock_bh` ultimately. `spin_unlock_bh` calls `local_bh_enable`, which detects that interrupts are still disabled, and triggers the warning.
Now, a question arises: Is `usb_hcd_giveback_urb` *supposed* to be called with interrupts disabled? This could be a valid design pattern in the USB core. I'll need to check the documentation or the implementation of `usb_hcd_giveback_urb` to be sure.
|
| 9/2 |
2026/07/05 07:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/core/hcd.c Name:usb_hcd_giveback_urb]
Results: map[SourceCode:1710: /**
1711: * usb_hcd_giveback_urb - return URB from HCD to device driver
1712: * @hcd: host controller returning the URB
1713: * @urb: urb being returned to the USB device driver.
1714: * @status: completion status code for the URB.
1715: *
1716: * Context: atomic. The completion callback is invoked either in a work queue
1717: * (BH) context or in the caller's context, depending on whether the HCD_BH
1718: * flag is set in the @hcd structure, except that URBs submitted to the
1719: * root hub always complete in BH context.
1720: *
1721: * This hands the URB from HCD to its USB device driver, using its
1722: * completion function. The HCD has freed all per-urb resources
1723: * (and is done using urb->hcpriv). It also released all HCD locks;
1724: * the device driver won't cause problems if it frees, modifies,
1725: * or resubmits this URB.
1726: *
1727: * If @urb was unlinked, the value of @status will be overridden by
1728: * @urb->unlinked. Erroneous short transfers are detected in case
1729: * the HCD hasn't checked for them.
1730: */
1731: void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
1732: {
1733: struct giveback_urb_bh *bh;
1734: bool running;
1735:
1736: /* pass status to BH via unlinked */
1737: if (likely(!urb->unlinked))
1738: urb->unlinked = status;
1739:
1740: if (!hcd_giveback_urb_in_bh(hcd) && !is_root_hub(urb->dev)) {
1741: __usb_hcd_giveback_urb(urb);
1742: return;
1743: }
1744:
1745: if (usb_pipeisoc(urb->pipe) || usb_pipeint(urb->pipe))
1746: bh = &hcd->high_prio_bh;
1747: else
1748: bh = &hcd->low_prio_bh;
1749:
1750: spin_lock(&bh->lock);
1751: list_add_tail(&urb->urb_list, &bh->head);
1752: running = bh->running;
1753: spin_unlock(&bh->lock);
1754:
1755: if (running)
1756: ;
1757: else if (bh->high_prio)
1758: queue_work(system_bh_highpri_wq, &bh->bh);
1759: else
1760: queue_work(system_bh_wq, &bh->bh);
1761: }
SourceFile:drivers/usb/core/hcd.c]
|
| 10/2 |
2026/07/05 07:51 |
llm |
expert |
0m
Model:
Tokens:
input: 31017
output: 44
thoughts: 0
|
| 11/2 |
2026/07/05 07:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/core/hcd.c Name:__usb_hcd_giveback_urb]
Results: map[SourceCode:1630: static void __usb_hcd_giveback_urb(struct urb *urb)
1631: {
1632: struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus);
1633: struct usb_anchor *anchor = urb->anchor;
1634: int status = urb->unlinked;
1635:
1636: urb->hcpriv = NULL;
1637: if (unlikely((urb->transfer_flags & URB_SHORT_NOT_OK) &&
1638: urb->actual_length < urb->transfer_buffer_length &&
1639: !status))
1640: status = -EREMOTEIO;
1641:
1642: unmap_urb_for_dma(hcd, urb);
1643: usbmon_urb_complete(&hcd->self, urb, status);
1644: usb_anchor_suspend_wakeups(anchor);
1645: usb_unanchor_urb(urb);
1646: if (likely(status == 0))
1647: usb_led_activity(USB_LED_EVENT_HOST);
1648:
1649: /* pass ownership to the completion handler */
1650: urb->status = status;
1651: /*
1652: * This function can be called in task context inside another remote
1653: * coverage collection section, but kcov doesn't support that kind of
1654: * recursion yet. Only collect coverage in softirq context for now.
1655: */
1656: kcov_remote_start_usb_softirq((u64)urb->dev->bus->busnum);
1657: urb->complete(urb);
1658: kcov_remote_stop_softirq();
1659:
1660: usb_anchor_resume_wakeups(anchor);
1661: atomic_dec(&urb->use_count);
1662: /*
1663: * Order the write of urb->use_count above before the read
1664: * of urb->reject below. Pairs with the memory barriers in
1665: * usb_kill_urb() and usb_poison_urb().
1666: */
1667: smp_mb__after_atomic();
1668:
1669: if (unlikely(atomic_read(&urb->reject)))
1670: wake_up(&usb_kill_urb_queue);
1671: usb_put_urb(urb);
1672: }
SourceFile:drivers/usb/core/hcd.c]
|
| 12/2 |
2026/07/05 07:51 |
llm |
expert |
0m
Model:
Tokens:
input: 31795
output: 57
thoughts: 0
|
| 13/2 |
2026/07/05 07:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/usb.c Name:carl9170_usb_rx_irq_complete]
Results: map[SourceCode: 277: static void carl9170_usb_rx_irq_complete(struct urb *urb)
278: {
279: struct ar9170 *ar = urb->context;
280:
281: if (WARN_ON_ONCE(!ar))
282: return;
283:
284: switch (urb->status) {
285: /* everything is fine */
286: case 0:
287: break;
288:
289: /* disconnect */
290: case -ENOENT:
291: case -ECONNRESET:
292: case -ENODEV:
293: case -ESHUTDOWN:
294: return;
295:
296: default:
297: goto resubmit;
298: }
299:
300: /*
301: * While the carl9170 firmware does not use this EP, the
302: * firmware loader in the EEPROM unfortunately does.
303: * Therefore we need to be ready to handle out-of-band
304: * responses and traps in case the firmware crashed and
305: * the loader took over again.
306: */
307: carl9170_handle_command_response(ar, urb->transfer_buffer,
308: urb->actual_length);
309:
310: resubmit:
311: usb_anchor_urb(urb, &ar->rx_anch);
312: if (unlikely(usb_submit_urb(urb, GFP_ATOMIC)))
313: usb_unanchor_urb(urb);
314: }
SourceFile:drivers/net/wireless/ath/carl9170/usb.c]
|
| 14/2 |
2026/07/05 07:51 |
llm |
expert |
0m
Model:
Tokens:
input: 32395
output: 54
thoughts: 0
|
| 15/2 |
2026/07/05 07:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/rx.c Name:carl9170_handle_command_response]
Results: map[SourceCode: 161: void carl9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len)
162: {
163: struct carl9170_rsp *cmd = buf;
164: struct ieee80211_vif *vif;
165:
166: if ((cmd->hdr.cmd & CARL9170_RSP_FLAG) != CARL9170_RSP_FLAG) {
167: if (!(cmd->hdr.cmd & CARL9170_CMD_ASYNC_FLAG))
168: carl9170_cmd_callback(ar, len, buf);
169:
170: return;
171: }
172:
173: if (unlikely(cmd->hdr.len != (len - 4))) {
174: if (net_ratelimit()) {
175: wiphy_err(ar->hw->wiphy, "FW: received over-/under"
176: "sized event %x (%d, but should be %d).\n",
177: cmd->hdr.cmd, cmd->hdr.len, len - 4);
178:
179: print_hex_dump_bytes("dump:", DUMP_PREFIX_NONE,
180: buf, len);
181: }
182:
183: return;
184: }
185:
186: /* hardware event handlers */
187: switch (cmd->hdr.cmd) {
188: case CARL9170_RSP_PRETBTT:
189: /* pre-TBTT event */
190: rcu_read_lock();
191: vif = carl9170_get_main_vif(ar);
192:
193: if (!vif) {
194: rcu_read_unlock();
195: break;
196: }
197:
198: switch (vif->type) {
199: case NL80211_IFTYPE_STATION:
200: carl9170_handle_ps(ar, cmd);
201: break;
202:
203: case NL80211_IFTYPE_AP:
204: case NL80211_IFTYPE_ADHOC:
205: case NL80211_IFTYPE_MESH_POINT:
206: carl9170_update_beacon(ar, true);
207: break;
208:
209: default:
210: break;
211: }
212: rcu_read_unlock();
213:
214: break;
215:
216:
217: case CARL9170_RSP_TXCOMP:
218: /* TX status notification */
219: carl9170_tx_process_status(ar, cmd);
220: break;
221:
222: case CARL9170_RSP_BEACON_CONFIG:
223: /*
224: * (IBSS) beacon send notification
225: * bytes: 04 c2 XX YY B4 B3 B2 B1
226: *
227: * XX always 80
228: * YY always 00
229: * B1-B4 "should" be the number of send out beacons.
230: */
231: break;
232:
233: case CARL9170_RSP_ATIM:
234: /* End of Atim Window */
235: break;
236:
237: case CARL9170_RSP_WATCHDOG:
238: /* Watchdog Interrupt */
239: carl9170_restart(ar, CARL9170_RR_WATCHDOG);
240: break;
241:
242: case CARL9170_RSP_TEXT:
243: /* firmware debug */
244: carl9170_dbg_message(ar, (char *)buf + 4, len - 4);
245: break;
246:
247: case CARL9170_RSP_HEXDUMP:
248: wiphy_dbg(ar->hw->wiphy, "FW: HD %d\n", len - 4);
249: print_hex_dump_bytes("FW:", DUMP_PREFIX_NONE,
250: (char *)buf + 4, len - 4);
251: break;
252:
253: case CARL9170_RSP_RADAR:
254: if (!net_ratelimit())
255: break;
256:
257: wiphy_info(ar->hw->wiphy, "FW: RADAR! Please report this "
258: "incident to linux-wireless@vger.kernel.org !\n");
259: break;
260:
261: case CARL9170_RSP_GPIO:
262: #ifdef CONFIG_CARL9170_WPC
263: if (ar->wps.pbc) {
264: bool state = !!(cmd->gpio.gpio & cpu_to_le32(
265: AR9170_GPIO_PORT_WPS_BUTTON_PRESSED));
266:
267: if (state != ar->wps.pbc_state) {
268: ar->wps.pbc_state = state;
269: input_report_key(ar->wps.pbc, KEY_WPS_BUTTON,
270: state);
271: input_sync(ar->wps.pbc);
272: }
273: }
274: #endif /* CONFIG_CARL9170_WPC */
275: break;
276:
277: case CARL9170_RSP_BOOT:
278: complete(&ar->fw_boot_wait);
279: break;
280:
281: default:
282: wiphy_err(ar->hw->wiphy, "FW: received unhandled event %x\n",
283: cmd->hdr.cmd);
284: print_hex_dump_bytes("dump:", DUMP_PREFIX_NONE, buf, len);
285: break;
286: }
287: }
SourceFile:drivers/net/wireless/ath/carl9170/rx.c]
|
| 16/2 |
2026/07/05 07:51 |
llm |
expert |
0m
Model:
Tokens:
input: 34403
output: 54
thoughts: 0
|
| 17/2 |
2026/07/05 07:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/tx.c Name:carl9170_tx_process_status]
Results: map[SourceCode: 689: void carl9170_tx_process_status(struct ar9170 *ar,
690: const struct carl9170_rsp *cmd)
691: {
692: unsigned int i;
693:
694: for (i = 0; i < cmd->hdr.ext; i++) {
695: if (WARN_ON(i > ((cmd->hdr.len / 2) + 1))) {
696: print_hex_dump_bytes("UU:", DUMP_PREFIX_NONE,
697: (void *) cmd, cmd->hdr.len + 4);
698: break;
699: }
700:
701: __carl9170_tx_process_status(ar, cmd->_tx_status[i].cookie,
702: cmd->_tx_status[i].info);
703: }
704: }
SourceFile:drivers/net/wireless/ath/carl9170/tx.c]
|
| 18/2 |
2026/07/05 07:51 |
llm |
expert |
0m
Model:
Tokens:
input: 34767
output: 55
thoughts: 0
|
| 19/2 |
2026/07/05 07:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/tx.c Name:__carl9170_tx_process_status]
Results: map[SourceCode: 658: static void __carl9170_tx_process_status(struct ar9170 *ar,
659: const uint8_t cookie, const uint8_t info)
660: {
661: struct sk_buff *skb;
662: struct ieee80211_tx_info *txinfo;
663: unsigned int r, t, q;
664: bool success = true;
665:
666: q = ar9170_qmap(info & CARL9170_TX_STATUS_QUEUE);
667:
668: skb = carl9170_get_queued_skb(ar, cookie, &ar->tx_status[q]);
669: if (!skb) {
670: /*
671: * We have lost the race to another thread.
672: */
673:
674: return ;
675: }
676:
677: txinfo = IEEE80211_SKB_CB(skb);
678:
679: if (!(info & CARL9170_TX_STATUS_SUCCESS))
680: success = false;
681:
682: r = (info & CARL9170_TX_STATUS_RIX) >> CARL9170_TX_STATUS_RIX_S;
683: t = (info & CARL9170_TX_STATUS_TRIES) >> CARL9170_TX_STATUS_TRIES_S;
684:
685: carl9170_tx_fill_rateinfo(ar, r, t, txinfo);
686: carl9170_tx_status(ar, skb, success);
687: }
SourceFile:drivers/net/wireless/ath/carl9170/tx.c]
|
| 20/2 |
2026/07/05 07:51 |
llm |
expert |
0m
Model:
Tokens:
input: 35372
output: 55
thoughts: 0
|
| 21/2 |
2026/07/05 07:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/tx.c Name:carl9170_get_queued_skb]
Results: map[SourceCode: 513: static struct sk_buff *carl9170_get_queued_skb(struct ar9170 *ar, u8 cookie,
514: struct sk_buff_head *queue)
515: {
516: struct sk_buff *skb;
517:
518: spin_lock_bh(&queue->lock);
519: skb_queue_walk(queue, skb) {
520: struct _carl9170_tx_superframe *txc = (void *) skb->data;
521:
522: if (txc->s.cookie != cookie)
523: continue;
524:
525: __skb_unlink(skb, queue);
526: spin_unlock_bh(&queue->lock);
527:
528: carl9170_release_dev_space(ar, skb);
529: return skb;
530: }
531: spin_unlock_bh(&queue->lock);
532:
533: return NULL;
534: }
SourceFile:drivers/net/wireless/ath/carl9170/tx.c]
|
| 22/2 |
2026/07/05 07:51 |
llm |
expert |
0m
Model:
Tokens:
input: 35793
output: 39
thoughts: 2632
Thoughts: **Analysis of the Kernel SoftIRQ Warning**
Okay, here's the breakdown. This warning, `__lockdep_enabled && !this_cpu_read(hardirqs_enabled)`, in `kernel/softirq.c` signals a critical issue: `spin_unlock_bh` is being called when hard interrupts are disabled, which is a big no-no. It seems to originate from the `carl9170` driver, specifically within the `carl9170_get_queued_skb` function. The call stack reveals: `spin_unlock_bh` -> `carl9170_get_queued_skb` -> `__carl9170_tx_process_status` -> `carl9170_tx_process_status` -> `carl9170_handle_command_response` -> `carl9170_usb_rx_irq_complete` -> `__usb_hcd_giveback_urb` -> `usb_hcd_giveback_urb` and finally into the heart of the USB subsystem through `dummy_timer`.
Now, the `dummy_timer` is triggered from softirq context, via the hrtimer. In it, the code calls `spin_lock_irqsave` to disable interrupts, which is standard when dealing with shared resources. But then, `spin_unlock` is used instead of `spin_unlock_irqrestore`, which, critically, *doesn't* re-enable interrupts, leaving them disabled. This creates the problem, because `usb_hcd_giveback_urb` is called with interrupts disabled.
`usb_hcd_giveback_urb`'s documentation is clear: it can either execute in a work queue context (BH) or in the caller's context, depending on `HCD_BH` flag in the `hcd` structure, but URBs for root hub always complete in BH. The problem is that `dummy_hcd` might not have `HCD_BH` set, leading to the completion callback, `carl9170_usb_rx_irq_complete`, being called with interrupts disabled. This then goes into the `carl9170` driver.
The `carl9170_usb_rx_irq_complete` is the key. Its completion handler eventually calls `carl9170_get_queued_skb`, where the problem lies. It's using `spin_lock_bh` and `spin_unlock_bh`. Here's the catch: the first disables softirqs and the second enables them, but because `spin_unlock` *hasn't* restored the hard interrupts, enabling softirqs while hardirqs are disabled is what causes the kernel to WARN. The root cause is the `dummy_timer` that calls `usb_hcd_giveback_urb` with interrupts disabled by design.
Usually, completion handlers, like `carl9170_usb_rx_irq_complete`, are called with interrupts disabled because USB HCDs typically hold or disable interrupts during the call to `usb_hcd_giveback_urb`. If `carl9170` relies on interrupt context (as completion handler) and uses softirq lock, there's a problem. A correct solution would be to use `spin_lock_irqsave` or `spin_lock` if called from the interrupt context.
The warning itself might be triggered by a malicious USB device that emulates a `carl9170` device (idVendor=0x0cf3, idProduct=0x9271), sending a crafted response via an RX endpoint. This triggers the call chain, exposing the flaw.
The real question is: Can a non-root user trigger this? Yes, because the `syz_usb_connect_ath9k` and `syz_usb_ep_write` calls use the `dummy_hcd`, emulating a USB device, but this is a peripheral attack and not by an unprivileged user.
Finally, while the warning doesn't immediately crash the system, it's a serious violation of kernel assumptions. The function `__local_bh_enable_ip` shows that it WARNs if interrupts are disabled and then it enables softirqs, which causes the problem. If `CONFIG_TRACE_IRQFLAGS` isn't set, then no hardirqs will be enabled to create the correct execution flow for the analysis.
|
| 23/2 |
2026/07/05 07:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/softirq.c Name:__local_bh_enable_ip]
Results: map[SourceCode: 427: void __local_bh_enable_ip(unsigned long ip, unsigned int cnt)
428: {
429: WARN_ON_ONCE(in_hardirq());
430: lockdep_assert_irqs_enabled();
431: #ifdef CONFIG_TRACE_IRQFLAGS
432: local_irq_disable();
433: #endif
434: /*
435: * Are softirqs going to be turned on now:
436: */
437: if (softirq_count() == SOFTIRQ_DISABLE_OFFSET)
438: lockdep_softirqs_on(ip);
439: /*
440: * Keep preemption disabled until we are done with
441: * softirq processing:
442: */
443: __preempt_count_sub(cnt - 1);
444:
445: if (unlikely(!in_interrupt() && local_softirq_pending())) {
446: /*
447: * Run softirq if any pending. And do it in its own stack
448: * as we may be calling this deep in a task call stack already.
449: */
450: do_softirq();
451: }
452:
453: preempt_count_dec();
454: #ifdef CONFIG_TRACE_IRQFLAGS
455: local_irq_enable();
456: #endif
457: preempt_check_resched();
458: }
SourceFile:kernel/softirq.c]
|
| 24/2 |
2026/07/05 07:52 |
llm |
expert |
0m
Model:
Tokens:
input: 37292
output: 30
thoughts: 4393
Thoughts: **Analysis of a `spin_unlock_bh` Bug in the `carl9170` Driver**
Okay, here's the deal. I've got a `WARNING` at `kernel/softirq.c:430` that's yelling about `__lockdep_enabled && !this_cpu_read(hardirqs_enabled)`. The trace leads me through a call stack that's pointing the finger at `carl9170_get_queued_skb` in the `carl9170` wireless driver. Specifically, it's about the use of `spin_unlock_bh` within that function.
The core of the issue stems from `carl9170_get_queued_skb` being called within a USB URB completion handler (`carl9170_usb_rx_irq_complete`). URB completion handlers are generally called from `usb_hcd_giveback_urb`. The problem is that sometimes, HCDs might call `usb_hcd_giveback_urb` with interrupts *disabled*. This is because `usb_hcd_giveback_urb` is called from the `dummy_timer` which, in the case of `dummy_hcd`, disables interrupts before making the call. But `spin_unlock_bh` enables softirqs, expecting hardirqs to be enabled. So, we have a context where hard interrupts are disabled, and then we're enabling BH, which is not correct.
The critical piece is that the `carl9170` driver uses `spin_lock_bh` and `spin_unlock_bh` to protect access to a queue. These functions assume they're operating in a context where they can disable/enable bottom halves (BH) β meaning they assume interrupts are enabled. However, the URB completion handler can be called with interrupts disabled. This mismatch, triggered by the `dummy_timer` (part of the `dummy_hcd`), is the root cause of the warning. This is a clear bug in the `carl9170` driver.
Now, is this a real vulnerability? Well, it's just a warning. In production builds, the `lockdep_assert_irqs_enabled()` check is a no-op, but the `WARN_ON_ONCE(in_hardirq())` might trigger. If it's called from a real hardware interrupt, then `in_hardirq()` will be true, and the `WARN_ON_ONCE` will trigger. But `WARN_ON_ONCE` only prints a warning and continues. It seems the code is not exploitable in the classic sense (memory corruption, etc.), but it is a sign of incorrect locking. The `spin_unlock_bh` might try to process softirqs with interrupts disabled, which is bad, but, if it's called from hardirq, the `in_interrupt()` check is true, so it doesn't call `do_softirq()` that could enable interrupts with an interrupt safe lock held and cause a deadlock.
The important question is whether a malicious device can trigger this. The answer is yes. Since `dummy_hcd` is being used to emulate a USB device (via syzkaller), the issue can indeed be reproduced by a malicious USB device. It can be triggered by a peripheral (USB), and, while not triggered remotely, requires specific communications between the USB device and host driver. A malicious firmware (or USB device) can send this to trigger this, or, in fact, normal operation of the device can trigger it as the legitimate firmware sends a `CARL9170_RSP_TXCOMP` response.
Now, while `dummy_hcd` uses a softirq, most other HCDs (xhci, ehci) defer URB completions to a tasklet/BH using `hcd_giveback_urb_in_bh`, and, in this case, `spin_lock_bh` is perfectly fine! The problem is that the interrupt-disabling situation can happen in many different HCD drivers.
The fundamental fix is that URB completion handlers MUST NOT use `spin_lock_bh` / `spin_unlock_bh`. They need to use either `spin_lock_irqsave` / `spin_unlock_irqrestore` or `spin_lock` / `spin_unlock` *if they know they're in an interrupt context.* Since the `carl9170` driver uses the wrong locking primitives in its URB completion handler, a warning can be generated.
|
| 25/2 |
2026/07/05 07:52 |
tool |
grepper |
0m
Args: map[Expression:HCD_BH PathPrefix:drivers/usb/host/]
Results: map[Output:drivers/usb/host/ehci-grlib.c=24=static const struct hc_driver ehci_grlib_hc_driver = {
--
drivers/usb/host/ehci-grlib.c-32- .irq = ehci_irq,
drivers/usb/host/ehci-grlib.c:33: .flags = HCD_MEMORY | HCD_DMA | HCD_USB2 | HCD_BH,
drivers/usb/host/ehci-grlib.c-34-
--
drivers/usb/host/ehci-hcd.c=1239=static const struct hc_driver ehci_hc_driver = {
--
drivers/usb/host/ehci-hcd.c-1247- .irq = ehci_irq,
drivers/usb/host/ehci-hcd.c:1248: .flags = HCD_MEMORY | HCD_DMA | HCD_USB2 | HCD_BH,
drivers/usb/host/ehci-hcd.c-1249-
--
drivers/usb/host/ehci-ppc-of.c=25=static const struct hc_driver ehci_ppc_of_hc_driver = {
--
drivers/usb/host/ehci-ppc-of.c-33- .irq = ehci_irq,
drivers/usb/host/ehci-ppc-of.c:34: .flags = HCD_MEMORY | HCD_DMA | HCD_USB2 | HCD_BH,
drivers/usb/host/ehci-ppc-of.c-35-
--
drivers/usb/host/ehci-ps3.c=57=static const struct hc_driver ps3_ehci_hc_driver = {
--
drivers/usb/host/ehci-ps3.c-61- .irq = ehci_irq,
drivers/usb/host/ehci-ps3.c:62: .flags = HCD_MEMORY | HCD_DMA | HCD_USB2 | HCD_BH,
drivers/usb/host/ehci-ps3.c-63- .reset = ps3_ehci_hc_reset,
--
drivers/usb/host/ehci-sh.c=26=static const struct hc_driver ehci_sh_hc_driver = {
--
drivers/usb/host/ehci-sh.c-34- .irq = ehci_irq,
drivers/usb/host/ehci-sh.c:35: .flags = HCD_USB2 | HCD_DMA | HCD_MEMORY | HCD_BH,
drivers/usb/host/ehci-sh.c-36-
--
drivers/usb/host/ehci-xilinx-of.c=60=static const struct hc_driver ehci_xilinx_of_hc_driver = {
--
drivers/usb/host/ehci-xilinx-of.c-68- .irq = ehci_irq,
drivers/usb/host/ehci-xilinx-of.c:69: .flags = HCD_MEMORY | HCD_DMA | HCD_USB2 | HCD_BH,
drivers/usb/host/ehci-xilinx-of.c-70-
--
drivers/usb/host/xhci.c=5574=static const struct hc_driver xhci_hc_driver = {
--
drivers/usb/host/xhci.c-5583- .flags = HCD_MEMORY | HCD_DMA | HCD_USB3 | HCD_SHARED |
drivers/usb/host/xhci.c:5584: HCD_BH,
drivers/usb/host/xhci.c-5585-
]
|
| 26/2 |
2026/07/05 07:52 |
llm |
expert |
0m
Model:
Tokens:
input: 39268
output: 40
thoughts: 0
|
| 27/2 |
2026/07/05 07:52 |
tool |
grepper |
0m
Error:
Args: map[Expression:HCD_BH PathPrefix:drivers/usb/gadget/udc/dummy_hcd.c]
Results:
|
| 28/2 |
2026/07/05 07:52 |
llm |
expert |
0m
Model:
Tokens:
input: 39322
output: 40
thoughts: 1205
Thoughts: **Analyzing a Lockdep Warning in the Carl9170 Driver**
Okay, I'm looking at this lockdep warning. It's complaining about `__lockdep_enabled && !this_cpu_read(hardirqs_enabled)` at `kernel/softirq.c:430` in `__local_bh_enable_ip`, and specifically that this happens in `spin_unlock_bh` when hardirqs are disabled. The call trace points to an issue within the `carl9170` wireless driver. Let's trace this out.
`spin_unlock_bh` is the culprit. From the trace, it's called from `carl9170_get_queued_skb`. This function appears to be using `spin_lock_bh` and `spin_unlock_bh`, which is fine in isolation. However, `spin_unlock_bh` is supposed to be called with hardirqs *enabled* because it enables softirqs, and `do_softirq` expects that. I thought it did the checks itself? It calls `local_bh_enable()`, which checks `!in_hardirq()` and `!irqs_disabled()`.
The call trace goes through `__carl9170_tx_process_status`, then into the USB subsystem via `carl9170_handle_command_response` which eventually lands in `dummy_timer`. Aha, `dummy_timer` is called from a softirq context, specifically the hrtimer softirq. Now, `dummy_timer` calls `usb_hcd_giveback_urb` which calls `__usb_hcd_giveback_urb` directly because `dummy_hcd` doesn't have the `HCD_BH` flag set.
Wait, does `__usb_hcd_giveback_urb` call `urb->complete(urb)` with hardirqs disabled? Let's verify by checking the code in `dummy_timer`.
Okay, `dummy_timer` has a `spin_lock_irqsave(&dum->lock, flags);` call at line 1831. It then calls `usb_hcd_giveback_urb` *with* the lock held, right? Wait, no. `dummy_timer` actually does:
```c
usb_hcd_unlink_urb_from_ep(dummy_hcd_to_hcd(dum_hcd), urb);
spin_unlock(&dum->lock);
usb_hcd_giveback_urb(dummy_hcd_to_hcd(dum_hcd), urb, status);
spin_lock(&dum->lock);
```
So it unlocks `dum->lock` *before* calling `usb_hcd_giveback_urb`.
But we know `dummy_timer` is called from `hrtimer_run_softirq` which runs in the softirq context. Are hardirqs disabled in `hrtimer_run_softirq`? I need to check the code for `hrtimer_run_softirq` directly.
|
| 29/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c Name:hrtimer_run_softirq]
Results: map[SourceCode:2103: static __latent_entropy void hrtimer_run_softirq(void)
2104: {
2105: struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases);
2106: unsigned long flags;
2107: ktime_t now;
2108:
2109: hrtimer_cpu_base_lock_expiry(cpu_base);
2110: raw_spin_lock_irqsave(&cpu_base->lock, flags);
2111:
2112: now = hrtimer_update_base(cpu_base);
2113: __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_SOFT);
2114:
2115: cpu_base->softirq_activated = false;
2116: hrtimer_update_softirq_timer(cpu_base, true);
2117:
2118: raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
2119: hrtimer_cpu_base_unlock_expiry(cpu_base);
2120: }
SourceFile:kernel/time/hrtimer.c]
|
| 30/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 40390
output: 40
thoughts: 0
|
| 31/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c Name:__hrtimer_run_queues]
Results: map[SourceCode:2070: static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now,
2071: unsigned long flags, unsigned int active_mask)
2072: {
2073: unsigned int active = cpu_base->active_bases & active_mask;
2074: struct hrtimer_clock_base *base;
2075:
2076: for_each_active_base(base, cpu_base, active) {
2077: ktime_t basenow = ktime_add(now, base->offset);
2078: struct hrtimer *timer;
2079:
2080: while ((timer = clock_base_next_timer(base))) {
2081: /*
2082: * The immediate goal for using the softexpires is
2083: * minimizing wakeups, not running timers at the
2084: * earliest interrupt after their soft expiration.
2085: * This allows us to avoid using a Priority Search
2086: * Tree, which can answer a stabbing query for
2087: * overlapping intervals and instead use the simple
2088: * BST we already have.
2089: * We don't add extra wakeups by delaying timers that
2090: * are right-of a not yet expired timer, because that
2091: * timer will have to trigger a wakeup anyway.
2092: */
2093: if (basenow < hrtimer_get_softexpires(timer))
2094: break;
2095:
2096: __run_hrtimer(cpu_base, base, timer, basenow, flags);
2097: if (active_mask == HRTIMER_ACTIVE_SOFT)
2098: hrtimer_sync_wait_running(cpu_base, flags);
2099: }
2100: }
2101: }
SourceFile:kernel/time/hrtimer.c]
|
| 32/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 40983
output: 37
thoughts: 0
|
| 33/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c Name:__run_hrtimer]
Results: map[SourceCode:1973: /*
1974: * The write_seqcount_barrier()s in __run_hrtimer() split the thing into 3
1975: * distinct sections:
1976: *
1977: * - queued: the timer is queued
1978: * - callback: the timer is being ran
1979: * - post: the timer is inactive or (re)queued
1980: *
1981: * On the read side we ensure we observe timer->is_queued and cpu_base->running
1982: * from the same section, if anything changed while we looked at it, we retry.
1983: * This includes timer->base changing because sequence numbers alone are
1984: * insufficient for that.
1985: *
1986: * The sequence numbers are required because otherwise we could still observe
1987: * a false negative if the read side got smeared over multiple consecutive
1988: * __run_hrtimer() invocations.
1989: */
1990: static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base, struct hrtimer_clock_base *base,
1991: struct hrtimer *timer, ktime_t now, unsigned long flags)
1992: __must_hold(&cpu_base->lock)
1993: {
1994: enum hrtimer_restart (*fn)(struct hrtimer *);
1995: bool expires_in_hardirq;
1996: int restart;
1997:
1998: lockdep_assert_held(&cpu_base->lock);
1999:
2000: debug_hrtimer_deactivate(timer);
2001: base->running = timer;
2002:
2003: /*
2004: * Separate the ->running assignment from the ->is_queued assignment.
2005: *
2006: * As with a regular write barrier, this ensures the read side in
2007: * hrtimer_active() cannot observe base->running == NULL &&
2008: * timer->is_queued == INACTIVE.
2009: */
2010: raw_write_seqcount_barrier(&base->seq);
2011:
2012: __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, false);
2013: fn = ACCESS_PRIVATE(timer, function);
2014:
2015: /*
2016: * Clear the 'is relative' flag for the TIME_LOW_RES case. If the
2017: * timer is restarted with a period then it becomes an absolute
2018: * timer. If its not restarted it does not matter.
2019: */
2020: if (IS_ENABLED(CONFIG_TIME_LOW_RES))
2021: timer->is_rel = false;
2022:
2023: /*
2024: * The timer is marked as running in the CPU base, so it is
2025: * protected against migration to a different CPU even if the lock
2026: * is dropped.
2027: */
2028: raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
2029: trace_hrtimer_expire_entry(timer, now);
2030: expires_in_hardirq = lockdep_hrtimer_enter(timer);
2031:
2032: restart = fn(timer);
2033:
2034: lockdep_hrtimer_exit(expires_in_hardirq);
2035: trace_hrtimer_expire_exit(timer);
2036: raw_spin_lock_irq(&cpu_base->lock);
2037:
2038: /*
2039: * Note: We clear the running state after enqueue_hrtimer and
2040: * we do not reprogram the event hardware. Happens either in
2041: * hrtimer_start_range_ns() or in hrtimer_interrupt()
2042: *
2043: * Note: Because we dropped the cpu_base->lock above,
2044: * hrtimer_start_range_ns() can have popped in and enqueued the timer
2045: * for us already.
2046: */
2047: if (restart == HRTIMER_RESTART && !timer->is_queued)
2048: enqueue_hrtimer(timer, base, HRTIMER_MODE_ABS, false);
2049:
2050: /*
2051: * Separate the ->running assignment from the ->is_queued assignment.
2052: *
2053: * As with a regular write barrier, this ensures the read side in
2054: * hrtimer_active() cannot observe base->running.timer == NULL &&
2055: * timer->is_queued == INACTIVE.
2056: */
2057: raw_write_seqcount_barrier(&base->seq);
2058:
2059: WARN_ON_ONCE(base->running != timer);
2060: base->running = NULL;
2061: }
SourceFile:kernel/time/hrtimer.c]
|
| 34/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 42458
output: 52
thoughts: 0
|
| 35/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/tx.c Name:carl9170_tx_status]
Results: map[SourceCode: 476: void carl9170_tx_status(struct ar9170 *ar, struct sk_buff *skb,
477: const bool success)
478: {
479: struct ieee80211_tx_info *txinfo;
480:
481: carl9170_tx_accounting_free(ar, skb);
482:
483: txinfo = IEEE80211_SKB_CB(skb);
484:
485: carl9170_tx_bar_status(ar, skb, txinfo);
486:
487: if (success)
488: txinfo->flags |= IEEE80211_TX_STAT_ACK;
489: else
490: ar->tx_ack_failures++;
491:
492: if (txinfo->flags & IEEE80211_TX_CTL_AMPDU)
493: carl9170_tx_status_process_ampdu(ar, skb, txinfo);
494:
495: carl9170_tx_ps_unblock(ar, skb);
496: carl9170_tx_put_skb(skb);
497: }
SourceFile:drivers/net/wireless/ath/carl9170/tx.c]
|
| 36/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 42925
output: 55
thoughts: 0
|
| 37/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/tx.c Name:carl9170_tx_put_skb]
Results: map[SourceCode: 338: int carl9170_tx_put_skb(struct sk_buff *skb)
339: {
340: struct carl9170_tx_info *arinfo = (void *)
341: (IEEE80211_SKB_CB(skb))->rate_driver_data;
342:
343: return kref_put(&arinfo->ref, carl9170_tx_release);
344: }
SourceFile:drivers/net/wireless/ath/carl9170/tx.c]
|
| 38/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 43157
output: 52
thoughts: 0
|
| 39/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/tx.c Name:carl9170_tx_release]
Results: map[SourceCode: 261: /* Called from any context */
262: static void carl9170_tx_release(struct kref *ref)
263: {
264: struct ar9170 *ar;
265: struct carl9170_tx_info *arinfo;
266: struct ieee80211_tx_info *txinfo;
267: struct sk_buff *skb;
268:
269: arinfo = container_of(ref, struct carl9170_tx_info, ref);
270: txinfo = container_of((void *) arinfo, struct ieee80211_tx_info,
271: rate_driver_data);
272: skb = container_of((void *) txinfo, struct sk_buff, cb);
273:
274: ar = arinfo->ar;
275: if (WARN_ON_ONCE(!ar))
276: return;
277:
278: /*
279: * This does not call ieee80211_tx_info_clear_status() because
280: * carl9170_tx_fill_rateinfo() has filled the rate information
281: * before we get to this point.
282: */
283: memset(&txinfo->pad, 0, sizeof(txinfo->pad));
284: memset(&txinfo->rate_driver_data, 0, sizeof(txinfo->rate_driver_data));
285:
286: if (atomic_read(&ar->tx_total_queued))
287: ar->tx_schedule = true;
288:
289: if (txinfo->flags & IEEE80211_TX_CTL_AMPDU) {
290: if (!atomic_read(&ar->tx_ampdu_upload))
291: ar->tx_ampdu_schedule = true;
292:
293: if (txinfo->flags & IEEE80211_TX_STAT_AMPDU) {
294: struct _carl9170_tx_superframe *super;
295:
296: super = (void *)skb->data;
297: txinfo->status.ampdu_len = super->s.rix;
298: txinfo->status.ampdu_ack_len = super->s.cnt;
299: } else if ((txinfo->flags & IEEE80211_TX_STAT_ACK) &&
300: !(txinfo->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) {
301: /*
302: * drop redundant tx_status reports:
303: *
304: * 1. ampdu_ack_len of the final tx_status does
305: * include the feedback of this particular frame.
306: *
307: * 2. tx_status_irqsafe only queues up to 128
308: * tx feedback reports and discards the rest.
309: *
310: * 3. minstrel_ht is picky, it only accepts
311: * reports of frames with the TX_STATUS_AMPDU flag.
312: *
313: * 4. mac80211 is not particularly interested in
314: * feedback either [CTL_REQ_TX_STATUS not set]
315: */
316:
317: ieee80211_free_txskb(ar->hw, skb);
318: return;
319: } else {
320: /*
321: * Either the frame transmission has failed or
322: * mac80211 requested tx status.
323: */
324: }
325: }
326:
327: skb_pull(skb, sizeof(struct _carl9170_tx_superframe));
328: ieee80211_tx_status_irqsafe(ar->hw, skb);
329: }
SourceFile:drivers/net/wireless/ath/carl9170/tx.c]
|
| 40/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 44422
output: 51
thoughts: 0
|
| 41/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/tx.c Name:ieee80211_tx_status_irqsafe]
Results: map[SourceCode: 22: void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
23: struct sk_buff *skb)
24: {
25: struct ieee80211_local *local = hw_to_local(hw);
26: struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
27: int tmp;
28:
29: skb->pkt_type = IEEE80211_TX_STATUS_MSG;
30: skb_queue_tail(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS ?
31: &local->skb_queue : &local->skb_queue_unreliable, skb);
32: tmp = skb_queue_len(&local->skb_queue) +
33: skb_queue_len(&local->skb_queue_unreliable);
34: while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
35: (skb = skb_dequeue(&local->skb_queue_unreliable))) {
36: ieee80211_free_txskb(hw, skb);
37: tmp--;
38: I802_DEBUG_INC(local->tx_status_drop);
39: }
40: tasklet_schedule(&local->tasklet);
41: }
SourceFile:net/mac80211/status.c]
|
| 42/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 44915
output: 49
thoughts: 0
|
| 43/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/tx.c Name:ieee80211_free_txskb]
Results: map[SourceCode:1314: void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb)
1315: {
1316: struct ieee80211_local *local = hw_to_local(hw);
1317: ktime_t kt = ktime_set(0, 0);
1318:
1319: ieee80211_report_used_skb(local, skb, true, kt);
1320: dev_kfree_skb_any(skb);
1321: }
SourceFile:net/mac80211/status.c]
|
| 44/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 45167
output: 50
thoughts: 0
|
| 45/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/tx.c Name:ieee80211_report_used_skb]
Results: map[SourceCode: 756: static void ieee80211_report_used_skb(struct ieee80211_local *local,
757: struct sk_buff *skb, bool dropped,
758: ktime_t ack_hwtstamp)
759: {
760: struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
761: u16 tx_time_est = ieee80211_info_get_tx_time_est(info);
762: struct ieee80211_hdr *hdr = (void *)skb->data;
763: bool acked = info->flags & IEEE80211_TX_STAT_ACK;
764:
765: if (dropped)
766: acked = false;
767:
768: if (tx_time_est) {
769: struct sta_info *sta;
770:
771: rcu_read_lock();
772:
773: sta = sta_info_get_by_addrs(local, hdr->addr1, hdr->addr2);
774: ieee80211_sta_update_pending_airtime(local, sta,
775: skb_get_queue_mapping(skb),
776: tx_time_est,
777: true);
778: rcu_read_unlock();
779: }
780:
781: if (info->flags & IEEE80211_TX_INTFL_MLME_CONN_TX) {
782: struct ieee80211_sub_if_data *sdata;
783:
784: rcu_read_lock();
785:
786: sdata = ieee80211_sdata_from_skb(local, skb);
787:
788: if (!sdata) {
789: skb->dev = NULL;
790: } else if (!dropped) {
791: /* Check to see if packet is a TDLS teardown packet */
792: if (ieee80211_is_data(hdr->frame_control) &&
793: (ieee80211_get_tdls_action(skb) ==
794: WLAN_TDLS_TEARDOWN)) {
795: ieee80211_tdls_td_tx_handle(local, sdata, skb,
796: info->flags);
797: } else if (ieee80211_s1g_is_twt_setup(skb)) {
798: if (!acked) {
799: struct sk_buff *qskb;
800:
801: qskb = skb_clone(skb, GFP_ATOMIC);
802: if (qskb) {
803: skb_queue_tail(&sdata->status_queue,
804: qskb);
805: wiphy_work_queue(local->hw.wiphy,
806: &sdata->work);
807: }
808: }
809: } else {
810: ieee80211_mgd_conn_tx_status(sdata,
811: hdr->frame_control,
812: acked);
813: }
814: }
815:
816: rcu_read_unlock();
817: } else if (info->status_data_idr) {
818: ieee80211_report_ack_skb(local, skb, acked, dropped,
819: ack_hwtstamp);
820: } else if (info->status_data) {
821: struct ieee80211_sub_if_data *sdata;
822:
823: rcu_read_lock();
824:
825: sdata = ieee80211_sdata_from_skb(local, skb);
826:
827: switch (u16_get_bits(info->status_data,
828: IEEE80211_STATUS_TYPE_MASK)) {
829: case IEEE80211_STATUS_TYPE_SMPS:
830: ieee80211_handle_smps_status(sdata, acked,
831: info->status_data);
832: break;
833: case IEEE80211_STATUS_TYPE_NEG_TTLM:
834: ieee80211_handle_teardown_ttlm_status(sdata, acked);
835: break;
836: case IEEE80211_STATUS_TYPE_UHR_OMP:
837: ieee80211_handle_uhr_omp_status(sdata, acked);
838: break;
839: }
840: rcu_read_unlock();
841: }
842:
843: if (!dropped && skb->destructor) {
844: skb->wifi_acked_valid = 1;
845: skb->wifi_acked = acked;
846: }
847:
848: ieee80211_led_tx(local);
849:
850: if (skb_has_frag_list(skb)) {
851: kfree_skb_list(skb_shinfo(skb)->frag_list);
852: skb_shinfo(skb)->frag_list = NULL;
853: }
854: }
SourceFile:net/mac80211/status.c]
|
| 46/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 46927
output: 53
thoughts: 0
|
| 47/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/tx.c Name:ieee80211_info_get_tx_time_est]
Results: map[SourceCode:1425: static inline u16
1426: ieee80211_info_get_tx_time_est(struct ieee80211_tx_info *info)
1427: {
1428: return info->tx_time_est << 2;
1429: }
SourceFile:include/net/mac80211.h]
|
| 48/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 47102
output: 52
thoughts: 0
|
| 49/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/tx.c Name:ieee80211_sta_update_pending_airtime]
Results: map[SourceCode:2485: void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local,
2486: struct sta_info *sta, u8 ac,
2487: u16 tx_airtime, bool tx_completed)
2488: {
2489: int tx_pending;
2490:
2491: if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL))
2492: return;
2493:
2494: if (!tx_completed) {
2495: if (sta)
2496: atomic_add(tx_airtime,
2497: &sta->airtime[ac].aql_tx_pending);
2498:
2499: atomic_add(tx_airtime, &local->aql_total_pending_airtime);
2500: atomic_add(tx_airtime, &local->aql_ac_pending_airtime[ac]);
2501: return;
2502: }
2503:
2504: if (sta) {
2505: tx_pending = atomic_sub_return(tx_airtime,
2506: &sta->airtime[ac].aql_tx_pending);
2507: if (tx_pending < 0)
2508: atomic_cmpxchg(&sta->airtime[ac].aql_tx_pending,
2509: tx_pending, 0);
2510: }
2511:
2512: atomic_sub(tx_airtime, &local->aql_total_pending_airtime);
2513: tx_pending = atomic_sub_return(tx_airtime,
2514: &local->aql_ac_pending_airtime[ac]);
2515: if (WARN_ONCE(tx_pending < 0,
2516: "Device %s AC %d pending airtime underflow: %u, %u",
2517: wiphy_name(local->hw.wiphy), ac, tx_pending,
2518: tx_airtime)) {
2519: atomic_cmpxchg(&local->aql_ac_pending_airtime[ac],
2520: tx_pending, 0);
2521: atomic_sub(tx_pending, &local->aql_total_pending_airtime);
2522: }
2523: }
SourceFile:net/mac80211/sta_info.c]
|
| 50/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 47886
output: 51
thoughts: 0
|
| 51/2 |
2026/07/05 07:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/tx.c Name:ieee80211_sdata_from_skb]
Results: map[SourceCode: 572: static struct ieee80211_sub_if_data *
573: ieee80211_sdata_from_skb(struct ieee80211_local *local, struct sk_buff *skb)
574: {
575: struct ieee80211_sub_if_data *sdata;
576: struct ieee80211_hdr *hdr = (void *)skb->data;
577:
578: if (skb->dev) {
579: list_for_each_entry_rcu(sdata, &local->interfaces, list) {
580: if (!sdata->dev)
581: continue;
582:
583: if (skb->dev == sdata->dev)
584: return sdata;
585: }
586:
587: return NULL;
588: }
589:
590: list_for_each_entry_rcu(sdata, &local->interfaces, list) {
591: switch (sdata->vif.type) {
592: case NL80211_IFTYPE_P2P_DEVICE:
593: break;
594: case NL80211_IFTYPE_NAN:
595: if (sdata->u.nan.started)
596: break;
597: fallthrough;
598: default:
599: continue;
600: }
601:
602: if (ether_addr_equal(sdata->vif.addr, hdr->addr2))
603: return sdata;
604: }
605:
606: return NULL;
607: }
SourceFile:net/mac80211/status.c]
|
| 52/2 |
2026/07/05 07:53 |
llm |
expert |
0m
Model:
Tokens:
input: 48493
output: 47
thoughts: 0
|
| 53/2 |
2026/07/05 07:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/tx.c Name:ieee80211_is_data]
Results: map[SourceCode: 461: /**
462: * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
463: * @fc: frame control bytes in little-endian byteorder
464: * Return: whether or not the frame is a data frame
465: */
466: static inline bool ieee80211_is_data(__le16 fc)
467: {
468: return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
469: cpu_to_le16(IEEE80211_FTYPE_DATA);
470: }
SourceFile:include/linux/ieee80211.h]
|
| 54/2 |
2026/07/05 07:54 |
llm |
expert |
0m
Model:
Tokens:
input: 48770
output: 50
thoughts: 0
|
| 55/2 |
2026/07/05 07:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/tx.c Name:ieee80211_get_tdls_action]
Results: map[SourceCode:2587: /**
2588: * ieee80211_get_tdls_action - get TDLS action code
2589: * @skb: the skb containing the frame, length will not be checked
2590: * Return: the TDLS action code, or -1 if it's not an encapsulated TDLS action
2591: * frame
2592: *
2593: * This function assumes the frame is a data frame, and that the network header
2594: * is in the correct place.
2595: */
2596: static inline int ieee80211_get_tdls_action(struct sk_buff *skb)
2597: {
2598: if (!skb_is_nonlinear(skb) &&
2599: skb->len > (skb_network_offset(skb) + 2)) {
2600: /* Point to where the indication of TDLS should start */
2601: const u8 *tdls_data = skb_network_header(skb) - 2;
2602:
2603: if (get_unaligned_be16(tdls_data) == ETH_P_TDLS &&
2604: tdls_data[2] == WLAN_TDLS_SNAP_RFTYPE &&
2605: tdls_data[3] == WLAN_CATEGORY_TDLS)
2606: return tdls_data[4];
2607: }
2608:
2609: return -1;
2610: }
SourceFile:include/linux/ieee80211.h]
|
| 56/2 |
2026/07/05 07:54 |
llm |
expert |
0m
Model:
Tokens:
input: 49284
output: 52
thoughts: 0
|
| 57/2 |
2026/07/05 07:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/tx.c Name:ieee80211_tdls_td_tx_handle]
Results: map[SourceCode: 533: /*
534: * Handles the tx for TDLS teardown frames.
535: * If the frame wasn't ACKed by the peer - it will be re-sent through the AP
536: */
537: static void ieee80211_tdls_td_tx_handle(struct ieee80211_local *local,
538: struct ieee80211_sub_if_data *sdata,
539: struct sk_buff *skb, u32 flags)
540: {
541: struct sk_buff *teardown_skb;
542: struct sk_buff *orig_teardown_skb;
543: bool is_teardown = false;
544:
545: /* Get the teardown data we need and free the lock */
546: spin_lock(&sdata->u.mgd.teardown_lock);
547: teardown_skb = sdata->u.mgd.teardown_skb;
548: orig_teardown_skb = sdata->u.mgd.orig_teardown_skb;
549: if ((skb == orig_teardown_skb) && teardown_skb) {
550: sdata->u.mgd.teardown_skb = NULL;
551: sdata->u.mgd.orig_teardown_skb = NULL;
552: is_teardown = true;
553: }
554: spin_unlock(&sdata->u.mgd.teardown_lock);
555:
556: if (is_teardown) {
557: /* This mechanism relies on being able to get ACKs */
558: WARN_ON(!ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS));
559:
560: /* Check if peer has ACKed */
561: if (flags & IEEE80211_TX_STAT_ACK) {
562: dev_kfree_skb_any(teardown_skb);
563: } else {
564: tdls_dbg(sdata,
565: "TDLS Resending teardown through AP\n");
566:
567: ieee80211_subif_start_xmit(teardown_skb, skb->dev);
568: }
569: }
570: }
SourceFile:net/mac80211/status.c]
|
| 58/2 |
2026/07/05 07:54 |
llm |
expert |
0m
Model:
Tokens:
input: 60272
output: 38
thoughts: 1311
Thoughts: **Analyzing the Lockdep Warning in `carl9170_get_queued_skb`**
Okay, so I'm looking at this lockdep warning: `__lockdep_enabled && !this_cpu_read(hardirqs_enabled)` in `kernel/softirq.c:430`, triggered by `carl9170_get_queued_skb`. This function uses `spin_lock_bh` and `spin_unlock_bh` within a USB URB completion handler, which is itself called with hardirqs disabled via `dummy_timer`. My immediate thought is, "Is this a security vulnerability?"
First, in a production build, with lockdep disabled and no debug options, there's no inherent crash risk. `WARN_ON_ONCE(in_hardirq())` wouldn't trigger because, in this specific case with `dummy_timer`, `in_hardirq()` is false since `dummy_timer` runs in softirq context. The `__local_bh_enable_ip` code, with or without lockdep, wouldn't flag any issues.
But let's consider a real HCD β what if it were calling `usb_hcd_giveback_urb` from a hardirq handler? If it did, then `in_hardirq()` *would* be true, potentially triggering the `WARN_ON_ONCE`. Thankfully, `WARN_ON_ONCE` is a warning, not a kernel panic. So, no immediate system crash.
I started thinking about memory corruption or deadlocks: `spin_lock_bh` disables softirqs; `spin_unlock_bh` enables them. If we're in hardirq context when these are called, `in_interrupt()` is true, so `do_softirq()` *isn't* called, which prevents the issue. It's just balancing the preempt count. Therefore, no deadlock or memory corruption arises from *this* particular path.
Then the thought arose, "what if `spin_unlock_bh` is called from *task* context with interrupts disabled?". It's a bit of an edge case, but possible. If a task holds a spinlock with interrupts disabled, and somehow calls `usb_hcd_giveback_urb`, `in_interrupt()` *might* be false. Then `do_softirq()` would be called, and it would `local_irq_enable()`, re-enabling interrupts while the task context still *believed* they were disabled! A subsequent interrupt trying to take the same lock would deadlock.
However, the analysis of the code with dummy HCD or real HCD pointed out that the call to `usb_hcd_giveback_urb` is always from hardirq or softirq contexts, where `in_interrupt()` is true. `do_softirq()` is never called in this scenario. Hence, no deadlock, no memory corruption, no crash, just a lockdep warning. From a DoS perspective, it's negligible unless `panic_on_warn` is set, which is not the default.
But then I saw the prompt's focus on "denial of service" due to the warning. If the condition is unhandled, it may cause DoS. Here, the condition is `in_hardirq()`. It warns but control flow continues normally by decrementing the preempt count.
Aha! There is another consequence to consider: `spin_lock_bh` calls `local_bh_disable()`. It's fine in hardirq because it just increments the softirq count. But `spin_lock_bh` also acquires a spinlock. If the same spinlock is acquired in softirq *while* we're in hardirq, `spin_lock_bh` *doesn't* disable hardirqs! So, a softirq holding the lock, then interrupted by a hardirq, trying to take the same lock? DEADLOCK!
Let's look at `carl9170_get_queued_skb`. It takes `&queue->lock`. Okay, is this `queue->lock` used elsewhere? The `queue` is actually `&ar->tx_status[q]`. I need to search `carl9170` for where `tx_status` is used. This is where I need to dig further. This may be a true denial-of-service vulnerability and I need to determine where else `queue->lock` might be held.
|
| 59/2 |
2026/07/05 07:54 |
tool |
grepper |
0m
Args: map[Expression:tx_status PathPrefix:drivers/net/wireless/ath/carl9170/]
Results: map[Output:drivers/net/wireless/ath/carl9170/carl9170.h=236=struct ar9170 {
--
drivers/net/wireless/ath/carl9170/carl9170.h-389- struct sk_buff_head tx_pending[__AR9170_NUM_TXQ];
drivers/net/wireless/ath/carl9170/carl9170.h:390: struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
drivers/net/wireless/ath/carl9170/carl9170.h-391- struct delayed_work tx_janitor;
--
drivers/net/wireless/ath/carl9170/carl9170.h=583=void carl9170_tx_process_status(struct ar9170 *ar,
drivers/net/wireless/ath/carl9170/carl9170.h-584- const struct carl9170_rsp *cmd);
drivers/net/wireless/ath/carl9170/carl9170.h:585:void carl9170_tx_status(struct ar9170 *ar, struct sk_buff *skb,
drivers/net/wireless/ath/carl9170/carl9170.h-586- const bool success);
--
drivers/net/wireless/ath/carl9170/debug.c=235=static char *carl9170_debugfs_qos_stat_read(struct ar9170 *ar, char *buf,
--
drivers/net/wireless/ath/carl9170/debug.c-266- skb_queue_len(&ar->tx_pending[0]),
drivers/net/wireless/ath/carl9170/debug.c:267: skb_queue_len(&ar->tx_status[0]),
drivers/net/wireless/ath/carl9170/debug.c-268- skb_queue_len(&ar->tx_pending[1]),
drivers/net/wireless/ath/carl9170/debug.c:269: skb_queue_len(&ar->tx_status[1]),
drivers/net/wireless/ath/carl9170/debug.c-270- skb_queue_len(&ar->tx_pending[2]),
drivers/net/wireless/ath/carl9170/debug.c:271: skb_queue_len(&ar->tx_status[2]),
drivers/net/wireless/ath/carl9170/debug.c-272- skb_queue_len(&ar->tx_pending[3]),
drivers/net/wireless/ath/carl9170/debug.c:273: skb_queue_len(&ar->tx_status[3]));
drivers/net/wireless/ath/carl9170/debug.c-274-
--
drivers/net/wireless/ath/carl9170/debug.c=759=DEBUGFS_HW_REG_FILE(hw_ampdu_info, ".8x");
drivers/net/wireless/ath/carl9170/debug.c:760:DEBUGFS_QUEUE_DUMP(tx_status, 0);
drivers/net/wireless/ath/carl9170/debug.c:761:DEBUGFS_QUEUE_DUMP(tx_status, 1);
drivers/net/wireless/ath/carl9170/debug.c:762:DEBUGFS_QUEUE_DUMP(tx_status, 2);
drivers/net/wireless/ath/carl9170/debug.c:763:DEBUGFS_QUEUE_DUMP(tx_status, 3);
drivers/net/wireless/ath/carl9170/debug.c-764-DEBUGFS_QUEUE_DUMP(tx_pending, 0);
--
drivers/net/wireless/ath/carl9170/debug.c=809=void carl9170_debugfs_register(struct ar9170 *ar)
--
drivers/net/wireless/ath/carl9170/debug.c-854-
drivers/net/wireless/ath/carl9170/debug.c:855: DEBUGFS_ADD(tx_status_0);
drivers/net/wireless/ath/carl9170/debug.c:856: DEBUGFS_ADD(tx_status_1);
drivers/net/wireless/ath/carl9170/debug.c:857: DEBUGFS_ADD(tx_status_2);
drivers/net/wireless/ath/carl9170/debug.c:858: DEBUGFS_ADD(tx_status_3);
drivers/net/wireless/ath/carl9170/debug.c-859-
--
drivers/net/wireless/ath/carl9170/fwcmd.h=228=struct carl9170_cmd {
--
drivers/net/wireless/ath/carl9170/fwcmd.h-256- * NOTE:
drivers/net/wireless/ath/carl9170/fwcmd.h:257: * Both structs [carl9170_tx_status and _carl9170_tx_status]
drivers/net/wireless/ath/carl9170/fwcmd.h-258- * need to be "bit for bit" in sync.
drivers/net/wireless/ath/carl9170/fwcmd.h-259- */
drivers/net/wireless/ath/carl9170/fwcmd.h:260:struct carl9170_tx_status {
drivers/net/wireless/ath/carl9170/fwcmd.h-261- /*
--
drivers/net/wireless/ath/carl9170/fwcmd.h-272-
drivers/net/wireless/ath/carl9170/fwcmd.h:273:struct _carl9170_tx_status {
drivers/net/wireless/ath/carl9170/fwcmd.h-274- /*
--
drivers/net/wireless/ath/carl9170/fwcmd.h-283-#define CARL9170_RSP_TX_STATUS_NUM (CARL9170_MAX_CMD_PAYLOAD_LEN / \
drivers/net/wireless/ath/carl9170/fwcmd.h:284: sizeof(struct _carl9170_tx_status))
drivers/net/wireless/ath/carl9170/fwcmd.h-285-
--
drivers/net/wireless/ath/carl9170/fwcmd.h=315=struct carl9170_rsp {
--
drivers/net/wireless/ath/carl9170/fwcmd.h-322-#ifdef __CARL9170FW__
drivers/net/wireless/ath/carl9170/fwcmd.h:323: DECLARE_FLEX_ARRAY(struct carl9170_tx_status, tx_status);
drivers/net/wireless/ath/carl9170/fwcmd.h-324-#endif /* __CARL9170FW__ */
drivers/net/wireless/ath/carl9170/fwcmd.h:325: DECLARE_FLEX_ARRAY(struct _carl9170_tx_status, _tx_status);
drivers/net/wireless/ath/carl9170/fwcmd.h-326- struct carl9170_gpio gpio;
--
drivers/net/wireless/ath/carl9170/main.c=184=static void carl9170_ampdu_gc(struct ar9170 *ar)
--
drivers/net/wireless/ath/carl9170/main.c-211- while ((skb = __skb_dequeue(&tid_info->queue)))
drivers/net/wireless/ath/carl9170/main.c:212: carl9170_tx_status(ar, skb, false);
drivers/net/wireless/ath/carl9170/main.c-213-
--
drivers/net/wireless/ath/carl9170/main.c=219=static void carl9170_flush(struct ar9170 *ar, bool drop_queued)
--
drivers/net/wireless/ath/carl9170/main.c-238-
drivers/net/wireless/ath/carl9170/main.c:239: carl9170_tx_status(ar, skb, false);
drivers/net/wireless/ath/carl9170/main.c-240- }
--
drivers/net/wireless/ath/carl9170/main.c=249=static void carl9170_flush_ba(struct ar9170 *ar)
--
drivers/net/wireless/ath/carl9170/main.c-272- while ((skb = __skb_dequeue(&free)))
drivers/net/wireless/ath/carl9170/main.c:273: carl9170_tx_status(ar, skb, false);
drivers/net/wireless/ath/carl9170/main.c-274-}
--
drivers/net/wireless/ath/carl9170/main.c=276=static void carl9170_zap_queues(struct ar9170 *ar)
--
drivers/net/wireless/ath/carl9170/main.c-286- for (i = 0; i < ar->hw->queues; i++) {
drivers/net/wireless/ath/carl9170/main.c:287: spin_lock_bh(&ar->tx_status[i].lock);
drivers/net/wireless/ath/carl9170/main.c:288: while (!skb_queue_empty(&ar->tx_status[i])) {
drivers/net/wireless/ath/carl9170/main.c-289- struct sk_buff *skb;
drivers/net/wireless/ath/carl9170/main.c-290-
drivers/net/wireless/ath/carl9170/main.c:291: skb = skb_peek(&ar->tx_status[i]);
drivers/net/wireless/ath/carl9170/main.c-292- carl9170_tx_get_skb(skb);
drivers/net/wireless/ath/carl9170/main.c:293: spin_unlock_bh(&ar->tx_status[i].lock);
drivers/net/wireless/ath/carl9170/main.c-294- carl9170_tx_drop(ar, skb);
drivers/net/wireless/ath/carl9170/main.c:295: spin_lock_bh(&ar->tx_status[i].lock);
drivers/net/wireless/ath/carl9170/main.c-296- carl9170_tx_put_skb(skb);
drivers/net/wireless/ath/carl9170/main.c-297- }
drivers/net/wireless/ath/carl9170/main.c:298: spin_unlock_bh(&ar->tx_status[i].lock);
drivers/net/wireless/ath/carl9170/main.c-299- }
--
drivers/net/wireless/ath/carl9170/main.c=1741=void *carl9170_alloc(size_t priv_size)
--
drivers/net/wireless/ath/carl9170/main.c-1788- for (i = 0; i < ar->hw->queues; i++) {
drivers/net/wireless/ath/carl9170/main.c:1789: skb_queue_head_init(&ar->tx_status[i]);
drivers/net/wireless/ath/carl9170/main.c-1790- skb_queue_head_init(&ar->tx_pending[i]);
--
drivers/net/wireless/ath/carl9170/tx.c=262=static void carl9170_tx_release(struct kref *ref)
--
drivers/net/wireless/ath/carl9170/tx.c-301- /*
drivers/net/wireless/ath/carl9170/tx.c:302: * drop redundant tx_status reports:
drivers/net/wireless/ath/carl9170/tx.c-303- *
drivers/net/wireless/ath/carl9170/tx.c:304: * 1. ampdu_ack_len of the final tx_status does
drivers/net/wireless/ath/carl9170/tx.c-305- * include the feedback of this particular frame.
drivers/net/wireless/ath/carl9170/tx.c-306- *
drivers/net/wireless/ath/carl9170/tx.c:307: * 2. tx_status_irqsafe only queues up to 128
drivers/net/wireless/ath/carl9170/tx.c-308- * tx feedback reports and discards the rest.
--
drivers/net/wireless/ath/carl9170/tx.c-327- skb_pull(skb, sizeof(struct _carl9170_tx_superframe));
drivers/net/wireless/ath/carl9170/tx.c:328: ieee80211_tx_status_irqsafe(ar->hw, skb);
drivers/net/wireless/ath/carl9170/tx.c-329-}
--
drivers/net/wireless/ath/carl9170/tx.c=347=static void carl9170_tx_shift_bm(struct ar9170 *ar,
--
drivers/net/wireless/ath/carl9170/tx.c-358- * Sanity check. For each MPDU we set the bit in bitmap and
drivers/net/wireless/ath/carl9170/tx.c:359: * clear it once we received the tx_status.
drivers/net/wireless/ath/carl9170/tx.c-360- * But if the bit is already cleared then we've been bitten
--
drivers/net/wireless/ath/carl9170/tx.c-377-
drivers/net/wireless/ath/carl9170/tx.c:378:static void carl9170_tx_status_process_ampdu(struct ar9170 *ar,
drivers/net/wireless/ath/carl9170/tx.c-379- struct sk_buff *skb, struct ieee80211_tx_info *txinfo)
--
drivers/net/wireless/ath/carl9170/tx.c=437=static void carl9170_tx_bar_status(struct ar9170 *ar, struct sk_buff *skb,
--
drivers/net/wireless/ath/carl9170/tx.c-475-
drivers/net/wireless/ath/carl9170/tx.c:476:void carl9170_tx_status(struct ar9170 *ar, struct sk_buff *skb,
drivers/net/wireless/ath/carl9170/tx.c-477- const bool success)
--
drivers/net/wireless/ath/carl9170/tx.c-492- if (txinfo->flags & IEEE80211_TX_CTL_AMPDU)
drivers/net/wireless/ath/carl9170/tx.c:493: carl9170_tx_status_process_ampdu(ar, skb, txinfo);
drivers/net/wireless/ath/carl9170/tx.c-494-
--
drivers/net/wireless/ath/carl9170/tx.c=558=static void carl9170_check_queue_stop_timeout(struct ar9170 *ar)
--
drivers/net/wireless/ath/carl9170/tx.c-566- for (i = 0; i < ar->hw->queues; i++) {
drivers/net/wireless/ath/carl9170/tx.c:567: spin_lock_bh(&ar->tx_status[i].lock);
drivers/net/wireless/ath/carl9170/tx.c-568-
drivers/net/wireless/ath/carl9170/tx.c:569: skb = skb_peek(&ar->tx_status[i]);
drivers/net/wireless/ath/carl9170/tx.c-570-
--
drivers/net/wireless/ath/carl9170/tx.c-581-next:
drivers/net/wireless/ath/carl9170/tx.c:582: spin_unlock_bh(&ar->tx_status[i].lock);
drivers/net/wireless/ath/carl9170/tx.c-583- }
--
drivers/net/wireless/ath/carl9170/tx.c=658=static void __carl9170_tx_process_status(struct ar9170 *ar,
--
drivers/net/wireless/ath/carl9170/tx.c-667-
drivers/net/wireless/ath/carl9170/tx.c:668: skb = carl9170_get_queued_skb(ar, cookie, &ar->tx_status[q]);
drivers/net/wireless/ath/carl9170/tx.c-669- if (!skb) {
--
drivers/net/wireless/ath/carl9170/tx.c-685- carl9170_tx_fill_rateinfo(ar, r, t, txinfo);
drivers/net/wireless/ath/carl9170/tx.c:686: carl9170_tx_status(ar, skb, success);
drivers/net/wireless/ath/carl9170/tx.c-687-}
--
drivers/net/wireless/ath/carl9170/tx.c=689=void carl9170_tx_process_status(struct ar9170 *ar,
--
drivers/net/wireless/ath/carl9170/tx.c-700-
drivers/net/wireless/ath/carl9170/tx.c:701: __carl9170_tx_process_status(ar, cmd->_tx_status[i].cookie,
drivers/net/wireless/ath/carl9170/tx.c:702: cmd->_tx_status[i].info);
drivers/net/wireless/ath/carl9170/tx.c-703- }
--
drivers/net/wireless/ath/carl9170/tx.c=1288=static bool carl9170_tx_ps_drop(struct ar9170 *ar, struct sk_buff *skb)
--
drivers/net/wireless/ath/carl9170/tx.c-1311- carl9170_release_dev_space(ar, skb);
drivers/net/wireless/ath/carl9170/tx.c:1312: carl9170_tx_status(ar, skb, false);
drivers/net/wireless/ath/carl9170/tx.c-1313- return true;
--
drivers/net/wireless/ath/carl9170/tx.c=1341=static void carl9170_tx(struct ar9170 *ar)
--
drivers/net/wireless/ath/carl9170/tx.c-1368- /*
drivers/net/wireless/ath/carl9170/tx.c:1369: * NB: tx_status[i] vs. tx_status[q],
drivers/net/wireless/ath/carl9170/tx.c-1370- * TODO: Move into pick_skb or alloc_dev_space.
drivers/net/wireless/ath/carl9170/tx.c-1371- */
drivers/net/wireless/ath/carl9170/tx.c:1372: skb_queue_tail(&ar->tx_status[q], skb);
drivers/net/wireless/ath/carl9170/tx.c-1373-
--
drivers/net/wireless/ath/carl9170/tx.c-1379- * and wlan tx status functions:
drivers/net/wireless/ath/carl9170/tx.c:1380: * carl9170_tx_status/janitor.
drivers/net/wireless/ath/carl9170/tx.c-1381- */
--
drivers/net/wireless/ath/carl9170/tx.c=1396=static bool carl9170_tx_ampdu_queue(struct ar9170 *ar,
--
drivers/net/wireless/ath/carl9170/tx.c-1466- txinfo->flags &= ~IEEE80211_TX_CTL_AMPDU;
drivers/net/wireless/ath/carl9170/tx.c:1467: carl9170_tx_status(ar, skb, false);
drivers/net/wireless/ath/carl9170/tx.c-1468- ar->tx_dropped++;
--
drivers/net/wireless/ath/carl9170/tx.c=1472=void carl9170_op_tx(struct ieee80211_hw *hw,
--
drivers/net/wireless/ath/carl9170/tx.c-1492- /*
drivers/net/wireless/ath/carl9170/tx.c:1493: * from now on, one has to use carl9170_tx_status to free
drivers/net/wireless/ath/carl9170/tx.c-1494- * all ressouces which are associated with the frame.
]
|
| 60/2 |
2026/07/05 07:54 |
llm |
expert |
0m
Model:
Tokens:
input: 56993
output: 54
thoughts: 0
|
| 61/2 |
2026/07/05 07:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/tx.c Name:carl9170_tx_accounting_free]
Results: map[SourceCode: 156: static void carl9170_tx_accounting_free(struct ar9170 *ar, struct sk_buff *skb)
157: {
158: int queue;
159:
160: queue = skb_get_queue_mapping(skb);
161:
162: spin_lock_bh(&ar->tx_stats_lock);
163:
164: ar->tx_stats[queue].len--;
165:
166: if (!is_mem_full(ar)) {
167: unsigned int i;
168: for (i = 0; i < ar->hw->queues; i++) {
169: if (ar->tx_stats[i].len >= CARL9170_NUM_TX_LIMIT_SOFT)
170: continue;
171:
172: if (ieee80211_queue_stopped(ar->hw, i)) {
173: unsigned long tmp;
174:
175: tmp = jiffies - ar->queue_stop_timeout[i];
176: if (tmp > ar->max_queue_stop_timeout[i])
177: ar->max_queue_stop_timeout[i] = tmp;
178: }
179:
180: ieee80211_wake_queue(ar->hw, i);
181: }
182: }
183:
184: spin_unlock_bh(&ar->tx_stats_lock);
185:
186: if (atomic_dec_and_test(&ar->tx_total_queued))
187: complete(&ar->tx_flush);
188: }
SourceFile:drivers/net/wireless/ath/carl9170/tx.c]
|
| 62/2 |
2026/07/05 07:54 |
llm |
expert |
0m
Model:
Tokens:
input: 57589
output: 54
thoughts: 0
|
| 63/2 |
2026/07/05 07:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/tx.c Name:carl9170_tx_bar_status]
Results: map[SourceCode: 437: static void carl9170_tx_bar_status(struct ar9170 *ar, struct sk_buff *skb,
438: struct ieee80211_tx_info *tx_info)
439: {
440: struct _carl9170_tx_superframe *super = (void *) skb->data;
441: struct ieee80211_bar *bar = (void *) super->frame_data;
442:
443: /*
444: * Unlike all other frames, the status report for BARs does
445: * not directly come from the hardware as it is incapable of
446: * matching a BA to a previously send BAR.
447: * Instead the RX-path will scan for incoming BAs and set the
448: * IEEE80211_TX_STAT_ACK if it sees one that was likely
449: * caused by a BAR from us.
450: */
451:
452: if (unlikely(ieee80211_is_back_req(bar->frame_control)) &&
453: !(tx_info->flags & IEEE80211_TX_STAT_ACK)) {
454: struct carl9170_bar_list_entry *entry;
455: int queue = skb_get_queue_mapping(skb);
456:
457: rcu_read_lock();
458: list_for_each_entry_rcu(entry, &ar->bar_list[queue], list) {
459: if (entry->skb == skb) {
460: spin_lock_bh(&ar->bar_list_lock[queue]);
461: list_del_rcu(&entry->list);
462: spin_unlock_bh(&ar->bar_list_lock[queue]);
463: kfree_rcu(entry, head);
464: goto out;
465: }
466: }
467:
468: WARN(1, "bar not found in %d - ra:%pM ta:%pM c:%x ssn:%x\n",
469: queue, bar->ra, bar->ta, bar->control,
470: bar->start_seq_num);
471: out:
472: rcu_read_unlock();
473: }
474: }
SourceFile:drivers/net/wireless/ath/carl9170/tx.c]
|
| 64/2 |
2026/07/05 07:54 |
llm |
expert |
0m
Model:
Tokens:
input: 58370
output: 57
thoughts: 0
|
| 65/2 |
2026/07/05 07:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/tx.c Name:carl9170_tx_status_process_ampdu]
Results: map[SourceCode: 378: static void carl9170_tx_status_process_ampdu(struct ar9170 *ar,
379: struct sk_buff *skb, struct ieee80211_tx_info *txinfo)
380: {
381: struct _carl9170_tx_superframe *super = (void *) skb->data;
382: struct ieee80211_hdr *hdr = (void *) super->frame_data;
383: struct ieee80211_sta *sta;
384: struct carl9170_sta_info *sta_info;
385: struct carl9170_sta_tid *tid_info;
386: u8 tid;
387:
388: if (!(txinfo->flags & IEEE80211_TX_CTL_AMPDU) ||
389: txinfo->flags & IEEE80211_TX_CTL_INJECTED)
390: return;
391:
392: rcu_read_lock();
393: sta = __carl9170_get_tx_sta(ar, skb);
394: if (unlikely(!sta))
395: goto out_rcu;
396:
397: tid = ieee80211_get_tid(hdr);
398:
399: sta_info = (void *) sta->drv_priv;
400: tid_info = rcu_dereference(sta_info->agg[tid]);
401: if (!tid_info)
402: goto out_rcu;
403:
404: spin_lock_bh(&tid_info->lock);
405: if (likely(tid_info->state >= CARL9170_TID_STATE_IDLE))
406: carl9170_tx_shift_bm(ar, tid_info, get_seq_h(hdr));
407:
408: if (sta_info->stats[tid].clear) {
409: sta_info->stats[tid].clear = false;
410: sta_info->stats[tid].req = false;
411: sta_info->stats[tid].ampdu_len = 0;
412: sta_info->stats[tid].ampdu_ack_len = 0;
413: }
414:
415: sta_info->stats[tid].ampdu_len++;
416: if (txinfo->status.rates[0].count == 1)
417: sta_info->stats[tid].ampdu_ack_len++;
418:
419: if (!(txinfo->flags & IEEE80211_TX_STAT_ACK))
420: sta_info->stats[tid].req = true;
421:
422: if (super->f.mac_control & cpu_to_le16(AR9170_TX_MAC_IMM_BA)) {
423: super->s.rix = sta_info->stats[tid].ampdu_len;
424: super->s.cnt = sta_info->stats[tid].ampdu_ack_len;
425: txinfo->flags |= IEEE80211_TX_STAT_AMPDU;
426: if (sta_info->stats[tid].req)
427: txinfo->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
428:
429: sta_info->stats[tid].clear = true;
430: }
431: spin_unlock_bh(&tid_info->lock);
432:
433: out_rcu:
434: rcu_read_unlock();
435: }
SourceFile:drivers/net/wireless/ath/carl9170/tx.c]
|
| 66/2 |
2026/07/05 07:54 |
llm |
expert |
0m
Model:
Tokens:
input: 71044
output: 32
thoughts: 2164
Thoughts: **Deadlock in carl9170 USB Driver - Critical Analysis**
Okay, so here's the deal. I've been digging into this `carl9170` driver, and it looks like there's a serious potential for a deadlock situation. The crux of it is this: `spin_lock_bh` is being used in multiple places, specifically in `carl9170_get_queued_skb`, `carl9170_zap_queues`, and `carl9170_check_queue_stop_timeout`. The first of which is called from a USB IRQ complete function.
`carl9170_get_queued_skb` can be called from `carl9170_usb_rx_irq_complete`, which itself is invoked by `usb_hcd_giveback_urb`. Now, here's where it gets dicey. `usb_hcd_giveback_urb` is *frequently* called from a *hardirq* context β the interrupt handler of a USB host controller driver (HCD). `spin_lock_bh` is designed to disable softirqs but *not* hardirqs.
The problem arises if `carl9170_tx_janitor` is already holding one of these locks (using `spin_lock_bh`). The `tx_janitor` is delayed work that can run in process or softirq context, and can call the same lock in that context. If a hardirq (from a real HCD's interrupt handler) then triggers `carl9170_usb_rx_irq_complete`, the hardirq's execution will call `spin_lock_bh`, attempting to acquire a lock that's already held. This is a classic deadlock. The hardirq will spin forever, blocking the system.
I'm thinking this is a bug that's exploitable, potentially by sending specially crafted `CARL9170_RSP_TXCOMP` responses from a malicious USB device (or even just through normal operation). Timing is the critical factor, but spamming those responses could eventually trigger the race condition.
I need to confirm if this issue is system-agnostic or whether certain HCD configurations mitigate it. I know `xhci` and `ehci` support `HCD_BH` which defers completions to softirq context (like a tasklet), which makes the use of `spin_lock_bh` safe. These HCDs essentially prevent this deadlock, since softirqs can't interrupt other softirqs on the same CPU. My thinking is, if `HCD_BH` is used, the situation is completely safe, as `spin_lock_bh` in softirq context is fine.
The warning I saw during testing must be tied to a specific scenario that exposes this error. Looks like the `dummy_hcd` *doesn't* use `HCD_BH`.
Wait, the `dummy_timer` runs in softirq context, right? Okay, double-checking⦠yes, initialized with `HRTIMER_MODE_REL_SOFT`, meaning softirq. It uses `spin_lock_irqsave` which disables hardirqs, then calls `usb_hcd_giveback_urb`, and calls spin_unlock, leaving hardirqs disabled. This is where I'm seeing the warning. It looks like the issue is that the `dummy_hcd` *disables* hardirqs within its own context and then calls `usb_hcd_giveback_urb` with the hardirqs disabled!
So, `usb_hcd_giveback_urb`'s documentation states that all HCD locks are released *before* the call. But in this case, hardirqs are still disabled.
Checking the code again, yes, `spin_unlock` is being used instead of `spin_unlock_irqrestore`. Many older HCDs *still* call `usb_hcd_giveback_urb` with hardirqs disabled, which forces the driver completion handler to assume this! *The core of the problem is in carl9170*. Because it's using `spin_lock_bh` in a completion handler, it is *vulnerable* to the deadlock when used with an HCD that doesn't use `HCD_BH`. `uhci_hcd` *doesn't* use `HCD_BH`, making this critical. The bug in `carl9170` can cause denial of service.
The bug is in `carl9170` using `spin_lock_bh` in a completion handler which can be called in hardir
|
| 67/2 |
2026/07/05 07:55 |
tool |
grepper |
0m
Error:
Args: map[Expression:HCD_BH PathPrefix:drivers/usb/host/uhci]
Results:
|
| 68/2 |
2026/07/05 07:55 |
llm |
expert |
0m
Model:
Tokens:
input: 60613
output: 32
thoughts: 0
|
| 69/2 |
2026/07/05 07:55 |
tool |
grepper |
0m
Error:
Args: map[Expression:HCD_BH PathPrefix:drivers/usb/host/ohci]
Results:
|
| 70/2 |
2026/07/05 07:55 |
llm |
expert |
0m
Model:
Tokens:
input: 74325
output: 52
thoughts: 2455
Thoughts: **Analysis of `carl9170` USB Driver Deadlock Vulnerability**
Okay, let's break this down. It seems that the `carl9170` driver, specifically, has a critical issue related to how it handles URB (USB Request Block) completions. My initial thought is that the driver's completion handler, within `carl9170_get_queued_skb`, calls `spin_lock_bh`. Now, the problem arises because `uhci_hcd` and `ohci_hcd` don't utilize `HCD_BH` β meaning the completion handler, when the device is connected to a USB 1.1 (OHCI/UHCI) port, executes in hard interrupt (hardirq) context.
The flaw is simple but nasty: `spin_lock_bh` doesn't disable hardirqs. If `carl9170_tx_janitor` β which likely runs in task or softirq context β holds the lock when a USB 1.1 completion handler fires, it's an immediate deadlock. This deadlock scenario also makes me realize that itβs not really a memory corruption issue, but a denial-of-service (DoS) vulnerability.
I have to consider that `carl9170` is a USB 2.0 device and might fallback to USB 1.1 if plugged into an older port. Even if it doesnβt, a malicious device pretending to be a `carl9170` and connected to an OHCI/UHCI controller could trigger this, leading to a system freeze. This is a real security concern.
I also considered the interaction with `dummy_hcd`, which `syzkaller` uses to emulate USB devices. Here, the completion handler runs in softirq context, but with hardirqs disabled, `spin_unlock_bh` will trigger the `WARN_ON_ONCE(irqs_disabled())` in `__local_bh_enable_ip`. However, since `dummy_hcd` uses softirqs, the deadlock won't happen (because softirqs can run on different CPUs even if the task has disabled them). The bug specifically manifests with OHCI/UHCI because those controllers trigger the completion handler in a hardirq context. This scenario creates a classic single-CPU deadlock.
The core of the bug is the misuse of `spin_lock_bh` within the URB completion handler when it should be using `spin_lock_irqsave` to handle interrupts correctly, particularly on OHCI/UHCI controllers.
**Vulnerability Assessment:**
* **Exploitable:** False (DoS only)
* **Denial of Service:** True
* **Accessible From Unprivileged Processes:** False (requires a specific hardware setup that's not easily exploitable unless present, and relies on a malicious device)
* **Peripheral Trigger:** True (requires a malicious or misconfigured USB device.)
* **Other Remote Trigger:** True.
Crucially, can this be triggered by a normal user with a real `carl9170` dongle? Yes, network traffic (ping, UDP, etc.) transmitted through the dongle will trigger the completion handler, which *could* deadlock the system, *if* the device is plugged into a USB 1.1 (OHCI/UHCI) port. In most cases, because of `HCD_BH`, the issue remains dormant. But that opens up an attack vector that is very difficult to detect. This vulnerability can be triggered remotely with the right conditions.
In conclusion, this is a DoS vulnerability that can be triggered by either a malicious USB device or, under specific conditions (USB 1.1 connection), normal network traffic via a legitimate dongle. The fix is obvious: replace `spin_lock_bh` with `spin_lock_irqsave` in the completion handler.
|
| 71/2 |
2026/07/05 07:55 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/usb.c Name:carl9170_usb_probe]
Results: map[SourceCode:1043: static int carl9170_usb_probe(struct usb_interface *intf,
1044: const struct usb_device_id *id)
1045: {
1046: struct usb_endpoint_descriptor *ep;
1047: struct ar9170 *ar;
1048: struct usb_device *udev;
1049: int i, err;
1050:
1051: err = usb_reset_device(interface_to_usbdev(intf));
1052: if (err)
1053: return err;
1054:
1055: ar = carl9170_alloc(sizeof(*ar));
1056: if (IS_ERR(ar))
1057: return PTR_ERR(ar);
1058:
1059: udev = interface_to_usbdev(intf);
1060: ar->udev = udev;
1061: ar->intf = intf;
1062: ar->features = id->driver_info;
1063:
1064: /* We need to remember the type of endpoint 4 because it differs
1065: * between high- and full-speed configuration. The high-speed
1066: * configuration specifies it as interrupt and the full-speed
1067: * configuration as bulk endpoint. This information is required
1068: * later when sending urbs to that endpoint.
1069: */
1070: for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; ++i) {
1071: ep = &intf->cur_altsetting->endpoint[i].desc;
1072:
1073: if (usb_endpoint_num(ep) == AR9170_USB_EP_CMD &&
1074: usb_endpoint_dir_out(ep) &&
1075: usb_endpoint_type(ep) == USB_ENDPOINT_XFER_BULK)
1076: ar->usb_ep_cmd_is_bulk = true;
1077: }
1078:
1079: /* Verify that all expected endpoints are present */
1080: if (ar->usb_ep_cmd_is_bulk) {
1081: u8 bulk_ep_addr[] = {
1082: AR9170_USB_EP_RX | USB_DIR_IN,
1083: AR9170_USB_EP_TX | USB_DIR_OUT,
1084: AR9170_USB_EP_CMD | USB_DIR_OUT,
1085: 0};
1086: u8 int_ep_addr[] = {
1087: AR9170_USB_EP_IRQ | USB_DIR_IN,
1088: 0};
1089: if (!usb_check_bulk_endpoints(intf, bulk_ep_addr) ||
1090: !usb_check_int_endpoints(intf, int_ep_addr))
1091: err = -ENODEV;
1092: } else {
1093: u8 bulk_ep_addr[] = {
1094: AR9170_USB_EP_RX | USB_DIR_IN,
1095: AR9170_USB_EP_TX | USB_DIR_OUT,
1096: 0};
1097: u8 int_ep_addr[] = {
1098: AR9170_USB_EP_IRQ | USB_DIR_IN,
1099: AR9170_USB_EP_CMD | USB_DIR_OUT,
1100: 0};
1101: if (!usb_check_bulk_endpoints(intf, bulk_ep_addr) ||
1102: !usb_check_int_endpoints(intf, int_ep_addr))
1103: err = -ENODEV;
1104: }
1105:
1106: if (err) {
1107: carl9170_free(ar);
1108: return err;
1109: }
1110:
1111: usb_set_intfdata(intf, ar);
1112: SET_IEEE80211_DEV(ar->hw, &intf->dev);
1113:
1114: init_usb_anchor(&ar->rx_anch);
1115: init_usb_anchor(&ar->rx_pool);
1116: init_usb_anchor(&ar->rx_work);
1117: init_usb_anchor(&ar->tx_wait);
1118: init_usb_anchor(&ar->tx_anch);
1119: init_usb_anchor(&ar->tx_cmd);
1120: init_usb_anchor(&ar->tx_err);
1121: init_completion(&ar->cmd_wait);
1122: init_completion(&ar->fw_boot_wait);
1123: init_completion(&ar->fw_load_wait);
1124: tasklet_setup(&ar->usb_tasklet, carl9170_usb_tasklet);
1125:
1126: atomic_set(&ar->tx_cmd_urbs, 0);
1127: atomic_set(&ar->tx_anch_urbs, 0);
1128: atomic_set(&ar->rx_work_urbs, 0);
1129: atomic_set(&ar->rx_anch_urbs, 0);
1130: atomic_set(&ar->rx_pool_urbs, 0);
1131:
1132: usb_get_intf(intf);
1133:
1134: carl9170_set_state(ar, CARL9170_STOPPED);
1135:
1136: err = request_firmware_nowait(THIS_MODULE, 1, CARL9170FW_NAME,
1137: &ar->udev->dev, GFP_KERNEL, ar, carl9170_usb_firmware_step2);
1138: if (err) {
1139: usb_put_intf(intf);
1140: carl9170_free(ar);
1141: }
1142: return err;
1143: }
SourceFile:drivers/net/wireless/ath/carl9170/usb.c]
|
| 72/2 |
2026/07/05 07:55 |
llm |
expert |
0m
Model:
Tokens:
input: 63326
output: 58
thoughts: 0
|
| 73/2 |
2026/07/05 07:55 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/usb.c Name:carl9170_usb_init_rx_bulk_urbs]
Results: map[SourceCode: 520: static int carl9170_usb_init_rx_bulk_urbs(struct ar9170 *ar)
521: {
522: struct urb *urb;
523: int i, err = -EINVAL;
524:
525: /*
526: * The driver actively maintains a second shadow
527: * pool for inactive, but fully-prepared rx urbs.
528: *
529: * The pool should help the driver to master huge
530: * workload spikes without running the risk of
531: * undersupplying the hardware or wasting time by
532: * processing rx data (streams) inside the urb
533: * completion (hardirq context).
534: */
535: for (i = 0; i < AR9170_NUM_RX_URBS_POOL; i++) {
536: urb = carl9170_usb_alloc_rx_urb(ar, GFP_KERNEL);
537: if (!urb) {
538: err = -ENOMEM;
539: goto err_out;
540: }
541:
542: usb_anchor_urb(urb, &ar->rx_pool);
543: atomic_inc(&ar->rx_pool_urbs);
544: usb_free_urb(urb);
545: }
546:
547: err = carl9170_usb_submit_rx_urb(ar, GFP_KERNEL);
548: if (err)
549: goto err_out;
550:
551: /* the device now waiting for the firmware. */
552: carl9170_set_state_when(ar, CARL9170_STOPPED, CARL9170_IDLE);
553: return 0;
554:
555: err_out:
556:
557: usb_scuttle_anchored_urbs(&ar->rx_pool);
558: usb_scuttle_anchored_urbs(&ar->rx_work);
559: usb_kill_anchored_urbs(&ar->rx_anch);
560: return err;
561: }
SourceFile:drivers/net/wireless/ath/carl9170/usb.c]
|
| 74/2 |
2026/07/05 07:55 |
llm |
expert |
0m
Model:
Tokens:
input: 64070
output: 56
thoughts: 0
|
| 75/2 |
2026/07/05 07:55 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/usb.c Name:carl9170_usb_alloc_rx_urb]
Results: map[SourceCode: 466: static struct urb *carl9170_usb_alloc_rx_urb(struct ar9170 *ar, gfp_t gfp)
467: {
468: struct urb *urb;
469: void *buf;
470:
471: buf = kmalloc(ar->fw.rx_size, gfp);
472: if (!buf)
473: return NULL;
474:
475: urb = usb_alloc_urb(0, gfp);
476: if (!urb) {
477: kfree(buf);
478: return NULL;
479: }
480:
481: usb_fill_bulk_urb(urb, ar->udev, usb_rcvbulkpipe(ar->udev,
482: AR9170_USB_EP_RX), buf, ar->fw.rx_size,
483: carl9170_usb_rx_complete, ar);
484:
485: urb->transfer_flags |= URB_FREE_BUFFER;
486:
487: return urb;
488: }
SourceFile:drivers/net/wireless/ath/carl9170/usb.c]
|
| 76/2 |
2026/07/05 07:55 |
llm |
expert |
0m
Model:
Tokens:
input: 64504
output: 54
thoughts: 0
|
| 77/2 |
2026/07/05 07:55 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/usb.c Name:carl9170_usb_rx_complete]
Results: map[SourceCode: 398: static void carl9170_usb_rx_complete(struct urb *urb)
399: {
400: struct ar9170 *ar = urb->context;
401: int err;
402:
403: if (WARN_ON_ONCE(!ar))
404: return;
405:
406: atomic_dec(&ar->rx_anch_urbs);
407:
408: switch (urb->status) {
409: case 0:
410: /* rx path */
411: usb_anchor_urb(urb, &ar->rx_work);
412: atomic_inc(&ar->rx_work_urbs);
413: break;
414:
415: case -ENOENT:
416: case -ECONNRESET:
417: case -ENODEV:
418: case -ESHUTDOWN:
419: /* handle disconnect events*/
420: return;
421:
422: default:
423: /* handle all other errors */
424: usb_anchor_urb(urb, &ar->rx_pool);
425: atomic_inc(&ar->rx_pool_urbs);
426: break;
427: }
428:
429: err = carl9170_usb_submit_rx_urb(ar, GFP_ATOMIC);
430: if (unlikely(err)) {
431: /*
432: * usb_submit_rx_urb reported a problem.
433: * In case this is due to a rx buffer shortage,
434: * elevate the tasklet worker priority to
435: * the highest available level.
436: */
437: tasklet_hi_schedule(&ar->usb_tasklet);
438:
439: if (atomic_read(&ar->rx_anch_urbs) == 0) {
440: /*
441: * At this point, either the system is too slow to
442: * cope with the enormous workload (so we have simply
443: * run out of active rx urbs and this unfortunately
444: * leads to an unpredictable device), or the device
445: * is not fully functional after an unsuccessful
446: * firmware loading attempts (so it doesn't pass
447: * ieee80211_register_hw() and there is no internal
448: * workqueue at all).
449: */
450:
451: if (ar->registered)
452: ieee80211_queue_work(ar->hw, &ar->ping_work);
453: else
454: pr_warn_once("device %s is not registered\n",
455: dev_name(&ar->udev->dev));
456: }
457: } else {
458: /*
459: * Using anything less than _high_ priority absolutely
460: * kills the rx performance my UP-System...
461: */
462: tasklet_hi_schedule(&ar->usb_tasklet);
463: }
464: }
SourceFile:drivers/net/wireless/ath/carl9170/usb.c]
|
| 78/2 |
2026/07/05 07:55 |
llm |
expert |
0m
Model:
Tokens:
input: 65534
output: 53
thoughts: 0
|
| 79/2 |
2026/07/05 07:55 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/usb.c Name:carl9170_usb_tasklet]
Results: map[SourceCode: 380: static void carl9170_usb_tasklet(struct tasklet_struct *t)
381: {
382: struct ar9170 *ar = from_tasklet(ar, t, usb_tasklet);
383:
384: if (!IS_INITIALIZED(ar))
385: return;
386:
387: carl9170_usb_rx_work(ar);
388:
389: /*
390: * Strictly speaking: The tx scheduler is not part of the USB system.
391: * But the rx worker returns frames back to the mac80211-stack and
392: * this is the _perfect_ place to generate the next transmissions.
393: */
394: if (IS_STARTED(ar))
395: carl9170_tx_scheduler(ar);
396: }
SourceFile:drivers/net/wireless/ath/carl9170/usb.c]
|
| 80/2 |
2026/07/05 07:55 |
llm |
expert |
0m
Model:
Tokens:
input: 65891
output: 54
thoughts: 0
|
| 81/2 |
2026/07/05 07:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/usb.c Name:carl9170_usb_rx_work]
Results: map[SourceCode: 342: static void carl9170_usb_rx_work(struct ar9170 *ar)
343: {
344: struct urb *urb;
345: int i;
346:
347: for (i = 0; i < AR9170_NUM_RX_URBS_POOL; i++) {
348: urb = usb_get_from_anchor(&ar->rx_work);
349: if (!urb)
350: break;
351:
352: atomic_dec(&ar->rx_work_urbs);
353: if (IS_INITIALIZED(ar)) {
354: carl9170_rx(ar, urb->transfer_buffer,
355: urb->actual_length);
356: }
357:
358: usb_anchor_urb(urb, &ar->rx_pool);
359: atomic_inc(&ar->rx_pool_urbs);
360:
361: usb_free_urb(urb);
362:
363: carl9170_usb_submit_rx_urb(ar, GFP_ATOMIC);
364: }
365: }
SourceFile:drivers/net/wireless/ath/carl9170/usb.c]
|
| 82/2 |
2026/07/05 07:56 |
llm |
expert |
0m
Model:
Tokens:
input: 66342
output: 50
thoughts: 0
|
| 83/2 |
2026/07/05 07:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/rx.c Name:carl9170_rx]
Results: map[SourceCode:1007: void carl9170_rx(struct ar9170 *ar, void *buf, unsigned int len)
1008: {
1009: if (ar->fw.rx_stream)
1010: carl9170_rx_stream(ar, buf, len);
1011: else
1012: __carl9170_rx(ar, buf, len);
1013: }
SourceFile:drivers/net/wireless/ath/carl9170/rx.c]
|
| 84/2 |
2026/07/05 07:56 |
llm |
expert |
0m
Model:
Tokens:
input: 66555
output: 51
thoughts: 0
|
| 85/2 |
2026/07/05 07:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/rx.c Name:__carl9170_rx]
Results: map[SourceCode: 854: static void __carl9170_rx(struct ar9170 *ar, u8 *buf, unsigned int len)
855: {
856: unsigned int i = 0;
857:
858: /* weird thing, but this is the same in the original driver */
859: while (len > 2 && i < 12 && buf[0] == 0xff && buf[1] == 0xff) {
860: i += 2;
861: len -= 2;
862: buf += 2;
863: }
864:
865: if (unlikely(len < 4))
866: return;
867:
868: /* found the 6 * 0xffff marker? */
869: if (i == 12)
870: carl9170_rx_untie_cmds(ar, buf, len);
871: else
872: carl9170_rx_untie_data(ar, buf, len);
873: }
SourceFile:drivers/net/wireless/ath/carl9170/rx.c]
|
| 86/2 |
2026/07/05 07:56 |
llm |
expert |
0m
Model:
Tokens:
input: 66961
output: 55
thoughts: 0
|
| 87/2 |
2026/07/05 07:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/rx.c Name:carl9170_rx_untie_cmds]
Results: map[SourceCode: 825: static void carl9170_rx_untie_cmds(struct ar9170 *ar, const u8 *respbuf,
826: const unsigned int resplen)
827: {
828: struct carl9170_rsp *cmd;
829: int i = 0;
830:
831: while (i < resplen) {
832: cmd = (void *) &respbuf[i];
833:
834: i += cmd->hdr.len + 4;
835: if (unlikely(i > resplen))
836: break;
837:
838: if (carl9170_check_sequence(ar, cmd->hdr.seq))
839: break;
840:
841: carl9170_handle_command_response(ar, cmd, cmd->hdr.len + 4);
842: }
843:
844: if (unlikely(i != resplen)) {
845: if (!net_ratelimit())
846: return;
847:
848: wiphy_err(ar->hw->wiphy, "malformed firmware trap:\n");
849: print_hex_dump_bytes("rxcmd:", DUMP_PREFIX_OFFSET,
850: respbuf, resplen);
851: }
852: }
SourceFile:drivers/net/wireless/ath/carl9170/rx.c]
|
| 88/2 |
2026/07/05 07:56 |
llm |
expert |
0m
Model:
Tokens:
input: 67476
output: 52
thoughts: 0
|
| 89/2 |
2026/07/05 07:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/rx.c Name:carl9170_rx_stream]
Results: map[SourceCode: 875: static void carl9170_rx_stream(struct ar9170 *ar, void *buf, unsigned int len)
876: {
877: unsigned int tlen, wlen = 0, clen = 0;
878: struct ar9170_stream *rx_stream;
879: u8 *tbuf;
880:
881: tbuf = buf;
882: tlen = len;
883:
884: while (tlen >= 4) {
885: rx_stream = (void *) tbuf;
886: clen = le16_to_cpu(rx_stream->length);
887: wlen = ALIGN(clen, 4);
888:
889: /* check if this is stream has a valid tag.*/
890: if (rx_stream->tag != cpu_to_le16(AR9170_RX_STREAM_TAG)) {
891: /*
892: * TODO: handle the highly unlikely event that the
893: * corrupted stream has the TAG at the right position.
894: */
895:
896: /* check if the frame can be repaired. */
897: if (!ar->rx_failover_missing) {
898:
899: /* this is not "short read". */
900: if (net_ratelimit()) {
901: wiphy_err(ar->hw->wiphy,
902: "missing tag!\n");
903: }
904:
905: __carl9170_rx(ar, tbuf, tlen);
906: return;
907: }
908:
909: if (ar->rx_failover_missing > tlen) {
910: if (net_ratelimit()) {
911: wiphy_err(ar->hw->wiphy,
912: "possible multi "
913: "stream corruption!\n");
914: goto err_telluser;
915: } else {
916: goto err_silent;
917: }
918: }
919:
920: skb_put_data(ar->rx_failover, tbuf, tlen);
921: ar->rx_failover_missing -= tlen;
922:
923: if (ar->rx_failover_missing <= 0) {
924: /*
925: * nested carl9170_rx_stream call!
926: *
927: * termination is guaranteed, even when the
928: * combined frame also have an element with
929: * a bad tag.
930: */
931:
932: ar->rx_failover_missing = 0;
933: carl9170_rx_stream(ar, ar->rx_failover->data,
934: ar->rx_failover->len);
935:
936: skb_reset_tail_pointer(ar->rx_failover);
937: skb_trim(ar->rx_failover, 0);
938: }
939:
940: return;
941: }
942:
943: /* check if stream is clipped */
944: if (wlen > tlen - 4) {
945: if (ar->rx_failover_missing) {
946: /* TODO: handle double stream corruption. */
947: if (net_ratelimit()) {
948: wiphy_err(ar->hw->wiphy, "double rx "
949: "stream corruption!\n");
950: goto err_telluser;
951: } else {
952: goto err_silent;
953: }
954: }
955:
956: /*
957: * save incomplete data set.
958: * the firmware will resend the missing bits when
959: * the rx - descriptor comes round again.
960: */
961:
962: skb_put_data(ar->rx_failover, tbuf, tlen);
963: ar->rx_failover_missing = clen - tlen;
964: return;
965: }
966: __carl9170_rx(ar, rx_stream->payload, clen);
967:
968: tbuf += wlen + 4;
969: tlen -= wlen + 4;
970: }
971:
972: if (tlen) {
973: if (net_ratelimit()) {
974: wiphy_err(ar->hw->wiphy, "%d bytes of unprocessed "
975: "data left in rx stream!\n", tlen);
976: }
977:
978: goto err_telluser;
979: }
980:
981: return;
982:
983: err_telluser:
984: wiphy_err(ar->hw->wiphy, "damaged RX stream data [want:%d, "
985: "data:%d, rx:%d, pending:%d ]\n", clen, wlen, tlen,
986: ar->rx_failover_missing);
987:
988: if (ar->rx_failover_missing)
989: print_hex_dump_bytes("rxbuf:", DUMP_PREFIX_OFFSET,
990: ar->rx_failover->data,
991: ar->rx_failover->len);
992:
993: print_hex_dump_bytes("stream:", DUMP_PREFIX_OFFSET,
994: buf, len);
995:
996: wiphy_err(ar->hw->wiphy, "please check your hardware and cables, if "
997: "you see this message frequently.\n");
998:
999: err_silent:
1000: if (ar->rx_failover_missing) {
1001: skb_reset_tail_pointer(ar->rx_failover);
1002: skb_trim(ar->rx_failover, 0);
1003: ar->rx_failover_missing = 0;
1004: }
1005: }
SourceFile:drivers/net/wireless/ath/carl9170/rx.c]
|
| 90/2 |
2026/07/05 07:56 |
llm |
expert |
0m
Model:
Tokens:
input: 69450
output: 55
thoughts: 0
|
| 91/2 |
2026/07/05 07:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/rx.c Name:carl9170_rx_untie_data]
Results: map[SourceCode: 688: /*
689: * If the frame alignment is right (or the kernel has
690: * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS), and there
691: * is only a single MPDU in the USB frame, then we could
692: * submit to mac80211 the SKB directly. However, since
693: * there may be multiple packets in one SKB in stream
694: * mode, and we need to observe the proper ordering,
695: * this is non-trivial.
696: */
697: static void carl9170_rx_untie_data(struct ar9170 *ar, u8 *buf, int len)
698: {
699: struct ar9170_rx_head *head;
700: struct ar9170_rx_macstatus *mac;
701: struct ar9170_rx_phystatus *phy = NULL;
702: struct ieee80211_rx_status status;
703: int mpdu_len;
704: u8 mac_status;
705:
706: if (!IS_STARTED(ar))
707: return;
708:
709: if (unlikely(len < sizeof(*mac)))
710: goto drop;
711:
712: memset(&status, 0, sizeof(status));
713:
714: mpdu_len = len - sizeof(*mac);
715:
716: mac = (void *)(buf + mpdu_len);
717: mac_status = mac->status;
718: switch (mac_status & AR9170_RX_STATUS_MPDU) {
719: case AR9170_RX_STATUS_MPDU_FIRST:
720: ar->ampdu_ref++;
721: /* Aggregated MPDUs start with an PLCP header */
722: if (likely(mpdu_len >= sizeof(struct ar9170_rx_head))) {
723: head = (void *) buf;
724:
725: /*
726: * The PLCP header needs to be cached for the
727: * following MIDDLE + LAST A-MPDU packets.
728: *
729: * So, if you are wondering why all frames seem
730: * to share a common RX status information,
731: * then you have the answer right here...
732: */
733: memcpy(&ar->rx_plcp, (void *) buf,
734: sizeof(struct ar9170_rx_head));
735:
736: mpdu_len -= sizeof(struct ar9170_rx_head);
737: buf += sizeof(struct ar9170_rx_head);
738:
739: ar->rx_has_plcp = true;
740: } else {
741: if (net_ratelimit()) {
742: wiphy_err(ar->hw->wiphy, "plcp info "
743: "is clipped.\n");
744: }
745:
746: goto drop;
747: }
748: break;
749:
750: case AR9170_RX_STATUS_MPDU_LAST:
751: status.flag |= RX_FLAG_AMPDU_IS_LAST;
752:
753: /*
754: * The last frame of an A-MPDU has an extra tail
755: * which does contain the phy status of the whole
756: * aggregate.
757: */
758: if (likely(mpdu_len >= sizeof(struct ar9170_rx_phystatus))) {
759: mpdu_len -= sizeof(struct ar9170_rx_phystatus);
760: phy = (void *)(buf + mpdu_len);
761: } else {
762: if (net_ratelimit()) {
763: wiphy_err(ar->hw->wiphy, "frame tail "
764: "is clipped.\n");
765: }
766:
767: goto drop;
768: }
769: fallthrough;
770:
771: case AR9170_RX_STATUS_MPDU_MIDDLE:
772: /* These are just data + mac status */
773: if (unlikely(!ar->rx_has_plcp)) {
774: if (!net_ratelimit())
775: return;
776:
777: wiphy_err(ar->hw->wiphy, "rx stream does not start "
778: "with a first_mpdu frame tag.\n");
779:
780: goto drop;
781: }
782:
783: head = &ar->rx_plcp;
784: break;
785:
786: case AR9170_RX_STATUS_MPDU_SINGLE:
787: /* single mpdu has both: plcp (head) and phy status (tail) */
788: head = (void *) buf;
789:
790: mpdu_len -= sizeof(struct ar9170_rx_head);
791: mpdu_len -= sizeof(struct ar9170_rx_phystatus);
792:
793: buf += sizeof(struct ar9170_rx_head);
794: phy = (void *)(buf + mpdu_len);
795: break;
796:
797: default:
798: BUG();
799: break;
800: }
801:
802: /* FC + DU + RA + FCS */
803: if (unlikely(mpdu_len < (2 + 2 + ETH_ALEN + FCS_LEN)))
804: goto drop;
805:
806: if (unlikely(carl9170_rx_mac_status(ar, head, mac, &status)))
807: goto drop;
808:
809: if (!carl9170_ampdu_check(ar, buf, mac_status, &status))
810: goto drop;
811:
812: if (phy)
813: carl9170_rx_phy_status(ar, phy, &status);
814: else
815: status.flag |= RX_FLAG_NO_SIGNAL_VAL;
816:
817: if (carl9170_handle_mpdu(ar, buf, mpdu_len, &status))
818: goto drop;
819:
820: return;
821: drop:
822: ar->rx_dropped++;
823: }
SourceFile:drivers/net/wireless/ath/carl9170/rx.c]
|
| 92/2 |
2026/07/05 07:56 |
llm |
expert |
0m
Model:
Tokens:
input: 71564
output: 53
thoughts: 0
|
| 93/2 |
2026/07/05 07:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/rx.c Name:carl9170_handle_mpdu]
Results: map[SourceCode: 659: static int carl9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len,
660: struct ieee80211_rx_status *status)
661: {
662: struct sk_buff *skb;
663:
664: /* (driver) frame trap handler
665: *
666: * Because power-saving mode handing has to be implemented by
667: * the driver/firmware. We have to check each incoming beacon
668: * from the associated AP, if there's new data for us (either
669: * broadcast/multicast or unicast) we have to react quickly.
670: *
671: * So, if you have you want to add additional frame trap
672: * handlers, this would be the perfect place!
673: */
674:
675: carl9170_ps_beacon(ar, buf, len);
676:
677: carl9170_ba_check(ar, buf, len);
678:
679: skb = carl9170_rx_copy_data(buf, len);
680: if (!skb)
681: return -ENOMEM;
682:
683: memcpy(IEEE80211_SKB_RXCB(skb), status, sizeof(*status));
684: ieee80211_rx(ar->hw, skb);
685: return 0;
686: }
SourceFile:drivers/net/wireless/ath/carl9170/rx.c]
|
| 94/2 |
2026/07/05 07:56 |
llm |
expert |
0m
Model:
Tokens:
input: 72110
output: 52
thoughts: 0
|
| 95/2 |
2026/07/05 07:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/rx.c Name:carl9170_ba_check]
Results: map[SourceCode: 573: static void carl9170_ba_check(struct ar9170 *ar, void *data, unsigned int len)
574: {
575: struct ieee80211_bar *bar = data;
576: struct carl9170_bar_list_entry *entry;
577: unsigned int queue;
578:
579: if (likely(!ieee80211_is_back(bar->frame_control)))
580: return;
581:
582: if (len <= sizeof(*bar) + FCS_LEN)
583: return;
584:
585: queue = TID_TO_WME_AC(((le16_to_cpu(bar->control) &
586: IEEE80211_BAR_CTRL_TID_INFO_MASK) >>
587: IEEE80211_BAR_CTRL_TID_INFO_SHIFT) & 7);
588:
589: rcu_read_lock();
590: list_for_each_entry_rcu(entry, &ar->bar_list[queue], list) {
591: struct sk_buff *entry_skb = entry->skb;
592: struct _carl9170_tx_superframe *super = (void *)entry_skb->data;
593: struct ieee80211_bar *entry_bar = (void *)super->frame_data;
594:
595: #define TID_CHECK(a, b) ( \
596: ((a) & cpu_to_le16(IEEE80211_BAR_CTRL_TID_INFO_MASK)) == \
597: ((b) & cpu_to_le16(IEEE80211_BAR_CTRL_TID_INFO_MASK))) \
598:
599: if (bar->start_seq_num == entry_bar->start_seq_num &&
600: TID_CHECK(bar->control, entry_bar->control) &&
601: ether_addr_equal_64bits(bar->ra, entry_bar->ta) &&
602: ether_addr_equal_64bits(bar->ta, entry_bar->ra)) {
603: struct ieee80211_tx_info *tx_info;
604:
605: tx_info = IEEE80211_SKB_CB(entry_skb);
606: tx_info->flags |= IEEE80211_TX_STAT_ACK;
607:
608: spin_lock_bh(&ar->bar_list_lock[queue]);
609: list_del_rcu(&entry->list);
610: spin_unlock_bh(&ar->bar_list_lock[queue]);
611: kfree_rcu(entry, head);
612: break;
613: }
614: }
615: rcu_read_unlock();
616:
617: #undef TID_CHECK
618: }
SourceFile:drivers/net/wireless/ath/carl9170/rx.c]
|
| 96/2 |
2026/07/05 07:56 |
llm |
expert |
0m
Model:
Tokens:
input: 73078
output: 54
thoughts: 0
|
| 97/2 |
2026/07/05 07:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/rx.c Name:carl9170_rx_copy_data]
Results: map[SourceCode: 462: static struct sk_buff *carl9170_rx_copy_data(u8 *buf, int len)
463: {
464: struct sk_buff *skb;
465: int reserved = 0;
466: struct ieee80211_hdr *hdr = (void *) buf;
467:
468: if (ieee80211_is_data_qos(hdr->frame_control)) {
469: u8 *qc = ieee80211_get_qos_ctl(hdr);
470: reserved += NET_IP_ALIGN;
471:
472: if (*qc & IEEE80211_QOS_CTL_A_MSDU_PRESENT)
473: reserved += NET_IP_ALIGN;
474: }
475:
476: if (ieee80211_has_a4(hdr->frame_control))
477: reserved += NET_IP_ALIGN;
478:
479: reserved = 32 + (reserved & NET_IP_ALIGN);
480:
481: skb = dev_alloc_skb(len + reserved);
482: if (likely(skb)) {
483: skb_reserve(skb, reserved);
484: skb_put_data(skb, buf, len);
485: }
486:
487: return skb;
488: }
SourceFile:drivers/net/wireless/ath/carl9170/rx.c]
|
| 98/2 |
2026/07/05 07:56 |
llm |
expert |
0m
Model:
Tokens:
input: 73602
output: 53
thoughts: 0
|
| 99/2 |
2026/07/05 07:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/rx.c Name:carl9170_ampdu_check]
Results: map[SourceCode: 620: static bool carl9170_ampdu_check(struct ar9170 *ar, u8 *buf, u8 ms,
621: struct ieee80211_rx_status *rx_status)
622: {
623: __le16 fc;
624:
625: if ((ms & AR9170_RX_STATUS_MPDU) == AR9170_RX_STATUS_MPDU_SINGLE) {
626: /*
627: * This frame is not part of an aMPDU.
628: * Therefore it is not subjected to any
629: * of the following content restrictions.
630: */
631: return true;
632: }
633:
634: rx_status->flag |= RX_FLAG_AMPDU_DETAILS | RX_FLAG_AMPDU_LAST_KNOWN;
635: rx_status->ampdu_reference = ar->ampdu_ref;
636:
637: /*
638: * "802.11n - 7.4a.3 A-MPDU contents" describes in which contexts
639: * certain frame types can be part of an aMPDU.
640: *
641: * In order to keep the processing cost down, I opted for a
642: * stateless filter solely based on the frame control field.
643: */
644:
645: fc = ((struct ieee80211_hdr *)buf)->frame_control;
646: if (ieee80211_is_data_qos(fc) && ieee80211_is_data_present(fc))
647: return true;
648:
649: if (ieee80211_is_ack(fc) || ieee80211_is_back(fc) ||
650: ieee80211_is_back_req(fc))
651: return true;
652:
653: if (ieee80211_is_action(fc))
654: return true;
655:
656: return false;
657: }
SourceFile:drivers/net/wireless/ath/carl9170/rx.c]
|
| 100/2 |
2026/07/05 07:56 |
llm |
expert |
0m
Model:
Tokens:
input: 74328
output: 54
thoughts: 0
|
| 101/2 |
2026/07/05 07:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/rx.c Name:carl9170_rx_mac_status]
Results: map[SourceCode: 289: static int carl9170_rx_mac_status(struct ar9170 *ar,
290: struct ar9170_rx_head *head, struct ar9170_rx_macstatus *mac,
291: struct ieee80211_rx_status *status)
292: {
293: struct ieee80211_channel *chan;
294: u8 error, decrypt;
295:
296: BUILD_BUG_ON(sizeof(struct ar9170_rx_head) != 12);
297: BUILD_BUG_ON(sizeof(struct ar9170_rx_macstatus) != 4);
298:
299: error = mac->error;
300:
301: if (error & AR9170_RX_ERROR_WRONG_RA) {
302: if (!ar->sniffer_enabled)
303: return -EINVAL;
304: }
305:
306: if (error & AR9170_RX_ERROR_PLCP) {
307: if (!(ar->filter_state & FIF_PLCPFAIL))
308: return -EINVAL;
309:
310: status->flag |= RX_FLAG_FAILED_PLCP_CRC;
311: }
312:
313: if (error & AR9170_RX_ERROR_FCS) {
314: ar->tx_fcs_errors++;
315:
316: if (!(ar->filter_state & FIF_FCSFAIL))
317: return -EINVAL;
318:
319: status->flag |= RX_FLAG_FAILED_FCS_CRC;
320: }
321:
322: decrypt = ar9170_get_decrypt_type(mac);
323: if (!(decrypt & AR9170_RX_ENC_SOFTWARE) &&
324: decrypt != AR9170_ENC_ALG_NONE) {
325: if ((decrypt == AR9170_ENC_ALG_TKIP) &&
326: (error & AR9170_RX_ERROR_MMIC))
327: status->flag |= RX_FLAG_MMIC_ERROR;
328:
329: status->flag |= RX_FLAG_DECRYPTED;
330: }
331:
332: if (error & AR9170_RX_ERROR_DECRYPT && !ar->sniffer_enabled)
333: return -ENODATA;
334:
335: error &= ~(AR9170_RX_ERROR_MMIC |
336: AR9170_RX_ERROR_FCS |
337: AR9170_RX_ERROR_WRONG_RA |
338: AR9170_RX_ERROR_DECRYPT |
339: AR9170_RX_ERROR_PLCP);
340:
341: /* drop any other error frames */
342: if (unlikely(error)) {
343: /* TODO: update netdevice's RX dropped/errors statistics */
344:
345: if (net_ratelimit())
346: wiphy_dbg(ar->hw->wiphy, "received frame with "
347: "suspicious error code (%#x).\n", error);
348:
349: return -EINVAL;
350: }
351:
352: chan = ar->channel;
353: if (chan) {
354: status->band = chan->band;
355: status->freq = chan->center_freq;
356: }
357:
358: switch (mac->status & AR9170_RX_STATUS_MODULATION) {
359: case AR9170_RX_STATUS_MODULATION_CCK:
360: if (mac->status & AR9170_RX_STATUS_SHORT_PREAMBLE)
361: status->enc_flags |= RX_ENC_FLAG_SHORTPRE;
362: switch (head->plcp[0]) {
363: case AR9170_RX_PHY_RATE_CCK_1M:
364: status->rate_idx = 0;
365: break;
366: case AR9170_RX_PHY_RATE_CCK_2M:
367: status->rate_idx = 1;
368: break;
369: case AR9170_RX_PHY_RATE_CCK_5M:
370: status->rate_idx = 2;
371: break;
372: case AR9170_RX_PHY_RATE_CCK_11M:
373: status->rate_idx = 3;
374: break;
375: default:
376: if (net_ratelimit()) {
377: wiphy_err(ar->hw->wiphy, "invalid plcp cck "
378: "rate (%x).\n", head->plcp[0]);
379: }
380:
381: return -EINVAL;
382: }
383: break;
384:
385: case AR9170_RX_STATUS_MODULATION_DUPOFDM:
386: case AR9170_RX_STATUS_MODULATION_OFDM:
387: switch (head->plcp[0] & 0xf) {
388: case AR9170_TXRX_PHY_RATE_OFDM_6M:
389: status->rate_idx = 0;
390: break;
391: case AR9170_TXRX_PHY_RATE_OFDM_9M:
392: status->rate_idx = 1;
393: break;
394: case AR9170_TXRX_PHY_RATE_OFDM_12M:
395: status->rate_idx = 2;
396: break;
397: case AR9170_TXRX_PHY_RATE_OFDM_18M:
398: status->rate_idx = 3;
399: break;
400: case AR9170_TXRX_PHY_RATE_OFDM_24M:
401: status->rate_idx = 4;
402: break;
403: case AR9170_TXRX_PHY_RATE_OFDM_36M:
404: status->rate_idx = 5;
405: break;
406: case AR9170_TXRX_PHY_RATE_OFDM_48M:
407: status->rate_idx = 6;
408: break;
409: case AR9170_TXRX_PHY_RATE_OFDM_54M:
410: status->rate_idx = 7;
411: break;
412: default:
413: if (net_ratelimit()) {
414: wiphy_err(ar->hw->wiphy, "invalid plcp ofdm "
415: "rate (%x).\n", head->plcp[0]);
416: }
417:
418: return -EINVAL;
419: }
420: if (status->band == NL80211_BAND_2GHZ)
421: status->rate_idx += 4;
422: break;
423:
424: case AR9170_RX_STATUS_MODULATION_HT:
425: if (head->plcp[3] & 0x80)
426: status->bw = RATE_INFO_BW_40;
427: if (head->plcp[6] & 0x80)
428: status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
429:
430: status->rate_idx = clamp(head->plcp[3] & 0x7f, 0, 75);
431: status->encoding = RX_ENC_HT;
432: break;
433:
434: default:
435: BUG();
436: return -ENOSYS;
437: }
438:
439: return 0;
440: }
SourceFile:drivers/net/wireless/ath/carl9170/rx.c]
|
| 102/2 |
2026/07/05 07:56 |
llm |
expert |
0m
Model:
Tokens:
input: 76873
output: 56
thoughts: 0
|
| 103/2 |
2026/07/05 07:57 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/carl9170/usb.c Name:carl9170_usb_submit_rx_urb]
Results: map[SourceCode: 316: static int carl9170_usb_submit_rx_urb(struct ar9170 *ar, gfp_t gfp)
317: {
318: struct urb *urb;
319: int err = 0, runs = 0;
320:
321: while ((atomic_read(&ar->rx_anch_urbs) < AR9170_NUM_RX_URBS) &&
322: (runs++ < AR9170_NUM_RX_URBS)) {
323: err = -ENOSPC;
324: urb = usb_get_from_anchor(&ar->rx_pool);
325: if (urb) {
326: usb_anchor_urb(urb, &ar->rx_anch);
327: err = usb_submit_urb(urb, gfp);
328: if (unlikely(err)) {
329: usb_unanchor_urb(urb);
330: usb_anchor_urb(urb, &ar->rx_pool);
331: } else {
332: atomic_dec(&ar->rx_pool_urbs);
333: atomic_inc(&ar->rx_anch_urbs);
334: }
335: usb_free_urb(urb);
336: }
337: }
338:
339: return err;
340: }
SourceFile:drivers/net/wireless/ath/carl9170/usb.c]
|
| 104/2 |
2026/07/05 07:57 |
llm |
expert |
0m
Model:
Tokens:
input: 93493
output: 66
thoughts: 1018
Thoughts: **Analysis of the carl9170 USB Driver Deadlock**
Okay, let's break this down. My initial understanding is that the `carl9170` device, which supports both Full and High Speed connections, has a potential deadlock scenario. My primary concern is how a typical user can trigger it, so I'll work through the possibilities.
Initially, I thought "Peripheral Trigger" = True, because the malicious device itself could be the primary attack vector. If it's on a Full Speed port (OHCI/UHCI), the bug will trigger and deadlock, and since plugging in a device requires physical access, I considered "Accessible From Unprivileged Processes" = False. But then I realized that if the device is ALREADY plugged in, could an unprivileged user still trigger it?
The answer, it seems, is yes. Sending network traffic is enough. But here's the kicker: if it deadlocks under normal operation with any network traffic, it's a *severe* bug that doesn't necessarily need a malicious actor. And then I looked at the code to confirm that the driver can, in fact, work on Full Speed connections.
After some code analysis, I confirmed that `carl9170_usb_probe` does support Full Speed, and the deadlock does indeed exist in the hardirq context when the `carl9170_tx_janitor` is running. `spin_lock_bh` doesn't disable hardirqs. Bingo, a real deadlock!
So, I had to revisit my initial assumptions. Since an unprivileged user *can* trigger it, I am certain it's "Accessible From Unprivileged Processes" = True. Network traffic from an external host will send TX replies to the device, which will trigger the bug. So, "Other Remote Trigger" is also True. Since it's Wi-Fi and not Ethernet, "Ethernet Network Trigger" is False. As for exploitability, I'm marking it False, but it results in a Denial of Service, which is True.
Now I need to be *sure* that an unprivileged user can reliably trigger this. If the device is connected, ANY user can send a UDP packet to an external IP. The kernel will route it, causing the firmware to send a TX status, which triggers the bug. Yes, it's reproducible.
I had concerns if the device would become unusable, given that `carl9170_tx_janitor` runs periodically. But the race window is actually quite small since `carl9170_check_queue_stop_timeout` only holds the lock very briefly. The deadlock won't happen *immediately*. However, the race isn't very severe, because a `WARN_ON_ONCE(in_hardirq())` will immediately trigger on the very first TX status due to the call to `__local_bh_enable_ip`, which checks `in_hardirq()` when called from `spin_unlock_bh`. Therefore, the warning is 100% reproducible on the first TX, even if the deadlock is a race.
Therefore, the final assessment is:
* Exploitable: False
* Denial of Service: True
* Accessible From Unprivileged Processes: True (by sending network traffic if the device is connected to OHCI/UHCI)
* Accessible From User Namespaces: False
* VM Guest Trigger: False
* VM Host Trigger in The Confidential Computing Context: False
* Ethernet Network Trigger: False
* Other Remote Trigger: True (by sending Wi-Fi traffic to the device if connected to OHCI/UHCI)
* Peripheral Trigger: True (by plugging in a malicious USB device)
* Malicious Filesystem Trigger: False
|
| 105/2 |
2026/07/05 07:57 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:true Unprivileged:true UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:true Unprivileged:true UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 106/2 |
2026/07/05 07:57 |
llm |
expert |
1m
Model:
Tokens:
input: 78312
output: 622
thoughts: 9900
Thoughts: **Analysis of the carl9170 USB Driver Warning**
Okay, so I've got this WARNING in `__local_bh_enable_ip`, and it's because `in_hardirq()` is true, but we're trying to enable bottom halves (BHs). The stack trace points to `spin_unlock_bh` being called from within the `carl9170` driver, specifically during the handling of USB transfer completion, within `carl9170_get_queued_skb`. It looks like it's an interrupt URB completion handler. The call stack involves the `dummy_hcd`, and the `dummy_timer`, which suggests hrtimers are involved, and by inference softirqs.
The puzzling thing is, if it's a softirq, why is `in_hardirq()` true? That macro checks the `preempt_count` for `HARDIRQ_MASK`. I see that `dummy_timer` is an hrtimer callback, and these can run in either hardirq *or* softirq context. This trace shows it in softirq, so I'm confused why the `in_hardirq()` check is failing.
My first thought, maybe it's because `dummy_timer` is called from the IRQ stack? But the stack clearly shows `handle_softirqs`, so itβs running in softirq. Then I remember that `__local_bh_enable_ip` can WARN if interrupts are *disabled*. The kernel is warning that `__lockdep_enabled && !this_cpu_read(hardirqs_enabled)`.
So, the issue isn't that we are *in* a hardirq, but that interrupts are disabled when they shouldn't be. That means, the problem is with how the USB completion handler is called, and this likely comes from the `dummy_timer`, which locks the interrupt flag, and calls `usb_hcd_giveback_urb`. The unlock is done with `spin_unlock`, not `spin_unlock_irqrestore`, so it keeps IRQs disabled when calling the completion handler. Then, the completion handler uses `spin_lock_bh` and `spin_unlock_bh`, which is incorrect, as BH cannot be enabled when hardware interrupts are disabled. So, `carl9170_get_queued_skb` is the culprit for the incorrect `spin_lock_bh` and `spin_unlock_bh` calls, which are wrapped in the completion handler.
Is it a bug in `dummy_hcd` or `carl9170`? The key is `usb_hcd_giveback_urb`. The docs say it can be called in BH or caller context. In this case, `dummy_hcd` doesn't set `HCD_BH`, so the completion handler runs directly from `dummy_timer` which runs with IRQs disabled.
Now I need to check if real HCDs do the same thing. Does a real HCD set the `HCD_BH` flag? The documentation says the HCD has freed locks and that the driver can do what it wants with the URB. It *doesn't* specify if interrupts are enabled or disabled, but in hardirq HCDs, the completion callback *must* be able to run with IRQs disabled. My grep confirmed that xHCI and EHCI, most likely the ones connected to high-speed devices, *do* set `HCD_BH`, so the completion runs in a tasklet (BH context). But UHCI and OHCI, the ones for full-speed devices, donβt set `HCD_BH`, so their completion handlers are called from hardirq with interrupts disabled. With full speed, `carl9170` *could* be using UHCI or OHCI.
If a completion handler calls `spin_lock_bh`, it *cannot* work on HCDs where completion is called with IRQs disabled. And that's exactly what's happening here!
Is this exploitable? Itβs just a `WARN_ON_ONCE` about an incorrect API usage. If the warning occurs, it checks if it's safe to run softirqs which are *only* executed if IRQs are enabled!
If this occurs in production, `CONFIG_TRACE_IRQFLAGS` is disabled. The `spin_unlock_bh` call only decrements the preempt count. The code correctly handles that it doesn't call `do_softirq()` because it detects the current is in a hardirq. Thus, in production, this is harmless, and the lockdep warning is just a developer flag.
Can this be triggered by a malicious USB
|
| 107/1 |
2026/07/05 07:58 |
action |
format-explanation |
0m
Results: map[Explanation:**Bug Analysis:**
The bug report indicates a `WARNING` in `__local_bh_enable_ip()` triggered by
`lockdep_assert_irqs_enabled()`.
By analyzing the stack trace and the source code, the sequence of events is as
follows:
1. The `dummy_hcd` driver (used for emulating USB devices) completes an URB by
calling `usb_hcd_giveback_urb()`. Because `dummy_hcd` does not set the `HCD_BH`
flag, the completion handler is invoked synchronously in the context of the
`dummy_timer` hrtimer, where hardware interrupts are disabled (via
`spin_lock_irqsave`).
2. The URB completion handler for the `carl9170` WiFi driver
(`carl9170_usb_rx_irq_complete()`) is executed.
3. The driver processes a TX completion response (`CARL9170_RSP_TXCOMP`) from
the device, eventually calling `carl9170_get_queued_skb()`.
4. Inside `carl9170_get_queued_skb()`, the driver uses `spin_lock_bh()` and
`spin_unlock_bh()` to protect the queue.
5. `spin_unlock_bh()` calls `__local_bh_enable_ip()`, which expects hardware
interrupts to be enabled. Since they are currently disabled by the HCD, lockdep
throws a warning.
**Security Impact:**
* **Exploitable:** **No.** This is purely an API usage violation caught by
lockdep and debug assertions. There is no memory corruption, out-of-bounds
access, or information leak.
* **Denial of Service:** **No.** In production builds (where lockdep,
`CONFIG_TRACE_IRQFLAGS`, and `panic_on_warn` are disabled), calling
`spin_unlock_bh()` with interrupts disabled is harmless. The function will
simply decrement the preempt count and skip running softirqs because
`in_interrupt()` evaluates to true. It does not inadvertently re-enable hardware
interrupts, nor does it cause a deadlock or system crash.
* **Accessible From Unprivileged Processes:** **Yes.** An unprivileged local
user can trigger this warning by simply sending network traffic (e.g., UDP
packets) over the WiFi interface, which naturally generates TX completion events
from the firmware.
* **Peripheral Trigger:** **Yes.** A malicious USB device can spoof
`CARL9170_RSP_TXCOMP` responses on the interrupt endpoint to trigger this code
path.
In summary, this is a benign lockdep warning resulting from the `carl9170`
driver using bottom-half (BH) spinlocks inside an URB completion handler that
may be called with hardware interrupts disabled (depending on the specific USB
Host Controller). It poses no security risk in production environments.]
|