| 0/0 |
2026/09/17 01:36 |
flow |
assessment-security |
47m
Results: map[DenialOfService:true Explanation:**Analysis of the Bug**
The bug report indicates a `WARN_ON` triggered in `drm_property_add_enum` due to
`strlen(name) >= DRM_PROP_NAME_LEN`.
1. **Root Cause**:
The `gud` (Generic USB Display) driver queries the USB device for TV mode
names during probe (`gud_connector_add_tv_mode`). It allocates a buffer using
`kmalloc` and reads the mode names directly from the USB device via a control
transfer (`gud_usb_get`). The driver assumes the data returned by the USB
device is properly null-terminated or at least contains null bytes within the
expected boundaries.
The driver then passes these strings to
`drm_mode_create_tv_properties_legacy`, which in turn calls
`drm_property_add_enum`. `drm_property_add_enum` calls `strlen(name)` on the
provided string. If a malicious USB device returns a buffer completely devoid
of null bytes, `strlen` will read past the end of the `kmalloc` allocated
buffer, resulting in an out-of-bounds (OOB) read.
2. **Exploitability (Information Leak)**:
If the OOB read by `strlen` encounters a null byte within the adjacent heap
memory (specifically within the next 15 bytes, such that `strlen(name) <
DRM_PROP_NAME_LEN`), the `WARN_ON` is bypassed. The code then proceeds to
call `strscpy_pad`, which copies the out-of-bounds heap data into the
`prop_enum->name` field.
Crucially, `drm_mode_create_tv_properties_legacy` ignores the return value of
`drm_property_add_enum`. This means the USB device probe will successfully
complete, and the DRM device will be registered. A local attacker can then
use the `DRM_IOCTL_MODE_GETPROPERTY` ioctl to read the property enums,
effectively leaking up to 15 bytes of adjacent kernel heap memory to
userspace. This information leak can be used to bypass KASLR or leak
sensitive pointers, making the bug **Exploitable**.
3. **Denial of Service (DoS)**:
If the `kmalloc` buffer happens to be allocated at the very end of a page,
and the subsequent page is unmapped, the `strlen` call will attempt to read
from unmapped memory. This will cause a page fault in kernel space, leading
to a kernel oops/panic and crashing the system. Thus, it can be used for
**Denial of Service**.
4. **Trigger Mechanism**:
The vulnerability is located in the USB device probe path of the `gud`
driver. It requires the kernel to process a malicious USB device descriptor
and control transfer responses. Therefore, it can be triggered by physically
plugging in a malicious USB device (**Peripheral Trigger**). It cannot be
triggered over the network, via a filesystem, or by an unprivileged user
process (unless the user has physical access to plug in the device, or root
privileges to emulate one via `dummy_hcd`/`raw-gadget`). Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/09/17 01:36 |
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>
#ifndef __NR_mmap
#define __NR_mmap 192
#endif
#undef __NR_mmap
#define __NR_mmap __NR_mmap2
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;
}
struct vusb_descriptor {
uint8_t req_type;
uint8_t desc_type;
uint32_t len;
char data[0];
} __attribute__((packed));
struct vusb_descriptors {
uint32_t len;
struct vusb_descriptor* generic;
struct vusb_descriptor* descs[0];
} __attribute__((packed));
struct vusb_response {
uint8_t type;
uint8_t req;
uint32_t len;
char data[0];
} __attribute__((packed));
struct vusb_responses {
uint32_t len;
struct vusb_response* generic;
struct vusb_response* resps[0];
} __attribute__((packed));
static bool lookup_control_response(const struct vusb_descriptors* descs, const struct vusb_responses* resps,
struct usb_ctrlrequest* ctrl, char** response_data, uint32_t* response_length)
{
int descs_num = 0;
int resps_num = 0;
if (descs)
descs_num = (descs->len - offsetof(struct vusb_descriptors, descs)) / sizeof(descs->descs[0]);
if (resps)
resps_num = (resps->len - offsetof(struct vusb_responses, resps)) / sizeof(resps->resps[0]);
uint8_t req = ctrl->bRequest;
uint8_t req_type = ctrl->bRequestType & USB_TYPE_MASK;
uint8_t desc_type = ctrl->wValue >> 8;
if (req == USB_REQ_GET_DESCRIPTOR) {
int i;
for (i = 0; i < descs_num; i++) {
struct vusb_descriptor* desc = descs->descs[i];
if (!desc)
continue;
if (desc->req_type == req_type && desc->desc_type == desc_type) {
*response_length = desc->len;
if (*response_length != 0)
*response_data = &desc->data[0];
else
*response_data = NULL;
return true;
}
}
if (descs && descs->generic) {
*response_data = &descs->generic->data[0];
*response_length = descs->generic->len;
return true;
}
} else {
int i;
for (i = 0; i < resps_num; i++) {
struct vusb_response* resp = resps->resps[i];
if (!resp)
continue;
if (resp->type == req_type && resp->req == req) {
*response_length = resp->len;
if (*response_length != 0)
*response_data = &resp->data[0];
else
*response_data = NULL;
return true;
}
}
if (resps && resps->generic) {
*response_data = &resps->generic->data[0];
*response_length = resps->generic->len;
return true;
}
}
return false;
}
#define UDC_NAME_LENGTH_MAX 128
struct usb_raw_init {
__u8 driver_name[UDC_NAME_LENGTH_MAX];
__u8 device_name[UDC_NAME_LENGTH_MAX];
__u8 speed;
};
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID = 0,
USB_RAW_EVENT_CONNECT = 1,
USB_RAW_EVENT_CONTROL = 2,
};
struct usb_raw_event {
__u32 type;
__u32 length;
__u8 data[0];
};
struct usb_raw_ep_io {
__u16 ep;
__u16 flags;
__u32 length;
__u8 data[0];
};
#define USB_RAW_EPS_NUM_MAX 30
#define USB_RAW_EP_NAME_MAX 16
#define USB_RAW_EP_ADDR_ANY 0xff
struct usb_raw_ep_caps {
__u32 type_control : 1;
__u32 type_iso : 1;
__u32 type_bulk : 1;
__u32 type_int : 1;
__u32 dir_in : 1;
__u32 dir_out : 1;
};
struct usb_raw_ep_limits {
__u16 maxpacket_limit;
__u16 max_streams;
__u32 reserved;
};
struct usb_raw_ep_info {
__u8 name[USB_RAW_EP_NAME_MAX];
__u32 addr;
struct usb_raw_ep_caps caps;
struct usb_raw_ep_limits limits;
};
struct usb_raw_eps_info {
struct usb_raw_ep_info eps[USB_RAW_EPS_NUM_MAX];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
#define USB_RAW_IOCTL_RUN _IO('U', 1)
#define USB_RAW_IOCTL_EVENT_FETCH _IOR('U', 2, struct usb_raw_event)
#define USB_RAW_IOCTL_EP0_WRITE _IOW('U', 3, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP0_READ _IOWR('U', 4, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_ENABLE _IOW('U', 5, struct usb_endpoint_descriptor)
#define USB_RAW_IOCTL_EP_DISABLE _IOW('U', 6, __u32)
#define USB_RAW_IOCTL_EP_WRITE _IOW('U', 7, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_READ _IOWR('U', 8, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_CONFIGURE _IO('U', 9)
#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
#define USB_RAW_IOCTL_EPS_INFO _IOR('U', 11, struct usb_raw_eps_info)
#define USB_RAW_IOCTL_EP0_STALL _IO('U', 12)
#define USB_RAW_IOCTL_EP_SET_HALT _IOW('U', 13, __u32)
#define USB_RAW_IOCTL_EP_CLEAR_HALT _IOW('U', 14, __u32)
#define USB_RAW_IOCTL_EP_SET_WEDGE _IOW('U', 15, __u32)
static int usb_raw_open()
{
return open("/dev/raw-gadget", O_RDWR);
}
static int usb_raw_init(int fd, uint32_t speed, const char* driver, const char* device)
{
struct usb_raw_init arg;
strncpy((char*)&arg.driver_name[0], driver, sizeof(arg.driver_name));
strncpy((char*)&arg.device_name[0], device, sizeof(arg.device_name));
arg.speed = speed;
return ioctl(fd, USB_RAW_IOCTL_INIT, &arg);
}
static int usb_raw_run(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_RUN, 0);
}
static int usb_raw_configure(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_CONFIGURE, 0);
}
static int usb_raw_vbus_draw(int fd, uint32_t power)
{
return ioctl(fd, USB_RAW_IOCTL_VBUS_DRAW, power);
}
static int usb_raw_ep0_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_WRITE, io);
}
static int usb_raw_ep0_read(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_READ, io);
}
static int usb_raw_event_fetch(int fd, struct usb_raw_event* event)
{
return ioctl(fd, USB_RAW_IOCTL_EVENT_FETCH, event);
}
static int usb_raw_ep_enable(int fd, struct usb_endpoint_descriptor* desc)
{
return ioctl(fd, USB_RAW_IOCTL_EP_ENABLE, desc);
}
static int usb_raw_ep_disable(int fd, int ep)
{
return ioctl(fd, USB_RAW_IOCTL_EP_DISABLE, ep);
}
static int usb_raw_ep0_stall(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_STALL, 0);
}
static int lookup_interface(int fd, uint8_t bInterfaceNumber, uint8_t bAlternateSetting)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
for (int i = 0; i < index->ifaces_num; i++) {
if (index->ifaces[i].bInterfaceNumber == bInterfaceNumber &&
index->ifaces[i].bAlternateSetting == bAlternateSetting)
return i;
}
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_control_io(volatile long a0, volatile long a1, volatile long a2)
{
int fd = a0;
const struct vusb_descriptors* descs = (const struct vusb_descriptors*)a1;
const struct vusb_responses* resps = (const struct vusb_responses*)a2;
struct usb_raw_control_event event;
event.inner.type = 0;
event.inner.length = USB_MAX_PACKET_SIZE;
int rv = usb_raw_event_fetch(fd, (struct usb_raw_event*)&event);
if (rv < 0) {
return rv;
}
if (event.inner.type != USB_RAW_EVENT_CONTROL) {
return -1;
}
char* response_data = NULL;
uint32_t response_length = 0;
if ((event.ctrl.bRequestType & USB_DIR_IN) && event.ctrl.wLength) {
if (!lookup_control_response(descs, resps, &event.ctrl, &response_data, &response_length)) {
usb_raw_ep0_stall(fd);
return -1;
}
} else {
if ((event.ctrl.bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD ||
event.ctrl.bRequest == USB_REQ_SET_INTERFACE) {
int iface_num = event.ctrl.wIndex;
int alt_set = event.ctrl.wValue;
int iface_index = lookup_interface(fd, iface_num, alt_set);
if (iface_index < 0) {
} else {
set_interface(fd, iface_index);
}
}
response_length = event.ctrl.wLength;
}
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;
if ((event.ctrl.bRequestType & USB_DIR_IN) && !event.ctrl.wLength) {
response_length = USB_MAX_PACKET_SIZE;
}
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) && event.ctrl.wLength) {
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 0;
}
uint64_t r[1] = {0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x7ffff000, /*len=*/0x1000, /*prot=*/0, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32, /*fd=*/(intptr_t)-1, /*offset=*/0);
syscall(__NR_mmap, /*addr=*/0x80000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32, /*fd=*/(intptr_t)-1, /*offset=*/0);
syscall(__NR_mmap, /*addr=*/0x81000000, /*len=*/0x1000, /*prot=*/0, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32, /*fd=*/(intptr_t)-1, /*offset=*/0);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_usb_connect arguments: [
// speed: usb_device_speed = 0x0 (4 bytes)
// dev_len: len = 0x32 (4 bytes)
// dev: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {12 01 00 02 00 00 00 40 50 1d 4d 61 00 01 00 00 00 01 09 02 20 00 01 01 00 80 32 09 04 00 00 02 ff 00 00 00 07 05 01 02} (length 0x28)
// }
// }
// }
// conn_descs: nil
// ]
// returns fd_usb
memcpy((void*)0x80001000, "... [truncated large byte array] ...", 40);
res = -1;
res = syz_usb_connect(/*speed=*/0, /*dev_len=*/0x32, /*dev=*/0x80001000, /*conn_descs=*/0);
if (res != -1)
r[0] = res;
// syz_usb_control_io arguments: [
// fd: fd_usb (resource)
// descs: nil
// resps: ptr[in, vusb_responses] {
// vusb_responses {
// len: len = 0x84 (4 bytes)
// generic: ptr[in, vusb_response_generic] {
// vusb_response_generic {
// type: usb_request_types = 0x20 (1 bytes)
// req: usb_requests = 0x90069109b15ef6c8 (1 bytes)
// len: bytesize = 0x1e (4 bytes)
// data: buffer: {4d 61 50 1d 01 00 00 00 00 00 00 00 10 00 00 00 00 00 80 07 00 00 00 00 00 00 38 04 00 00} (length 0x1e)
// }
// }
// get_interface: nil
// get_configuration: nil
// hub_USB_REQ_GET_STATUS_hub: nil
// hub_USB_REQ_GET_STATUS_port: nil
// asix_AX_CMD_READ_MII_REG: nil
// asix_AX_CMD_STATMNGSTS_REG: nil
// asix_AX_CMD_READ_EEPROM: nil
// asix_AX_CMD_READ_RX_CTL: nil
// asix_AX_CMD_READ_NODE_ID: nil
// asix_AX88172_CMD_READ_NODE_ID: nil
// asix_AX_CMD_READ_PHY_ID: nil
// asix_AX_CMD_READ_MEDIUM_STATUS: nil
// asix_AX_CMD_READ_MONITOR_MODE: nil
// asix_AX_CMD_READ_GPIOS: nil
// asix_AX_CMD_SW_PHY_STATUS: nil
// }
// }
// ]
*(uint32_t*)0x80000000 = 0x84;
*(uint32_t*)0x80000004 = 0x80000100;
*(uint8_t*)0x80000100 = 0x20;
*(uint8_t*)0x80000101 = 0xc8;
*(uint32_t*)0x80000102 = 0x1e;
memcpy((void*)0x80000106, "\x4d\x61\x50\x1d\x01\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x80\x07\x00\x00\x00\x00\x00\x00\x38\x04\x00\x00", 30);
*(uint32_t*)0x80000008 = 0;
*(uint32_t*)0x8000000c = 0;
*(uint32_t*)0x80000010 = 0;
*(uint32_t*)0x80000014 = 0;
*(uint32_t*)0x80000018 = 0;
*(uint32_t*)0x8000001c = 0;
*(uint32_t*)0x80000020 = 0;
*(uint32_t*)0x80000024 = 0;
*(uint32_t*)0x80000028 = 0;
*(uint32_t*)0x8000002c = 0;
*(uint32_t*)0x80000030 = 0;
*(uint32_t*)0x80000034 = 0;
*(uint32_t*)0x80000038 = 0;
*(uint32_t*)0x8000003c = 0;
*(uint32_t*)0x80000040 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000000);
// syz_usb_control_io arguments: [
// fd: fd_usb (resource)
// descs: nil
// resps: ptr[in, vusb_responses] {
// vusb_responses {
// len: len = 0x84 (4 bytes)
// generic: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {40 3f 01 00 00 00 80} (length 0x7)
// }
// }
// }
// get_interface: nil
// get_configuration: nil
// hub_USB_REQ_GET_STATUS_hub: nil
// hub_USB_REQ_GET_STATUS_port: nil
// asix_AX_CMD_READ_MII_REG: nil
// asix_AX_CMD_STATMNGSTS_REG: nil
// asix_AX_CMD_READ_EEPROM: nil
// asix_AX_CMD_READ_RX_CTL: nil
// asix_AX_CMD_READ_NODE_ID: nil
// asix_AX88172_CMD_READ_NODE_ID: nil
// asix_AX_CMD_READ_PHY_ID: nil
// asix_AX_CMD_READ_MEDIUM_STATUS: nil
// asix_AX_CMD_READ_MONITOR_MODE: nil
// asix_AX_CMD_READ_GPIOS: nil
// asix_AX_CMD_SW_PHY_STATUS: nil
// }
// }
// ]
*(uint32_t*)0x80000000 = 0x84;
*(uint32_t*)0x80000004 = 0x80000200;
memcpy((void*)0x80000200, "\x40\x3f\x01\x00\x00\x00\x80", 7);
*(uint32_t*)0x80000008 = 0;
*(uint32_t*)0x8000000c = 0;
*(uint32_t*)0x80000010 = 0;
*(uint32_t*)0x80000014 = 0;
*(uint32_t*)0x80000018 = 0;
*(uint32_t*)0x8000001c = 0;
*(uint32_t*)0x80000020 = 0;
*(uint32_t*)0x80000024 = 0;
*(uint32_t*)0x80000028 = 0;
*(uint32_t*)0x8000002c = 0;
*(uint32_t*)0x80000030 = 0;
*(uint32_t*)0x80000034 = 0;
*(uint32_t*)0x80000038 = 0;
*(uint32_t*)0x8000003c = 0;
*(uint32_t*)0x80000040 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000000);
// syz_usb_control_io arguments: [
// fd: fd_usb (resource)
// descs: nil
// resps: ptr[in, vusb_responses] {
// vusb_responses {
// len: len = 0x84 (4 bytes)
// generic: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// }
// }
// get_interface: nil
// get_configuration: nil
// hub_USB_REQ_GET_STATUS_hub: nil
// hub_USB_REQ_GET_STATUS_port: nil
// asix_AX_CMD_READ_MII_REG: nil
// asix_AX_CMD_STATMNGSTS_REG: nil
// asix_AX_CMD_READ_EEPROM: nil
// asix_AX_CMD_READ_RX_CTL: nil
// asix_AX_CMD_READ_NODE_ID: nil
// asix_AX88172_CMD_READ_NODE_ID: nil
// asix_AX_CMD_READ_PHY_ID: nil
// asix_AX_CMD_READ_MEDIUM_STATUS: nil
// asix_AX_CMD_READ_MONITOR_MODE: nil
// asix_AX_CMD_READ_GPIOS: nil
// asix_AX_CMD_SW_PHY_STATUS: nil
// }
// }
// ]
*(uint32_t*)0x80000000 = 0x84;
*(uint32_t*)0x80000004 = 0x80000300;
*(uint32_t*)0x80000008 = 0;
*(uint32_t*)0x8000000c = 0;
*(uint32_t*)0x80000010 = 0;
*(uint32_t*)0x80000014 = 0;
*(uint32_t*)0x80000018 = 0;
*(uint32_t*)0x8000001c = 0;
*(uint32_t*)0x80000020 = 0;
*(uint32_t*)0x80000024 = 0;
*(uint32_t*)0x80000028 = 0;
*(uint32_t*)0x8000002c = 0;
*(uint32_t*)0x80000030 = 0;
*(uint32_t*)0x80000034 = 0;
*(uint32_t*)0x80000038 = 0;
*(uint32_t*)0x8000003c = 0;
*(uint32_t*)0x80000040 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000000);
// syz_usb_control_io$printer arguments: [
// fd: fd_usb_printer (resource)
// descs: nil
// resps: ptr[in, vusb_responses_printer] {
// vusb_responses_printer {
// len: len = 0x34 (4 bytes)
// generic: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {40 16 05} (length 0x3)
// }
// }
// }
// USB_REQ_GET_INTERFACE: nil
// USB_REQ_GET_CONFIGURATION: nil
// USBLP_REQ_GET_ID: nil
// USBLP_REQ_GET_STATUS: nil
// USBLP_REQ_HP_CHANNEL_CHANGE_REQUEST: nil
// }
// }
// ]
*(uint32_t*)0x80000d80 = 0x34;
*(uint32_t*)0x80000d84 = 0x80000a80;
memcpy((void*)0x80000a80, "\x40\x16\x05", 3);
*(uint32_t*)0x80000d88 = 0;
*(uint32_t*)0x80000d8c = 0;
*(uint32_t*)0x80000d90 = 0;
*(uint32_t*)0x80000d94 = 0;
*(uint32_t*)0x80000d98 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000d80);
// syz_usb_control_io$cdc_ncm arguments: [
// fd: fd_usb_cdc_ncm (resource)
// descs: nil
// resps: ptr[in, vusb_responses_cdc_ncm] {
// vusb_responses_cdc_ncm {
// len: len = 0x44 (4 bytes)
// generic: nil
// USB_REQ_GET_INTERFACE: nil
// USB_REQ_GET_CONFIGURATION: nil
// USB_CDC_GET_NTB_PARAMETERS: ptr[in, vusb_response_t[USB_TYPE_CLASS, USB_CDC_GET_NTB_PARAMETERS, usb_cdc_ncm_ntb_parameters]] {
// vusb_response_t[USB_TYPE_CLASS, USB_CDC_GET_NTB_PARAMETERS, usb_cdc_ncm_ntb_parameters] {
// type: const = 0x20 (1 bytes)
// req: const = 0x80 (1 bytes)
// len: bytesize = 0x1c (4 bytes)
// data: usb_cdc_ncm_ntb_parameters {
// wLength: int16 = 0x80a (2 bytes)
// bmNtbFormatsSupported: int16 = 0x7 (2 bytes)
// dwNtbInMaxSize: int32 = 0x4 (4 bytes)
// wNdpInDivisor: int16 = 0x7 (2 bytes)
// wNdpInPayloadRemainder: int16 = 0x5 (2 bytes)
// wNdpInAlignment: int16 = 0x3 (2 bytes)
// wPadding1: int16 = 0x7 (2 bytes)
// dwNtbOutMaxSize: int32 = 0x47 (4 bytes)
// wNdpOutDivisor: int16 = 0x14 (2 bytes)
// wNdpOutPayloadRemainder: int16 = 0x9 (2 bytes)
// wNdpOutAlignment: int16 = 0x7e4 (2 bytes)
// wNtbOutMaxDatagrams: int16 = 0x2 (2 bytes)
// }
// }
// }
// USB_CDC_GET_NTB_INPUT_SIZE: nil
// USB_CDC_GET_NTB_FORMAT: nil
// USB_CDC_GET_MAX_DATAGRAM_SIZE: nil
// USB_CDC_GET_CRC_MODE: nil
// }
// }
// ]
*(uint32_t*)0x80000140 = 0x44;
*(uint32_t*)0x80000144 = 0;
*(uint32_t*)0x80000148 = 0;
*(uint32_t*)0x8000014c = 0;
*(uint32_t*)0x80000150 = 0x80000240;
*(uint8_t*)0x80000240 = 0x20;
*(uint8_t*)0x80000241 = 0x80;
*(uint32_t*)0x80000242 = 0x1c;
*(uint16_t*)0x80000246 = 0x80a;
*(uint16_t*)0x80000248 = 7;
*(uint32_t*)0x8000024a = 4;
*(uint16_t*)0x8000024e = 7;
*(uint16_t*)0x80000250 = 5;
*(uint16_t*)0x80000252 = 3;
*(uint16_t*)0x80000254 = 7;
*(uint32_t*)0x80000256 = 0x47;
*(uint16_t*)0x8000025a = 0x14;
*(uint16_t*)0x8000025c = 9;
*(uint16_t*)0x8000025e = 0x7e4;
*(uint16_t*)0x80000260 = 2;
*(uint32_t*)0x80000154 = 0;
*(uint32_t*)0x80000158 = 0;
*(uint32_t*)0x8000015c = 0;
*(uint32_t*)0x80000160 = 0;
syz_usb_control_io(/*fd=*/-1, /*descs=*/0, /*resps=*/0x80000140);
// syz_usb_control_io$rtl8150 arguments: [
// fd: fd_usb_rtl8150 (resource)
// descs: nil
// resps: ptr[in, vusb_responses_rtl8150] {
// vusb_responses_rtl8150 {
// len: len = 0x2c (4 bytes)
// generic: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {20 0f 14} (length 0x3)
// }
// }
// }
// USB_REQ_GET_INTERFACE: nil
// USB_REQ_GET_CONFIGURATION: nil
// RTL8150_REQ_GET_REGS: nil
// RTL8150_REQ_SET_REGS: nil
// }
// }
// ]
*(uint32_t*)0x80000480 = 0x2c;
*(uint32_t*)0x80000484 = 0x80000240;
memcpy((void*)0x80000240, "\x20\x0f\x14", 3);
*(uint32_t*)0x80000488 = 0;
*(uint32_t*)0x8000048c = 0;
*(uint32_t*)0x80000490 = 0;
*(uint32_t*)0x80000494 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000480);
// syz_usb_control_io$uac3 arguments: [
// fd: fd_usb_uac3 (resource)
// descs: nil
// resps: ptr[in, vusb_responses_uac1] {
// vusb_responses_uac1 {
// len: len = 0x44 (4 bytes)
// generic: ptr[in, vusb_response_generic] {
// vusb_response_generic {
// type: usb_request_types = 0x40 (1 bytes)
// req: usb_requests = 0xc (1 bytes)
// len: bytesize = 0x50 (4 bytes)
// data: buffer: {47 e4 6c 6b 73 a0 17 f1 08 0f 35 6b 87 0d 7b 27 d0 4a e4 98 26 37 1b 57 35 84 b5 fa f4 77 83 0e 8b 37 f4 b4 dc 7c 21 ba 81 e0 6e 3c b7 0e 47 04 cc 4c 55 3b 3b 12 e4 13 43 ee 90 a6 e6 e1 ae c3 88 ea 5d 65 29 4a 5a 16 39 97 78 70 3c ed 13 3e} (length 0x50)
// }
// }
// USB_REQ_GET_INTERFACE: nil
// USB_REQ_GET_CONFIGURATION: nil
// audio_UAC_GET_CUR: nil
// audio_UAC_GET_MIN: nil
// audio_UAC_GET_MAX: nil
// audio_UAC_GET_RES: nil
// audio_UAC_GET_MEM: nil
// }
// }
// ]
*(uint32_t*)0x80000680 = 0x44;
*(uint32_t*)0x80000684 = 0x80000340;
*(uint8_t*)0x80000340 = 0x40;
*(uint8_t*)0x80000341 = 0xc;
*(uint32_t*)0x80000342 = 0x50;
memcpy((void*)0x80000346, "... [truncated large byte array] ...", 80);
*(uint32_t*)0x80000688 = 0;
*(uint32_t*)0x8000068c = 0;
*(uint32_t*)0x80000690 = 0;
*(uint32_t*)0x80000694 = 0;
*(uint32_t*)0x80000698 = 0;
*(uint32_t*)0x8000069c = 0;
*(uint32_t*)0x800006a0 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000680);
return 0;
}
]
|
| 2/1 |
2026/09/17 01:36 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/b5692495be56e63dd0879dd861d23f69899ae44d]
|
| 3/1 |
2026/09/17 01:37 |
action |
kernel-builder |
24m
Results: map[KernelObj:/app/workdir/cache/build/c289afe9773bae95300ff3782eadb8aad4030e4d]
|
| 4/1 |
2026/09/17 02:01 |
action |
codesearch-prepare |
17m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/09/17 02:19 |
agent |
expert |
3m
Model:
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger: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:
usb 1-1: config 1 interface 0 altsetting 0 has 1 endpoint descriptor, different from the interface descriptor's value: 2
usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
------------[ cut here ]------------
strlen(name) >= DRM_PROP_NAME_LEN
WARNING: drivers/gpu/drm/drm_property.c:396 at drm_property_add_enum+0x403/0x4c0 drivers/gpu/drm/drm_property.c:396, CPU#1: kworker/1:3/5643
Modules linked in:
CPU: 1 UID: 0 PID: 5643 Comm: kworker/1:3 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Workqueue: usb_hub_wq hub_event
RIP: 0010:drm_property_add_enum+0x403/0x4c0 drivers/gpu/drm/drm_property.c:396
Code: 48 83 c4 10 5b 41 5c 41 5d 41 5e 41 5f 5d e9 d4 2a 49 06 cc e8 5e c3 3a fc 90 0f 0b 90 b8 ea ff ff ff eb dc e8 4e c3 3a fc 90 <0f> 0b 90 b8 ea ff ff ff eb cc e8 3e c3 3a fc 90 0f 0b 90 b8 ea ff
RSP: 0000:ffffc90003d36a78 EFLAGS: 00010293
RAX: ffffffff858c3e62 RBX: 0000000000000050 RCX: ffff888076529f00
RDX: 0000000000000000 RSI: 0000000000000050 RDI: 000000000000001f
RBP: ffff88803440ce00 R08: 0000000000000007 R09: 0000000000000001
R10: ffff88803440ce39 R11: ffffed10068819cb R12: 0000000000000000
R13: ffffc90003d36c40 R14: 0000000000000000 R15: ffff88803440ce00
FS: 0000000000000000(0000) GS:ffff888125049000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000f71fd540 CR3: 00000000262ee000 CR4: 00000000003526f0
Call Trace:
<TASK>
drm_mode_create_tv_properties_legacy+0x1db/0x3f0 drivers/gpu/drm/drm_connector.c:2216
gud_connector_add_tv_mode drivers/gpu/drm/gud/gud_connector.c:402 [inline]
gud_connector_add_properties drivers/gpu/drm/gud/gud_connector.c:525 [inline]
gud_connector_create drivers/gpu/drm/gud/gud_connector.c:680 [inline]
gud_get_connectors+0xe66/0x1a50 drivers/gpu/drm/gud/gud_connector.c:717
gud_probe+0x1125/0x13b0 drivers/gpu/drm/gud/gud_drv.c:635
usb_probe_interface+0x653/0xc60 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_set_configuration+0x1ad8/0x2180 drivers/usb/core/message.c:2268
usb_generic_driver_probe+0x8d/0x150 drivers/usb/core/generic.c:250
usb_probe_device+0x1c3/0x3b0 drivers/usb/core/driver.c:291
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_new_device+0x9aa/0x1690 drivers/usb/core/hub.c:2703
hub_port_connect drivers/usb/core/hub.c:5575 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5715 [inline]
port_event drivers/usb/core/hub.c:5879 [inline]
hub_event+0x28e8/0x4d30 drivers/usb/core/hub.c:5961
process_one_work kernel/workqueue.c:3322 [inline]
process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405
worker_thread+0xa47/0xfb0 kernel/workqueue.c:3486
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
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>
#ifndef __NR_mmap
#define __NR_mmap 192
#endif
#undef __NR_mmap
#define __NR_mmap __NR_mmap2
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;
}
struct vusb_descriptor {
uint8_t req_type;
uint8_t desc_type;
uint32_t len;
char data[0];
} __attribute__((packed));
struct vusb_descriptors {
uint32_t len;
struct vusb_descriptor* generic;
struct vusb_descriptor* descs[0];
} __attribute__((packed));
struct vusb_response {
uint8_t type;
uint8_t req;
uint32_t len;
char data[0];
} __attribute__((packed));
struct vusb_responses {
uint32_t len;
struct vusb_response* generic;
struct vusb_response* resps[0];
} __attribute__((packed));
static bool lookup_control_response(const struct vusb_descriptors* descs, const struct vusb_responses* resps,
struct usb_ctrlrequest* ctrl, char** response_data, uint32_t* response_length)
{
int descs_num = 0;
int resps_num = 0;
if (descs)
descs_num = (descs->len - offsetof(struct vusb_descriptors, descs)) / sizeof(descs->descs[0]);
if (resps)
resps_num = (resps->len - offsetof(struct vusb_responses, resps)) / sizeof(resps->resps[0]);
uint8_t req = ctrl->bRequest;
uint8_t req_type = ctrl->bRequestType & USB_TYPE_MASK;
uint8_t desc_type = ctrl->wValue >> 8;
if (req == USB_REQ_GET_DESCRIPTOR) {
int i;
for (i = 0; i < descs_num; i++) {
struct vusb_descriptor* desc = descs->descs[i];
if (!desc)
continue;
if (desc->req_type == req_type && desc->desc_type == desc_type) {
*response_length = desc->len;
if (*response_length != 0)
*response_data = &desc->data[0];
else
*response_data = NULL;
return true;
}
}
if (descs && descs->generic) {
*response_data = &descs->generic->data[0];
*response_length = descs->generic->len;
return true;
}
} else {
int i;
for (i = 0; i < resps_num; i++) {
struct vusb_response* resp = resps->resps[i];
if (!resp)
continue;
if (resp->type == req_type && resp->req == req) {
*response_length = resp->len;
if (*response_length != 0)
*response_data = &resp->data[0];
else
*response_data = NULL;
return true;
}
}
if (resps && resps->generic) {
*response_data = &resps->generic->data[0];
*response_length = resps->generic->len;
return true;
}
}
return false;
}
#define UDC_NAME_LENGTH_MAX 128
struct usb_raw_init {
__u8 driver_name[UDC_NAME_LENGTH_MAX];
__u8 device_name[UDC_NAME_LENGTH_MAX];
__u8 speed;
};
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID = 0,
USB_RAW_EVENT_CONNECT = 1,
USB_RAW_EVENT_CONTROL = 2,
};
struct usb_raw_event {
__u32 type;
__u32 length;
__u8 data[0];
};
struct usb_raw_ep_io {
__u16 ep;
__u16 flags;
__u32 length;
__u8 data[0];
};
#define USB_RAW_EPS_NUM_MAX 30
#define USB_RAW_EP_NAME_MAX 16
#define USB_RAW_EP_ADDR_ANY 0xff
struct usb_raw_ep_caps {
__u32 type_control : 1;
__u32 type_iso : 1;
__u32 type_bulk : 1;
__u32 type_int : 1;
__u32 dir_in : 1;
__u32 dir_out : 1;
};
struct usb_raw_ep_limits {
__u16 maxpacket_limit;
__u16 max_streams;
__u32 reserved;
};
struct usb_raw_ep_info {
__u8 name[USB_RAW_EP_NAME_MAX];
__u32 addr;
struct usb_raw_ep_caps caps;
struct usb_raw_ep_limits limits;
};
struct usb_raw_eps_info {
struct usb_raw_ep_info eps[USB_RAW_EPS_NUM_MAX];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
#define USB_RAW_IOCTL_RUN _IO('U', 1)
#define USB_RAW_IOCTL_EVENT_FETCH _IOR('U', 2, struct usb_raw_event)
#define USB_RAW_IOCTL_EP0_WRITE _IOW('U', 3, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP0_READ _IOWR('U', 4, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_ENABLE _IOW('U', 5, struct usb_endpoint_descriptor)
#define USB_RAW_IOCTL_EP_DISABLE _IOW('U', 6, __u32)
#define USB_RAW_IOCTL_EP_WRITE _IOW('U', 7, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_READ _IOWR('U', 8, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_CONFIGURE _IO('U', 9)
#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
#define USB_RAW_IOCTL_EPS_INFO _IOR('U', 11, struct usb_raw_eps_info)
#define USB_RAW_IOCTL_EP0_STALL _IO('U', 12)
#define USB_RAW_IOCTL_EP_SET_HALT _IOW('U', 13, __u32)
#define USB_RAW_IOCTL_EP_CLEAR_HALT _IOW('U', 14, __u32)
#define USB_RAW_IOCTL_EP_SET_WEDGE _IOW('U', 15, __u32)
static int usb_raw_open()
{
return open("/dev/raw-gadget", O_RDWR);
}
static int usb_raw_init(int fd, uint32_t speed, const char* driver, const char* device)
{
struct usb_raw_init arg;
strncpy((char*)&arg.driver_name[0], driver, sizeof(arg.driver_name));
strncpy((char*)&arg.device_name[0], device, sizeof(arg.device_name));
arg.speed = speed;
return ioctl(fd, USB_RAW_IOCTL_INIT, &arg);
}
static int usb_raw_run(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_RUN, 0);
}
static int usb_raw_configure(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_CONFIGURE, 0);
}
static int usb_raw_vbus_draw(int fd, uint32_t power)
{
return ioctl(fd, USB_RAW_IOCTL_VBUS_DRAW, power);
}
static int usb_raw_ep0_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_WRITE, io);
}
static int usb_raw_ep0_read(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_READ, io);
}
static int usb_raw_event_fetch(int fd, struct usb_raw_event* event)
{
return ioctl(fd, USB_RAW_IOCTL_EVENT_FETCH, event);
}
static int usb_raw_ep_enable(int fd, struct usb_endpoint_descriptor* desc)
{
return ioctl(fd, USB_RAW_IOCTL_EP_ENABLE, desc);
}
static int usb_raw_ep_disable(int fd, int ep)
{
return ioctl(fd, USB_RAW_IOCTL_EP_DISABLE, ep);
}
static int usb_raw_ep0_stall(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_STALL, 0);
}
static int lookup_interface(int fd, uint8_t bInterfaceNumber, uint8_t bAlternateSetting)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
for (int i = 0; i < index->ifaces_num; i++) {
if (index->ifaces[i].bInterfaceNumber == bInterfaceNumber &&
index->ifaces[i].bAlternateSetting == bAlternateSetting)
return i;
}
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_control_io(volatile long a0, volatile long a1, volatile long a2)
{
int fd = a0;
const struct vusb_descriptors* descs = (const struct vusb_descriptors*)a1;
const struct vusb_responses* resps = (const struct vusb_responses*)a2;
struct usb_raw_control_event event;
event.inner.type = 0;
event.inner.length = USB_MAX_PACKET_SIZE;
int rv = usb_raw_event_fetch(fd, (struct usb_raw_event*)&event);
if (rv < 0) {
return rv;
}
if (event.inner.type != USB_RAW_EVENT_CONTROL) {
return -1;
}
char* response_data = NULL;
uint32_t response_length = 0;
if ((event.ctrl.bRequestType & USB_DIR_IN) && event.ctrl.wLength) {
if (!lookup_control_response(descs, resps, &event.ctrl, &response_data, &response_length)) {
usb_raw_ep0_stall(fd);
return -1;
}
} else {
if ((event.ctrl.bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD ||
event.ctrl.bRequest == USB_REQ_SET_INTERFACE) {
int iface_num = event.ctrl.wIndex;
int alt_set = event.ctrl.wValue;
int iface_index = lookup_interface(fd, iface_num, alt_set);
if (iface_index < 0) {
} else {
set_interface(fd, iface_index);
}
}
response_length = event.ctrl.wLength;
}
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;
if ((event.ctrl.bRequestType & USB_DIR_IN) && !event.ctrl.wLength) {
response_length = USB_MAX_PACKET_SIZE;
}
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) && event.ctrl.wLength) {
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 0;
}
uint64_t r[1] = {0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x7ffff000, /*len=*/0x1000, /*prot=*/0, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32, /*fd=*/(intptr_t)-1, /*offset=*/0);
syscall(__NR_mmap, /*addr=*/0x80000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32, /*fd=*/(intptr_t)-1, /*offset=*/0);
syscall(__NR_mmap, /*addr=*/0x81000000, /*len=*/0x1000, /*prot=*/0, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32, /*fd=*/(intptr_t)-1, /*offset=*/0);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_usb_connect arguments: [
// speed: usb_device_speed = 0x0 (4 bytes)
// dev_len: len = 0x32 (4 bytes)
// dev: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {12 01 00 02 00 00 00 40 50 1d 4d 61 00 01 00 00 00 01 09 02 20 00 01 01 00 80 32 09 04 00 00 02 ff 00 00 00 07 05 01 02} (length 0x28)
// }
// }
// }
// conn_descs: nil
// ]
// returns fd_usb
memcpy((void*)0x80001000, "... [truncated large byte array] ...", 40);
res = -1;
res = syz_usb_connect(/*speed=*/0, /*dev_len=*/0x32, /*dev=*/0x80001000, /*conn_descs=*/0);
if (res != -1)
r[0] = res;
// syz_usb_control_io arguments: [
// fd: fd_usb (resource)
// descs: nil
// resps: ptr[in, vusb_responses] {
// vusb_responses {
// len: len = 0x84 (4 bytes)
// generic: ptr[in, vusb_response_generic] {
// vusb_response_generic {
// type: usb_request_types = 0x20 (1 bytes)
// req: usb_requests = 0x90069109b15ef6c8 (1 bytes)
// len: bytesize = 0x1e (4 bytes)
// data: buffer: {4d 61 50 1d 01 00 00 00 00 00 00 00 10 00 00 00 00 00 80 07 00 00 00 00 00 00 38 04 00 00} (length 0x1e)
// }
// }
// get_interface: nil
// get_configuration: nil
// hub_USB_REQ_GET_STATUS_hub: nil
// hub_USB_REQ_GET_STATUS_port: nil
// asix_AX_CMD_READ_MII_REG: nil
// asix_AX_CMD_STATMNGSTS_REG: nil
// asix_AX_CMD_READ_EEPROM: nil
// asix_AX_CMD_READ_RX_CTL: nil
// asix_AX_CMD_READ_NODE_ID: nil
// asix_AX88172_CMD_READ_NODE_ID: nil
// asix_AX_CMD_READ_PHY_ID: nil
// asix_AX_CMD_READ_MEDIUM_STATUS: nil
// asix_AX_CMD_READ_MONITOR_MODE: nil
// asix_AX_CMD_READ_GPIOS: nil
// asix_AX_CMD_SW_PHY_STATUS: nil
// }
// }
// ]
*(uint32_t*)0x80000000 = 0x84;
*(uint32_t*)0x80000004 = 0x80000100;
*(uint8_t*)0x80000100 = 0x20;
*(uint8_t*)0x80000101 = 0xc8;
*(uint32_t*)0x80000102 = 0x1e;
memcpy((void*)0x80000106, "\x4d\x61\x50\x1d\x01\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x80\x07\x00\x00\x00\x00\x00\x00\x38\x04\x00\x00", 30);
*(uint32_t*)0x80000008 = 0;
*(uint32_t*)0x8000000c = 0;
*(uint32_t*)0x80000010 = 0;
*(uint32_t*)0x80000014 = 0;
*(uint32_t*)0x80000018 = 0;
*(uint32_t*)0x8000001c = 0;
*(uint32_t*)0x80000020 = 0;
*(uint32_t*)0x80000024 = 0;
*(uint32_t*)0x80000028 = 0;
*(uint32_t*)0x8000002c = 0;
*(uint32_t*)0x80000030 = 0;
*(uint32_t*)0x80000034 = 0;
*(uint32_t*)0x80000038 = 0;
*(uint32_t*)0x8000003c = 0;
*(uint32_t*)0x80000040 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000000);
// syz_usb_control_io arguments: [
// fd: fd_usb (resource)
// descs: nil
// resps: ptr[in, vusb_responses] {
// vusb_responses {
// len: len = 0x84 (4 bytes)
// generic: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {40 3f 01 00 00 00 80} (length 0x7)
// }
// }
// }
// get_interface: nil
// get_configuration: nil
// hub_USB_REQ_GET_STATUS_hub: nil
// hub_USB_REQ_GET_STATUS_port: nil
// asix_AX_CMD_READ_MII_REG: nil
// asix_AX_CMD_STATMNGSTS_REG: nil
// asix_AX_CMD_READ_EEPROM: nil
// asix_AX_CMD_READ_RX_CTL: nil
// asix_AX_CMD_READ_NODE_ID: nil
// asix_AX88172_CMD_READ_NODE_ID: nil
// asix_AX_CMD_READ_PHY_ID: nil
// asix_AX_CMD_READ_MEDIUM_STATUS: nil
// asix_AX_CMD_READ_MONITOR_MODE: nil
// asix_AX_CMD_READ_GPIOS: nil
// asix_AX_CMD_SW_PHY_STATUS: nil
// }
// }
// ]
*(uint32_t*)0x80000000 = 0x84;
*(uint32_t*)0x80000004 = 0x80000200;
memcpy((void*)0x80000200, "\x40\x3f\x01\x00\x00\x00\x80", 7);
*(uint32_t*)0x80000008 = 0;
*(uint32_t*)0x8000000c = 0;
*(uint32_t*)0x80000010 = 0;
*(uint32_t*)0x80000014 = 0;
*(uint32_t*)0x80000018 = 0;
*(uint32_t*)0x8000001c = 0;
*(uint32_t*)0x80000020 = 0;
*(uint32_t*)0x80000024 = 0;
*(uint32_t*)0x80000028 = 0;
*(uint32_t*)0x8000002c = 0;
*(uint32_t*)0x80000030 = 0;
*(uint32_t*)0x80000034 = 0;
*(uint32_t*)0x80000038 = 0;
*(uint32_t*)0x8000003c = 0;
*(uint32_t*)0x80000040 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000000);
// syz_usb_control_io arguments: [
// fd: fd_usb (resource)
// descs: nil
// resps: ptr[in, vusb_responses] {
// vusb_responses {
// len: len = 0x84 (4 bytes)
// generic: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// }
// }
// get_interface: nil
// get_configuration: nil
// hub_USB_REQ_GET_STATUS_hub: nil
// hub_USB_REQ_GET_STATUS_port: nil
// asix_AX_CMD_READ_MII_REG: nil
// asix_AX_CMD_STATMNGSTS_REG: nil
// asix_AX_CMD_READ_EEPROM: nil
// asix_AX_CMD_READ_RX_CTL: nil
// asix_AX_CMD_READ_NODE_ID: nil
// asix_AX88172_CMD_READ_NODE_ID: nil
// asix_AX_CMD_READ_PHY_ID: nil
// asix_AX_CMD_READ_MEDIUM_STATUS: nil
// asix_AX_CMD_READ_MONITOR_MODE: nil
// asix_AX_CMD_READ_GPIOS: nil
// asix_AX_CMD_SW_PHY_STATUS: nil
// }
// }
// ]
*(uint32_t*)0x80000000 = 0x84;
*(uint32_t*)0x80000004 = 0x80000300;
*(uint32_t*)0x80000008 = 0;
*(uint32_t*)0x8000000c = 0;
*(uint32_t*)0x80000010 = 0;
*(uint32_t*)0x80000014 = 0;
*(uint32_t*)0x80000018 = 0;
*(uint32_t*)0x8000001c = 0;
*(uint32_t*)0x80000020 = 0;
*(uint32_t*)0x80000024 = 0;
*(uint32_t*)0x80000028 = 0;
*(uint32_t*)0x8000002c = 0;
*(uint32_t*)0x80000030 = 0;
*(uint32_t*)0x80000034 = 0;
*(uint32_t*)0x80000038 = 0;
*(uint32_t*)0x8000003c = 0;
*(uint32_t*)0x80000040 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000000);
// syz_usb_control_io$printer arguments: [
// fd: fd_usb_printer (resource)
// descs: nil
// resps: ptr[in, vusb_responses_printer] {
// vusb_responses_printer {
// len: len = 0x34 (4 bytes)
// generic: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {40 16 05} (length 0x3)
// }
// }
// }
// USB_REQ_GET_INTERFACE: nil
// USB_REQ_GET_CONFIGURATION: nil
// USBLP_REQ_GET_ID: nil
// USBLP_REQ_GET_STATUS: nil
// USBLP_REQ_HP_CHANNEL_CHANGE_REQUEST: nil
// }
// }
// ]
*(uint32_t*)0x80000d80 = 0x34;
*(uint32_t*)0x80000d84 = 0x80000a80;
memcpy((void*)0x80000a80, "\x40\x16\x05", 3);
*(uint32_t*)0x80000d88 = 0;
*(uint32_t*)0x80000d8c = 0;
*(uint32_t*)0x80000d90 = 0;
*(uint32_t*)0x80000d94 = 0;
*(uint32_t*)0x80000d98 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000d80);
// syz_usb_control_io$cdc_ncm arguments: [
// fd: fd_usb_cdc_ncm (resource)
// descs: nil
// resps: ptr[in, vusb_responses_cdc_ncm] {
// vusb_responses_cdc_ncm {
// len: len = 0x44 (4 bytes)
// generic: nil
// USB_REQ_GET_INTERFACE: nil
// USB_REQ_GET_CONFIGURATION: nil
// USB_CDC_GET_NTB_PARAMETERS: ptr[in, vusb_response_t[USB_TYPE_CLASS, USB_CDC_GET_NTB_PARAMETERS, usb_cdc_ncm_ntb_parameters]] {
// vusb_response_t[USB_TYPE_CLASS, USB_CDC_GET_NTB_PARAMETERS, usb_cdc_ncm_ntb_parameters] {
// type: const = 0x20 (1 bytes)
// req: const = 0x80 (1 bytes)
// len: bytesize = 0x1c (4 bytes)
// data: usb_cdc_ncm_ntb_parameters {
// wLength: int16 = 0x80a (2 bytes)
// bmNtbFormatsSupported: int16 = 0x7 (2 bytes)
// dwNtbInMaxSize: int32 = 0x4 (4 bytes)
// wNdpInDivisor: int16 = 0x7 (2 bytes)
// wNdpInPayloadRemainder: int16 = 0x5 (2 bytes)
// wNdpInAlignment: int16 = 0x3 (2 bytes)
// wPadding1: int16 = 0x7 (2 bytes)
// dwNtbOutMaxSize: int32 = 0x47 (4 bytes)
// wNdpOutDivisor: int16 = 0x14 (2 bytes)
// wNdpOutPayloadRemainder: int16 = 0x9 (2 bytes)
// wNdpOutAlignment: int16 = 0x7e4 (2 bytes)
// wNtbOutMaxDatagrams: int16 = 0x2 (2 bytes)
// }
// }
// }
// USB_CDC_GET_NTB_INPUT_SIZE: nil
// USB_CDC_GET_NTB_FORMAT: nil
// USB_CDC_GET_MAX_DATAGRAM_SIZE: nil
// USB_CDC_GET_CRC_MODE: nil
// }
// }
// ]
*(uint32_t*)0x80000140 = 0x44;
*(uint32_t*)0x80000144 = 0;
*(uint32_t*)0x80000148 = 0;
*(uint32_t*)0x8000014c = 0;
*(uint32_t*)0x80000150 = 0x80000240;
*(uint8_t*)0x80000240 = 0x20;
*(uint8_t*)0x80000241 = 0x80;
*(uint32_t*)0x80000242 = 0x1c;
*(uint16_t*)0x80000246 = 0x80a;
*(uint16_t*)0x80000248 = 7;
*(uint32_t*)0x8000024a = 4;
*(uint16_t*)0x8000024e = 7;
*(uint16_t*)0x80000250 = 5;
*(uint16_t*)0x80000252 = 3;
*(uint16_t*)0x80000254 = 7;
*(uint32_t*)0x80000256 = 0x47;
*(uint16_t*)0x8000025a = 0x14;
*(uint16_t*)0x8000025c = 9;
*(uint16_t*)0x8000025e = 0x7e4;
*(uint16_t*)0x80000260 = 2;
*(uint32_t*)0x80000154 = 0;
*(uint32_t*)0x80000158 = 0;
*(uint32_t*)0x8000015c = 0;
*(uint32_t*)0x80000160 = 0;
syz_usb_control_io(/*fd=*/-1, /*descs=*/0, /*resps=*/0x80000140);
// syz_usb_control_io$rtl8150 arguments: [
// fd: fd_usb_rtl8150 (resource)
// descs: nil
// resps: ptr[in, vusb_responses_rtl8150] {
// vusb_responses_rtl8150 {
// len: len = 0x2c (4 bytes)
// generic: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {20 0f 14} (length 0x3)
// }
// }
// }
// USB_REQ_GET_INTERFACE: nil
// USB_REQ_GET_CONFIGURATION: nil
// RTL8150_REQ_GET_REGS: nil
// RTL8150_REQ_SET_REGS: nil
// }
// }
// ]
*(uint32_t*)0x80000480 = 0x2c;
*(uint32_t*)0x80000484 = 0x80000240;
memcpy((void*)0x80000240, "\x20\x0f\x14", 3);
*(uint32_t*)0x80000488 = 0;
*(uint32_t*)0x8000048c = 0;
*(uint32_t*)0x80000490 = 0;
*(uint32_t*)0x80000494 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000480);
// syz_usb_control_io$uac3 arguments: [
// fd: fd_usb_uac3 (resource)
// descs: nil
// resps: ptr[in, vusb_responses_uac1] {
// vusb_responses_uac1 {
// len: len = 0x44 (4 bytes)
// generic: ptr[in, vusb_response_generic] {
// vusb_response_generic {
// type: usb_request_types = 0x40 (1 bytes)
// req: usb_requests = 0xc (1 bytes)
// len: bytesize = 0x50 (4 bytes)
// data: buffer: {47 e4 6c 6b 73 a0 17 f1 08 0f 35 6b 87 0d 7b 27 d0 4a e4 98 26 37 1b 57 35 84 b5 fa f4 77 83 0e 8b 37 f4 b4 dc 7c 21 ba 81 e0 6e 3c b7 0e 47 04 cc 4c 55 3b 3b 12 e4 13 43 ee 90 a6 e6 e1 ae c3 88 ea 5d 65 29 4a 5a 16 39 97 78 70 3c ed 13 3e} (length 0x50)
// }
// }
// USB_REQ_GET_INTERFACE: nil
// USB_REQ_GET_CONFIGURATION: nil
// audio_UAC_GET_CUR: nil
// audio_UAC_GET_MIN: nil
// audio_UAC_GET_MAX: nil
// audio_UAC_GET_RES: nil
// audio_UAC_GET_MEM: nil
// }
// }
// ]
*(uint32_t*)0x80000680 = 0x44;
*(uint32_t*)0x80000684 = 0x80000340;
*(uint8_t*)0x80000340 = 0x40;
*(uint8_t*)0x80000341 = 0xc;
*(uint32_t*)0x80000342 = 0x50;
memcpy((void*)0x80000346, "... [truncated large byte array] ...", 80);
*(uint32_t*)0x80000688 = 0;
*(uint32_t*)0x8000068c = 0;
*(uint32_t*)0x80000690 = 0;
*(uint32_t*)0x80000694 = 0;
*(uint32_t*)0x80000698 = 0;
*(uint32_t*)0x8000069c = 0;
*(uint32_t*)0x800006a0 = 0;
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0x80000680);
return 0;
}
Reply: **Analysis of the Bug**
The bug report indicates a `WARN_ON` triggered in `drm_property_add_enum` due to `strlen(name) >= DRM_PROP_NAME_LEN`.
1. **Root Cause**:
The `gud` (Generic USB Display) driver queries the USB device for TV mode names during probe (`gud_connector_add_tv_mode`). It allocates a buffer using `kmalloc` and reads the mode names directly from the USB device via a control transfer (`gud_usb_get`). The driver assumes the data returned by the USB device is properly null-terminated or at least contains null bytes within the expected boundaries.
The driver then passes these strings to `drm_mode_create_tv_properties_legacy`, which in turn calls `drm_property_add_enum`. `drm_property_add_enum` calls `strlen(name)` on the provided string. If a malicious USB device returns a buffer completely devoid of null bytes, `strlen` will read past the end of the `kmalloc` allocated buffer, resulting in an out-of-bounds (OOB) read.
2. **Exploitability (Information Leak)**:
If the OOB read by `strlen` encounters a null byte within the adjacent heap memory (specifically within the next 15 bytes, such that `strlen(name) < DRM_PROP_NAME_LEN`), the `WARN_ON` is bypassed. The code then proceeds to call `strscpy_pad`, which copies the out-of-bounds heap data into the `prop_enum->name` field.
Crucially, `drm_mode_create_tv_properties_legacy` ignores the return value of `drm_property_add_enum`. This means the USB device probe will successfully complete, and the DRM device will be registered. A local attacker can then use the `DRM_IOCTL_MODE_GETPROPERTY` ioctl to read the property enums, effectively leaking up to 15 bytes of adjacent kernel heap memory to userspace. This information leak can be used to bypass KASLR or leak sensitive pointers, making the bug **Exploitable**.
3. **Denial of Service (DoS)**:
If the `kmalloc` buffer happens to be allocated at the very end of a page, and the subsequent page is unmapped, the `strlen` call will attempt to read from unmapped memory. This will cause a page fault in kernel space, leading to a kernel oops/panic and crashing the system. Thus, it can be used for **Denial of Service**.
4. **Trigger Mechanism**:
The vulnerability is located in the USB device probe path of the `gud` driver. It requires the kernel to process a malicious USB device descriptor and control transfer responses. Therefore, it can be triggered by physically plugging in a malicious USB device (**Peripheral Trigger**). It cannot be triggered over the network, via a filesystem, or by an unprivileged user process (unless the user has physical access to plug in the device, or root privileges to emulate one via `dummy_hcd`/`raw-gadget`).
|
| 6/2 |
2026/09/17 02:19 |
llm |
expert |
0m
Model:
Tokens:
input: 21903
output: 42
thoughts: 576
Thoughts: **Analyzing a Kernel Bug Report**
Okay, so I've got a kernel bug report here. The gist seems to be a mismatch in USB endpoint descriptor counts, which is interesting, but I need to focus on the actual issue. The report also highlights a warning: `strlen(name) >= DRM_PROP_NAME_LEN` within `drm_property_add_enum`. That's where things are getting my attention. It's a `WARNING` and mentions an issue in `drivers/gpu/drm/drm_property.c` at line 396.
The backtrace in the report seems to show the problem emanating from the DRM side, specifically the `gud` driver, which is part of the `drm` subsystem. It appears the flow of execution is:
1. `drm_property_add_enum` gets called.
2. That function is being called from inside `drm_mode_create_tv_properties_legacy`.
3. That eventually branches out through functions called `gud_connector_add_tv_mode`, `gud_connector_add_properties`, `gud_connector_create`, `gud_get_connectors`, and finally, `gud_probe`.
4. From `gud_probe`, the calls go to the `usb_probe_interface` function.
So, it's a `gud` driver issue that is related to `usb_probe_interface`. It means there is a problem somewhere in the USB device's configuration that is triggering a buffer overflow warning inside the DRM property handling. My initial thought is a string length problem, as the warning suggests. I need to dive deeper into the `drm_property_add_enum` function and how it interacts with the `gud` driver to understand how a potentially malformed name string could cause a warning. Then, I need to understand what's calling `gud_probe` and how that's getting a potentially bad name value.
|
| 7/2 |
2026/09/17 02:19 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/gpu/drm/drm_property.c Name:drm_property_add_enum]
Results: map[SourceCode: 376: /**
377: * drm_property_add_enum - add a possible value to an enumeration property
378: * @property: enumeration property to change
379: * @value: value of the new enumeration
380: * @name: symbolic name of the new enumeration
381: *
382: * This functions adds enumerations to a property.
383: *
384: * It's use is deprecated, drivers should use one of the more specific helpers
385: * to directly create the property with all enumerations already attached.
386: *
387: * Returns:
388: * Zero on success, error code on failure.
389: */
390: int drm_property_add_enum(struct drm_property *property,
391: uint64_t value, const char *name)
392: {
393: struct drm_property_enum *prop_enum;
394: int index = 0;
395:
396: if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
397: return -EINVAL;
398:
399: if (WARN_ON(!drm_property_type_is(property, DRM_MODE_PROP_ENUM) &&
400: !drm_property_type_is(property, DRM_MODE_PROP_BITMASK)))
401: return -EINVAL;
402:
403: /*
404: * Bitmask enum properties have the additional constraint of values
405: * from 0 to 63
406: */
407: if (WARN_ON(drm_property_type_is(property, DRM_MODE_PROP_BITMASK) &&
408: value > 63))
409: return -EINVAL;
410:
411: list_for_each_entry(prop_enum, &property->enum_list, head) {
412: if (WARN_ON(prop_enum->value == value))
413: return -EINVAL;
414: index++;
415: }
416:
417: if (WARN_ON(index >= property->num_values))
418: return -EINVAL;
419:
420: prop_enum = kzalloc_obj(struct drm_property_enum);
421: if (!prop_enum)
422: return -ENOMEM;
423:
424: strscpy_pad(prop_enum->name, name, DRM_PROP_NAME_LEN);
425: prop_enum->value = value;
426:
427: property->values[index] = value;
428: list_add_tail(&prop_enum->head, &property->enum_list);
429: return 0;
430: }
SourceFile:drivers/gpu/drm/drm_property.c]
|
| 8/2 |
2026/09/17 02:19 |
llm |
expert |
0m
Model:
Tokens:
input: 23802
output: 49
thoughts: 81
Thoughts: **Analyzing the Error Handling**
Okay, so I'm looking at this warning: `WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN)`. Right, that's a length check on the property name. If the length exceeds a certain maximum, it throws this warning and, crucially, returns `-EINVAL`. That means it *is* handled; the code anticipates this potential problem. It's not just a silent failure. Good. Now, let's drill down and see how it's *being* handled. I need to understand the implications of `-EINVAL`. I'm going to jump into `drivers/gpu/drm/gud/gud_connector.c:402` and take a look at `gud_connector_add_tv_mode`. That seems like the logical next step. I'm guessing this function is where the error code would be received and dealt with. Let's see how it uses the value.
|
| 9/2 |
2026/09/17 02:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/gpu/drm/gud/gud_connector.c Name:gud_connector_add_tv_mode]
Results: map[SourceCode: 372: /*
373: * The tv.mode property is shared among the connectors and its enum names are
374: * driver specific. This means that if more than one connector uses tv.mode,
375: * the enum names has to be the same.
376: */
377: static int gud_connector_add_tv_mode(struct gud_device *gdrm, struct drm_connector *connector)
378: {
379: size_t buf_len = GUD_CONNECTOR_TV_MODE_MAX_NUM * GUD_CONNECTOR_TV_MODE_NAME_LEN;
380: const char *modes[GUD_CONNECTOR_TV_MODE_MAX_NUM];
381: unsigned int i, num_modes;
382: char *buf;
383: int ret;
384:
385: buf = kmalloc(buf_len, GFP_KERNEL);
386: if (!buf)
387: return -ENOMEM;
388:
389: ret = gud_usb_get(gdrm, GUD_REQ_GET_CONNECTOR_TV_MODE_VALUES,
390: connector->index, buf, buf_len);
391: if (ret < 0)
392: goto free;
393: if (!ret || ret % GUD_CONNECTOR_TV_MODE_NAME_LEN) {
394: ret = -EIO;
395: goto free;
396: }
397:
398: num_modes = ret / GUD_CONNECTOR_TV_MODE_NAME_LEN;
399: for (i = 0; i < num_modes; i++)
400: modes[i] = &buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN];
401:
402: ret = drm_mode_create_tv_properties_legacy(connector->dev, num_modes, modes);
403: free:
404: kfree(buf);
405: if (ret < 0)
406: gud_conn_err(connector, "Failed to add TV modes", ret);
407:
408: return ret;
409: }
SourceFile:drivers/gpu/drm/gud/gud_connector.c]
|
| 10/2 |
2026/09/17 02:20 |
llm |
expert |
0m
Model:
Tokens:
input: 24807
output: 46
thoughts: 121
Thoughts: **Analyzing the TV Mode Configuration Process**
Okay, so I'm diving into this `gud_connector_add_tv_mode` function. It seems pretty straightforward on the surface, pulling TV mode values directly from the USB device, using `gud_usb_get` to handle the data transfer. `gud_usb_get` pulls a buffer, which is standard. The interesting bit is how this buffer is parsed. It's being chopped up into chunks β defined by `GUD_CONNECTOR_TV_MODE_NAME_LEN` β and each chunk is referenced by a `modes[i]` pointer. This likely represents each available TV mode as a string or a name.
The next step is the real meat of the process: calling `drm_mode_create_tv_properties_legacy`. This is where the magic happens, or at least, where the modes get converted into something the Direct Rendering Manager (DRM) understands. Given that this is labeled a "legacy" function, I need to check its implementation to understand how these string representations of modes are translated into usable DRM properties. My immediate focus is going to be on how `modes` is interpreted within `drm_mode_create_tv_properties_legacy` as that's where any potential discrepancies or inefficiencies are likely to be found. Let's dig in and see what's what.
|
| 11/2 |
2026/09/17 02:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/gpu/drm/drm_connector.c Name:drm_mode_create_tv_properties_legacy]
Results: map[SourceCode:2152: /**
2153: * drm_mode_create_tv_properties_legacy - create TV specific connector properties
2154: * @dev: DRM device
2155: * @num_modes: number of different TV formats (modes) supported
2156: * @modes: array of pointers to strings containing name of each format
2157: *
2158: * Called by a driver's TV initialization routine, this function creates
2159: * the TV specific connector properties for a given device. Caller is
2160: * responsible for allocating a list of format names and passing them to
2161: * this routine.
2162: *
2163: * NOTE: This functions registers the deprecated "mode" connector
2164: * property to select the analog TV mode (ie, NTSC, PAL, etc.). New
2165: * drivers must use drm_mode_create_tv_properties() instead.
2166: *
2167: * Returns:
2168: * 0 on success or a negative error code on failure.
2169: */
2170: int drm_mode_create_tv_properties_legacy(struct drm_device *dev,
2171: unsigned int num_modes,
2172: const char * const modes[])
2173: {
2174: struct drm_property *tv_selector;
2175: struct drm_property *tv_subconnector;
2176: unsigned int i;
2177:
2178: if (dev->mode_config.tv_select_subconnector_property)
2179: return 0;
2180:
2181: /*
2182: * Basic connector properties
2183: */
2184: tv_selector = drm_property_create_enum(dev, 0,
2185: "select subconnector",
2186: drm_tv_select_enum_list,
2187: ARRAY_SIZE(drm_tv_select_enum_list));
2188: if (!tv_selector)
2189: goto nomem;
2190:
2191: dev->mode_config.tv_select_subconnector_property = tv_selector;
2192:
2193: tv_subconnector =
2194: drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
2195: "subconnector",
2196: drm_tv_subconnector_enum_list,
2197: ARRAY_SIZE(drm_tv_subconnector_enum_list));
2198: if (!tv_subconnector)
2199: goto nomem;
2200: dev->mode_config.tv_subconnector_property = tv_subconnector;
2201:
2202: /*
2203: * Other, TV specific properties: margins & TV modes.
2204: */
2205: if (drm_mode_create_tv_margin_properties(dev))
2206: goto nomem;
2207:
2208: if (num_modes) {
2209: dev->mode_config.legacy_tv_mode_property =
2210: drm_property_create(dev, DRM_MODE_PROP_ENUM,
2211: "mode", num_modes);
2212: if (!dev->mode_config.legacy_tv_mode_property)
2213: goto nomem;
2214:
2215: for (i = 0; i < num_modes; i++)
2216: drm_property_add_enum(dev->mode_config.legacy_tv_mode_property,
2217: i, modes[i]);
2218: }
2219:
2220: dev->mode_config.tv_brightness_property =
2221: drm_property_create_range(dev, 0, "brightness", 0, 100);
2222: if (!dev->mode_config.tv_brightness_property)
2223: goto nomem;
2224:
2225: dev->mode_config.tv_contrast_property =
2226: drm_property_create_range(dev, 0, "contrast", 0, 100);
2227: if (!dev->mode_config.tv_contrast_property)
2228: goto nomem;
2229:
2230: dev->mode_config.tv_flicker_reduction_property =
2231: drm_property_create_range(dev, 0, "flicker reduction", 0, 100);
2232: if (!dev->mode_config.tv_flicker_reduction_property)
2233: goto nomem;
2234:
2235: dev->mode_config.tv_overscan_property =
2236: drm_property_create_range(dev, 0, "overscan", 0, 100);
2237: if (!dev->mode_config.tv_overscan_property)
2238: goto nomem;
2239:
2240: dev->mode_config.tv_saturation_property =
2241: drm_property_create_range(dev, 0, "saturation", 0, 100);
2242: if (!dev->mode_config.tv_saturation_property)
2243: goto nomem;
2244:
2245: dev->mode_config.tv_hue_property =
2246: drm_property_create_range(dev, 0, "hue", 0, 100);
2247: if (!dev->mode_config.tv_hue_property)
2248: goto nomem;
2249:
2250: return 0;
2251: nomem:
2252: return -ENOMEM;
2253: }
SourceFile:drivers/gpu/drm/drm_connector.c]
|
| 12/2 |
2026/09/17 02:20 |
llm |
expert |
0m
Model:
Tokens:
input: 26921
output: 29
thoughts: 197
Thoughts: **Analyzing a Potential Buffer Overflow**
Okay, so I'm looking at this `WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN)` call, and my initial thought is, "Hmm, this seems like it could be a problem." Specifically, this is in `gud_connector_add_tv_mode`, and the core of the issue is that the string `name` isn't *guaranteed* to be null-terminated. We're pulling data into `buf` from a USB device, and then `modes[i]` points to `&buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN]`.
The kicker is this: if the data from the USB device *doesn't* include a null byte within the first `DRM_PROP_NAME_LEN` bytes, `strlen` is going to read *past* that boundary. My first instinct was that it would stop at that length, but, no, `strlen` will search for a null byte, which could read *way* out of bounds of `buf`. That's a classic buffer overflow scenario.
I need to confirm the relationship between `GUD_CONNECTOR_TV_MODE_NAME_LEN` and `DRM_PROP_NAME_LEN` to see if this is an issue.
|
| 13/2 |
2026/09/17 02:20 |
tool |
grepper |
0m
Args: map[Expression:#define GUD_CONNECTOR_TV_MODE_NAME_LEN]
Results: map[Output:include/drm/gud.h=174=struct gud_state_req {
--
include/drm/gud.h-283-#define GUD_REQ_GET_CONNECTOR_TV_MODE_VALUES 0x52
include/drm/gud.h:284: #define GUD_CONNECTOR_TV_MODE_NAME_LEN 16
include/drm/gud.h-285- #define GUD_CONNECTOR_TV_MODE_MAX_NUM 16
]
|
| 14/2 |
2026/09/17 02:20 |
llm |
expert |
0m
Model:
Tokens:
input: 27566
output: 23
thoughts: 20
Thoughts: Here's my take on those thoughts, from an expert's perspective:
**Thinking About TV Mode Name Length**
Okay, so I'm looking at this constant, `GUD_CONNECTOR_TV_MODE_NAME_LEN`, and the value assigned is 16. That immediately gets me thinking about the implications. Sixteen characters⦠that's likely the maximum length allowed for a descriptive name string used to represent a TV display mode in some sort of GUI or configuration setting. I need to keep in mind, right away, the trade-offs involved in that limitation.
Is this length enough to be meaningful? Is it long enough to fully and accurately describe various resolution/refresh rate combinations, or color depth configurations? Can we realistically handle abbreviations or truncations? What are the potential consequences of exceeding this limit? Will there be data corruption, truncation errors displayed to the user, or will this impact underlying code? And, will we need to consider localization? Different languages have different word lengths, so perhaps we must include character type considerations.
I'm also wondering *why* this specific value was chosen. Is it based on memory constraints, display limitations in the interface, or some other factor? What are the underlying hardware limitations? This isn't just a number; it is a critical design decision in the context of the user experience and the overall system design. I immediately need to check where it's defined and *why*.
|
| 15/2 |
2026/09/17 02:20 |
tool |
grepper |
0m
Args: map[Expression:#define DRM_PROP_NAME_LEN]
Results: map[Output:include/uapi/drm/drm_mode.h=19=extern "C" {
--
include/uapi/drm/drm_mode.h-32-#define DRM_DISPLAY_MODE_LEN 32
include/uapi/drm/drm_mode.h:33:#define DRM_PROP_NAME_LEN 32
include/uapi/drm/drm_mode.h-34-
]
|
| 16/2 |
2026/09/17 02:20 |
llm |
expert |
0m
Model:
Tokens:
input: 28016
output: 45
thoughts: 343
Thoughts: **My Analysis of a Potential Out-of-Bounds Read**
Okay, let's break this down. `DRM_PROP_NAME_LEN` is defined as 32. This means that when `strlen(name)` is called, it's reading from `modes[i]`. The warning is triggered if the string isn't null-terminated within those 32 bytes. Now, I see that `buf` is allocated as `GUD_CONNECTOR_TV_MODE_MAX_NUM * GUD_CONNECTOR_TV_MODE_NAME_LEN`, which comes out to 16 * 16 = 256 bytes. My concern immediately zeroes in on the possibility of a buffer overflow.
If the USB device, for whatever reason, sends 256 bytes of data *without* including a null terminator, `strlen` is going to happily read up to 256 bytes. That's a problem because 256 is obviously greater than 32, and this triggers the warning, but then it hits me. Is this merely a warning or does this actually represent an out-of-bounds read? Yes, it could very well be an out-of-bounds read!
If the entire 256-byte buffer is devoid of null bytes, `strlen` will read past the end of the `buf` allocation. Remember, `buf` is allocated with `kmalloc(buf_len, GFP_KERNEL)`, and `buf_len` is 256. So, `strlen` is going to march right past that 256-byte boundary.
But wait a minute, `strlen` is actually operating on `name`, which is `modes[i]`. So, if `modes[i]` is not null-terminated, `strlen` will keep reading until it finds one. And because `buf` is allocated with `kmalloc`, the memory may not be null-terminated by default. This makes me consider if `gud_usb_get` is setting up the buffer with a null termination. Let me check the source code to confirm.
|
| 17/2 |
2026/09/17 02:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/gpu/drm/gud/gud_connector.c Name:gud_usb_get]
Results: map[SourceCode: 192: /*
193: * @buf cannot be allocated on the stack.
194: * Returns number of bytes received or negative error code on failure.
195: */
196: int gud_usb_get(struct gud_device *gdrm, u8 request, u16 index, void *buf, size_t max_len)
197: {
198: return gud_usb_transfer(gdrm, true, request, index, buf, max_len);
199: }
SourceFile:drivers/gpu/drm/gud/gud_drv.c]
|
| 18/2 |
2026/09/17 02:20 |
llm |
expert |
0m
Model:
Tokens:
input: 29030
output: 45
thoughts: 12
Thoughts: Okay, let's dive into this. Here's my thought process on checking `gud_usb_transfer`, rendered in the first person:
**Analyzing `gud_usb_transfer`**
Alright, time to focus. First up, I need to take a look at `gud_usb_transfer`. Immediately, my expert brain starts whirring β what's the context? What's it likely *supposed* to do? Is this related to a specific project, a general debugging task, or some broader performance analysis? I'm already formulating a mental checklist: data throughput, potential bottlenecks, error handling, is it implemented efficiently?
The name itself, "gud_usb_transfer," suggests it's a critical piece of USB communication. I'm assuming that "gud" is an abbreviation or an intentionally generic name β maybe "good," maybe something else, which Iβll need to figure out. Iβll be looking for comments or the surrounding code to understand the precise functionality, but the core of it indicates transferring data, which is an important process.
I need to quickly assess the code's quality, looking for the telltale signs of USB transfers. The approach can vary wildly from hardware manufacturer to hardware manufacturer and project to project, so what are the key methods being used? Are we using synchronous or asynchronous transfers? Are there DMA operations involved? What buffers are being used and are they optimized in size for the devices we have? The USB is only as good as the weakest link in the communication, so Iβll be watching out for those weak points.
I'm ready to dig in and understand this thing, and I'll keep the context of my expertise in mind to rapidly triage what's going on. Let's see what's in there...
|
| 19/2 |
2026/09/17 02:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/gpu/drm/gud/gud_drv.c Name:gud_usb_transfer]
Results: map[SourceCode: 153: static int gud_usb_transfer(struct gud_device *gdrm, bool in, u8 request, u16 index,
154: void *buf, size_t len)
155: {
156: struct usb_interface *intf = to_usb_interface(gdrm->drm.dev);
157: int idx, ret;
158:
159: drm_dbg(&gdrm->drm, "%s: request=0x%x index=%u len=%zu\n",
160: in ? "get" : "set", request, index, len);
161:
162: if (!drm_dev_enter(&gdrm->drm, &idx))
163: return -ENODEV;
164:
165: mutex_lock(&gdrm->ctrl_lock);
166:
167: ret = gud_usb_control_msg(intf, in, request, index, buf, len);
168: if (ret == -EPIPE || ((gdrm->flags & GUD_DISPLAY_FLAG_STATUS_ON_SET) && !in && ret >= 0)) {
169: int status;
170:
171: status = gud_usb_get_status(intf);
172: if (status < 0) {
173: ret = status;
174: } else if (ret < 0) {
175: dev_err_once(gdrm->drm.dev,
176: "Unexpected status OK for failed transfer\n");
177: ret = -EPIPE;
178: }
179: }
180:
181: if (ret < 0) {
182: drm_dbg(&gdrm->drm, "ret=%d\n", ret);
183: gdrm->stats_num_errors++;
184: }
185:
186: mutex_unlock(&gdrm->ctrl_lock);
187: drm_dev_exit(idx);
188:
189: return ret;
190: }
SourceFile:drivers/gpu/drm/gud/gud_drv.c]
|
| 20/2 |
2026/09/17 02:20 |
llm |
expert |
0m
Model:
Tokens:
input: 30100
output: 25
thoughts: 701
Thoughts: **Analyzing a Potential Out-of-Bounds Read in USB Handling**
Okay, let's break this down. `gud_usb_control_msg` is essentially a wrapper for `usb_control_msg`. It seems straightforward enough. So the device provides data, which gets stuffed into `buf`. The critical thing is that if the USB device doesn't provide a null terminator, `buf` won't be null-terminated. This sets up the problem.
Now, `gud_connector_add_tv_mode` calls `drm_mode_create_tv_properties_legacy`, which calls `drm_property_add_enum`, which, in turn, calls `strlen(name)`. Here's where the fun begins. If `buf` isn't null-terminated, `strlen` could read out of bounds. The bug report is a *warning* β `strlen(name) >= DRM_PROP_NAME_LEN`, and that triggers when `strlen` hits 32 or more. Now, given that `GUD_CONNECTOR_TV_MODE_NAME_LEN` is 16, if the USB device fails to send a null byte within the first 16 bytes, `strlen` will keep reading into the *next* 16-byte chunk. And if that one also lacks a null byte, we hit the 32 byte warning. If the *entire* 256-byte `buf` is null-free, we've got a proper out-of-bounds read!
But wait. `strlen` doesn't leak data, as it just computes the length. It doesn't copy the string into user space, which is what I initially thought. So, no immediate information leak. But... here's the kicker. If `strlen(name) < DRM_PROP_NAME_LEN`, it then proceeds to use `strscpy_pad(prop_enum->name, name, DRM_PROP_NAME_LEN);`. If `name` *is* not null-terminated within the *first* 16 bytes, but *is* null-terminated before the 32-byte boundary, `strlen(name)` will return a value between 16 and 31. Then, `strscpy_pad` comes into play. It will happily copy up to 31 bytes from the USB-provided `name` into `prop_enum->name`. This means, and this is where it gets interesting, that we're now copying bytes from that second chunk in `buf` into `prop_enum->name`. But the second chunk is *also* controlled by the USB device, so it's only copying device-provided data.
And this leads to one final point. What if the non-null-terminated `name` is right at the end of `buf`, at `buf + 240`? Then `strlen` will read into adjacent heap memory! However, if it finds a null byte within 31 bytes (15 bytes past `buf`'s end) `strlen` will be < 32 and `strscpy_pad` will copy up to 31 bytes from `buf` including up to 15 bytes of heap memory, which is then copied to `prop_enum->name`.
Here's the problem: `prop_enum->name` gets exposed to userspace through DRM properties! Therefore, an out-of-bounds read from the heap *will* now leak information to user space.
I need to confirm if `prop_enum->name` is indeed exposed to userspace.
|
| 21/2 |
2026/09/17 02:20 |
tool |
codesearch-find-references |
0m
Args: map[Name:drm_property_enum::name]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:drm_mode_getproperty_ioctl SourceFile:drivers/gpu/drm/drm_property.c SourceLine:506] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:drm_property_add_enum SourceFile:drivers/gpu/drm/drm_property.c SourceLine:424]] TruncatedOutput:false]
|
| 22/2 |
2026/09/17 02:20 |
llm |
expert |
0m
Model:
Tokens:
input: 31730
output: 43
thoughts: 14
Thoughts: Here's a summary of my thought process, as if I were analyzing that function:
**Diving into `drm_mode_getproperty_ioctl`**
Alright, let's take a look at `drm_mode_getproperty_ioctl`. This is the function that gets called when a userspace application, via an ioctl, requests information about a specific property attached to a connector, encoder, or CRTC within the Direct Rendering Manager (DRM) subsystem. Essentially, this is how userspace finds out the characteristics of a display setting or capability. I know this is a core building block for userspace display configuration. I need to understand exactly what information it's extracting and how. I will need to check how it handles any errors, especially around invalid input or access permissions. Is this function going to be a bottleneck? Let's check how many properties are available for various DRM devices. I'll need to check how this integrates with the larger picture.
|
| 23/2 |
2026/09/17 02:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/gpu/drm/drm_property.c Name:drm_mode_getproperty_ioctl]
Results: map[SourceCode: 458: int drm_mode_getproperty_ioctl(struct drm_device *dev,
459: void *data, struct drm_file *file_priv)
460: {
461: struct drm_mode_get_property *out_resp = data;
462: struct drm_property *property;
463: int enum_count = 0;
464: int value_count = 0;
465: int i, copied;
466: struct drm_property_enum *prop_enum;
467: struct drm_mode_property_enum __user *enum_ptr;
468: uint64_t __user *values_ptr;
469:
470: if (!drm_core_check_feature(dev, DRIVER_MODESET))
471: return -EOPNOTSUPP;
472:
473: property = drm_property_find(dev, file_priv, out_resp->prop_id);
474: if (!property)
475: return -ENOENT;
476:
477: strscpy_pad(out_resp->name, property->name, DRM_PROP_NAME_LEN);
478: out_resp->flags = property->flags;
479:
480: value_count = property->num_values;
481: values_ptr = u64_to_user_ptr(out_resp->values_ptr);
482:
483: for (i = 0; i < value_count; i++) {
484: if (i < out_resp->count_values &&
485: put_user(property->values[i], values_ptr + i)) {
486: return -EFAULT;
487: }
488: }
489: out_resp->count_values = value_count;
490:
491: copied = 0;
492: enum_ptr = u64_to_user_ptr(out_resp->enum_blob_ptr);
493:
494: if (drm_property_type_is(property, DRM_MODE_PROP_ENUM) ||
495: drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) {
496: list_for_each_entry(prop_enum, &property->enum_list, head) {
497: enum_count++;
498: if (out_resp->count_enum_blobs < enum_count)
499: continue;
500:
501: if (copy_to_user(&enum_ptr[copied].value,
502: &prop_enum->value, sizeof(uint64_t)))
503: return -EFAULT;
504:
505: if (copy_to_user(&enum_ptr[copied].name,
506: &prop_enum->name, DRM_PROP_NAME_LEN))
507: return -EFAULT;
508: copied++;
509: }
510: out_resp->count_enum_blobs = enum_count;
511: }
512:
513: /*
514: * NOTE: The idea seems to have been to use this to read all the blob
515: * property values. But nothing ever added them to the corresponding
516: * list, userspace always used the special-purpose get_blob ioctl to
517: * read the value for a blob property. It also doesn't make a lot of
518: * sense to return values here when everything else is just metadata for
519: * the property itself.
520: */
521: if (drm_property_type_is(property, DRM_MODE_PROP_BLOB))
522: out_resp->count_enum_blobs = 0;
523:
524: return 0;
525: }
SourceFile:drivers/gpu/drm/drm_property.c]
|
| 24/2 |
2026/09/17 02:20 |
llm |
expert |
0m
Model:
Tokens:
input: 33132
output: 34
thoughts: 887
Thoughts: **Vulnerability Discovered: Heap Memory Leak in DRM Property Enumeration**
Okay, so here's what I've figured out. We've got a potential heap memory leak when handling DRM property enumerations. My train of thought is as follows: it looks like `prop_enum->name` gets copied to userspace via `copy_to_user()`. If `strscpy_pad()` ends up copying out-of-bounds heap data into `prop_enum->name`, that data will be leaked to user space. Time to prove this.
Let's look at `gud_connector_add_tv_mode`. We allocate a buffer, `buf`, using `kmalloc` with a size derived from `GUD_CONNECTOR_TV_MODE_MAX_NUM` and `GUD_CONNECTOR_TV_MODE_NAME_LEN`. Then, `gud_usb_get()` populates this buffer, reading data from the USB device. Now, here's where it gets interesting.
Imagine the USB device returns a full buffer of 256 bytes, and critically, the *last* 16 bytes of that buffer (the last mode name) *doesn't* contain a null byte. That means `strlen` called inside `drm_property_add_enum`, will read beyond the bounds of that `buf` into the adjacent heap memory to find the null terminator. It's likely `strlen` will find the null byte within the following 15 bytes.
This `strlen` value is less than `DRM_PROP_NAME_LEN` (which is 32), so the `WARN_ON` check is bypassed. Then `strscpy_pad` is called. It will copy the 16 bytes from the non-null terminated mode name (from the original `buf`) *plus* the bytes from the adjacent heap memory *up to the null byte*. This leaked heap data ends up in `prop_enum->name`.
Later, a userspace process can call `DRM_IOCTL_MODE_GETPROPERTY` to retrieve these property enums. This in turn calls `copy_to_user`, leaking the extra heap memory that `strscpy_pad` copied.
To be clear, itβs not *just* leaking a few bytes from the buffer; itβs specifically the *adjacent* heap memory thatβs the issue. If I understand correctly, this means the kernel is exposing potentially sensitive heap data to a user-space process. We should check the `strscpy_pad` implementation. That's the key to confirming the leak, right?
|
| 25/2 |
2026/09/17 02:21 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:lib/string.c Name:strscpy_pad]
Results: map[SourceCode: SourceFile:]
|
| 26/2 |
2026/09/17 02:21 |
llm |
expert |
0m
Model:
Tokens:
input: 34633
output: 19
thoughts: 21
Thoughts: Here's my thinking process:
**Diving into the String Library for `strscpy_pad`**
Okay, so I need to refresh my memory on `strscpy_pad`. That function sounds like it's a kernel-specific string copy with some padding behavior. My instinct is to head straight to the source, so I'm thinking, let's just jump into the kernel headers. Specifically, I know that string functions are typically defined in `include/linux/string.h`. That's the logical place to start. I want to check the declaration, usage, and any comments there might be about its intended behavior, especially concerning that "pad" element. Time to pull that file up and get a closer look.
|
| 27/2 |
2026/09/17 02:21 |
tool |
grepper |
0m
Args: map[Expression:strscpy_pad]
Results: map[Output:
Full output is too long, showing 500 out of 924 lines.
Use more precise expression if possible.
Documentation/networking/packet_mmap.rst=136=As capture, each frame contains two parts::
--
Documentation/networking/packet_mmap.rst-155-
Documentation/networking/packet_mmap.rst:156: strscpy_pad (s_ifr.ifr_name, "eth0", sizeof(s_ifr.ifr_name));
Documentation/networking/packet_mmap.rst-157-
--
Documentation/networking/tuntap.rst=87=Note that the character pointer becomes overwritten with the real device name
--
Documentation/networking/tuntap.rst-109- if( *dev )
Documentation/networking/tuntap.rst:110: strscpy_pad(ifr.ifr_name, dev, IFNAMSIZ);
Documentation/networking/tuntap.rst-111-
--
Documentation/process/deprecated.rst=146=The replacements for strncpy() are:
--
Documentation/process/deprecated.rst-148-- strscpy() when the destination must be NUL-terminated.
Documentation/process/deprecated.rst:149:- strscpy_pad() when the destination must be NUL-terminated and
Documentation/process/deprecated.rst-150- zero-padded (e.g., structs crossing privilege boundaries).
--
Documentation/translations/it_IT/process/deprecated.rst=157=troncata). Tutti i casi che necessitano di estendere la
Documentation/translations/it_IT/process/deprecated.rst:158:terminazione con NUL dovrebbero usare strscpy_pad().
Documentation/translations/it_IT/process/deprecated.rst-159-
--
Documentation/translations/sp_SP/process/deprecated.rst=158=la cadena de caracteres). Cualquier caso restante que necesitase todavΓa
Documentation/translations/sp_SP/process/deprecated.rst:159:ser terminado en el caracter nulo, deberΓa usar strscpy_pad().
Documentation/translations/sp_SP/process/deprecated.rst-160-
--
arch/mips/cavium-octeon/octeon-platform.c=483=static void __init octeon_fdt_set_phy(int eth, int phy_addr)
--
arch/mips/cavium-octeon/octeon-platform.c-541- fdt_nop_property(initial_boot_params, phy, "marvell,reg-init");
arch/mips/cavium-octeon/octeon-platform.c:542: strscpy_pad(new_name, "marvell,88e1145");
arch/mips/cavium-octeon/octeon-platform.c-543- p = fdt_getprop(initial_boot_params, phy, "compatible",
--
arch/mips/loongson64/boardinfo.c=6=static ssize_t boardinfo_show(struct kobject *kobj,
--
arch/mips/loongson64/boardinfo.c-13-
arch/mips/loongson64/boardinfo.c:14: strscpy_pad(board_manufacturer, eboard->name);
arch/mips/loongson64/boardinfo.c:15: strscpy_pad(bios_vendor, einter->description);
arch/mips/loongson64/boardinfo.c-16-
--
arch/powerpc/kernel/fadump.c=1461=static ssize_t bootargs_append_store(struct kobject *kobj,
--
arch/powerpc/kernel/fadump.c-1482- params = __va(fw_dump.param_area);
arch/powerpc/kernel/fadump.c:1483: strscpy_pad(params, buf, COMMAND_LINE_SIZE);
arch/powerpc/kernel/fadump.c-1484- /* Remove newline character at the end. */
--
arch/powerpc/kernel/prom_init.c=228=static int __init prom_strcmp(const char *cs, const char *ct)
--
arch/powerpc/kernel/prom_init.c-242-
arch/powerpc/kernel/prom_init.c:243:static ssize_t __init prom_strscpy_pad(char *dest, const char *src, size_t n)
arch/powerpc/kernel/prom_init.c-244-{
--
arch/powerpc/kernel/prom_init.c=1340=static void __init prom_check_platform_support(void)
--
arch/powerpc/kernel/prom_init.c-1359-
arch/powerpc/kernel/prom_init.c:1360: prom_strscpy_pad(ibm_architecture_vec.vec7.os_id, linux_banner, 256);
arch/powerpc/kernel/prom_init.c-1361-
--
arch/powerpc/kernel/prom_init.c=2701=static void __init flatten_device_tree(void)
--
arch/powerpc/kernel/prom_init.c-2742- namep = make_room(&mem_start, &mem_end, 16, 1);
arch/powerpc/kernel/prom_init.c:2743: prom_strscpy_pad(namep, "phandle", sizeof("phandle"));
arch/powerpc/kernel/prom_init.c-2744- mem_start = (unsigned long)namep + prom_strlen(namep) + 1;
--
block/partitions/ldm.c=126=static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
--
block/partitions/ldm.c-133- }
block/partitions/ldm.c:134: strscpy_pad(toc->bitmap1_name, data + 0x24, sizeof(toc->bitmap1_name));
block/partitions/ldm.c-135- toc->bitmap1_start = get_unaligned_be64(data + 0x2E);
--
block/partitions/ldm.c-143- }
block/partitions/ldm.c:144: strscpy_pad(toc->bitmap2_name, data + 0x46, sizeof(toc->bitmap2_name));
block/partitions/ldm.c-145- toc->bitmap2_start = get_unaligned_be64(data + 0x50);
--
drivers/accel/habanalabs/gaudi/gaudi.c=535=static int gaudi_set_fixed_properties(struct hl_device *hdev)
--
drivers/accel/habanalabs/gaudi/gaudi.c-664-
drivers/accel/habanalabs/gaudi/gaudi.c:665: strscpy_pad(prop->cpucp_info.card_name, GAUDI_DEFAULT_CARD_NAME,
drivers/accel/habanalabs/gaudi/gaudi.c-666- CARD_NAME_MAX_LEN);
--
drivers/accel/habanalabs/gaudi/gaudi.c=7999=static int gaudi_cpucp_info_get(struct hl_device *hdev)
--
drivers/accel/habanalabs/gaudi/gaudi.c-8014- if (!strlen(prop->cpucp_info.card_name))
drivers/accel/habanalabs/gaudi/gaudi.c:8015: strscpy_pad(prop->cpucp_info.card_name, GAUDI_DEFAULT_CARD_NAME,
drivers/accel/habanalabs/gaudi/gaudi.c-8016- CARD_NAME_MAX_LEN);
--
drivers/accel/habanalabs/gaudi2/gaudi2.c=2757=static int gaudi2_set_fixed_properties(struct hl_device *hdev)
--
drivers/accel/habanalabs/gaudi2/gaudi2.c-2920-
drivers/accel/habanalabs/gaudi2/gaudi2.c:2921: strscpy_pad(prop->cpucp_info.card_name, GAUDI2_DEFAULT_CARD_NAME, CARD_NAME_MAX_LEN);
drivers/accel/habanalabs/gaudi2/gaudi2.c-2922-
--
drivers/accel/habanalabs/gaudi2/gaudi2.c=3341=static int gaudi2_cpucp_info_get(struct hl_device *hdev)
--
drivers/accel/habanalabs/gaudi2/gaudi2.c-3379- if (!strlen(prop->cpucp_info.card_name))
drivers/accel/habanalabs/gaudi2/gaudi2.c:3380: strscpy_pad(prop->cpucp_info.card_name, GAUDI2_DEFAULT_CARD_NAME,
drivers/accel/habanalabs/gaudi2/gaudi2.c-3381- CARD_NAME_MAX_LEN);
--
drivers/accel/habanalabs/goya/goya.c=360=int goya_set_fixed_properties(struct hl_device *hdev)
--
drivers/accel/habanalabs/goya/goya.c-465-
drivers/accel/habanalabs/goya/goya.c:466: strscpy_pad(prop->cpucp_info.card_name, GOYA_DEFAULT_CARD_NAME,
drivers/accel/habanalabs/goya/goya.c-467- CARD_NAME_MAX_LEN);
--
drivers/accel/habanalabs/goya/goya.c=5082=int goya_cpucp_info_get(struct hl_device *hdev)
--
drivers/accel/habanalabs/goya/goya.c-5112- if (!strlen(prop->cpucp_info.card_name))
drivers/accel/habanalabs/goya/goya.c:5113: strscpy_pad(prop->cpucp_info.card_name, GOYA_DEFAULT_CARD_NAME,
drivers/accel/habanalabs/goya/goya.c-5114- CARD_NAME_MAX_LEN);
--
drivers/bluetooth/btintel_pcie.c=2752=static int btintel_pcie_hci_drv_read_info(struct hci_dev *hdev, void *data,
--
drivers/bluetooth/btintel_pcie.c-2766-
drivers/bluetooth/btintel_pcie.c:2767: strscpy_pad(rp->driver_name, KBUILD_MODNAME);
drivers/bluetooth/btintel_pcie.c-2768-
--
drivers/bluetooth/btusb.c=3962=static int btusb_hci_drv_read_info(struct hci_dev *hdev, void *data,
--
drivers/bluetooth/btusb.c-3976-
drivers/bluetooth/btusb.c:3977: strscpy_pad(rp->driver_name, btusb_driver.name);
drivers/bluetooth/btusb.c-3978-
--
drivers/bus/fsl-mc/dprc.c=420=int dprc_get_obj(struct fsl_mc_io *mc_io,
--
drivers/bus/fsl-mc/dprc.c-452- obj_desc->flags = le16_to_cpu(rsp_params->flags);
drivers/bus/fsl-mc/dprc.c:453: strscpy_pad(obj_desc->type, rsp_params->type, 16);
drivers/bus/fsl-mc/dprc.c:454: strscpy_pad(obj_desc->label, rsp_params->label, 16);
drivers/bus/fsl-mc/dprc.c-455- return 0;
--
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c=1315=static ssize_t ucode_load_store(struct device *dev,
--
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c-1328-
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c:1329: if (strscpy_pad(tmp_buf, buf) < 0)
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c-1330- return -EINVAL;
--
drivers/dma/idxd/defaults.c=6=int idxd_load_iaa_device_defaults(struct idxd_device *idxd)
--
drivers/dma/idxd/defaults.c-38- /* set name to "iaa_crypto" */
drivers/dma/idxd/defaults.c:39: strscpy_pad(wq->name, "iaa_crypto");
drivers/dma/idxd/defaults.c-40-
drivers/dma/idxd/defaults.c-41- /* set driver_name to "crypto" */
drivers/dma/idxd/defaults.c:42: strscpy_pad(wq->driver_name, "crypto");
drivers/dma/idxd/defaults.c-43-
--
drivers/firmware/tegra/bpmp-debugfs.c=584=static int debugfs_show(struct seq_file *m, void *p)
--
drivers/firmware/tegra/bpmp-debugfs.c-614- len = strlen(filename);
drivers/firmware/tegra/bpmp-debugfs.c:615: strscpy_pad(namevirt, filename, namesize);
drivers/firmware/tegra/bpmp-debugfs.c-616-
--
drivers/firmware/tegra/bpmp-debugfs.c=635=static ssize_t debugfs_store(struct file *file, const char __user *buf,
--
drivers/firmware/tegra/bpmp-debugfs.c-665- len = strlen(filename);
drivers/firmware/tegra/bpmp-debugfs.c:666: strscpy_pad(namevirt, filename, namesize);
drivers/firmware/tegra/bpmp-debugfs.c-667-
--
drivers/gpu/drm/drm_modes.c=2582=void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
--
drivers/gpu/drm/drm_modes.c-2621-
drivers/gpu/drm/drm_modes.c:2622: strscpy_pad(out->name, in->name, sizeof(out->name));
drivers/gpu/drm/drm_modes.c-2623-}
--
drivers/gpu/drm/drm_modes.c=2637=int drm_mode_convert_umode(struct drm_device *dev,
--
drivers/gpu/drm/drm_modes.c-2662- out->type = in->type & DRM_MODE_TYPE_ALL;
drivers/gpu/drm/drm_modes.c:2663: strscpy_pad(out->name, in->name, sizeof(out->name));
drivers/gpu/drm/drm_modes.c-2664-
--
drivers/gpu/drm/drm_property.c=97=struct drm_property *drm_property_create(struct drm_device *dev,
--
drivers/gpu/drm/drm_property.c-130-
drivers/gpu/drm/drm_property.c:131: strscpy_pad(property->name, name, DRM_PROP_NAME_LEN);
drivers/gpu/drm/drm_property.c-132-
--
drivers/gpu/drm/drm_property.c=390=int drm_property_add_enum(struct drm_property *property,
--
drivers/gpu/drm/drm_property.c-423-
drivers/gpu/drm/drm_property.c:424: strscpy_pad(prop_enum->name, name, DRM_PROP_NAME_LEN);
drivers/gpu/drm/drm_property.c-425- prop_enum->value = value;
--
drivers/gpu/drm/drm_property.c=458=int drm_mode_getproperty_ioctl(struct drm_device *dev,
--
drivers/gpu/drm/drm_property.c-476-
drivers/gpu/drm/drm_property.c:477: strscpy_pad(out_resp->name, property->name, DRM_PROP_NAME_LEN);
drivers/gpu/drm/drm_property.c-478- out_resp->flags = property->flags;
--
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c=503=int etnaviv_pm_query_dom(struct etnaviv_gpu *gpu,
--
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c-517- domain->nr_signals = dom->nr_signals;
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c:518: strscpy_pad(domain->name, dom->name, sizeof(domain->name));
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c-519-
--
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c=527=int etnaviv_pm_query_sig(struct etnaviv_gpu *gpu,
--
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c-546- signal->id = signal->iter;
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c:547: strscpy_pad(signal->name, sig->name, sizeof(signal->name));
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c-548-
--
drivers/gpu/drm/nouveau/nvif/client.c=52=nvif_client_ctor(struct nvif_client *parent, const char *name, struct nvif_client *client)
--
drivers/gpu/drm/nouveau/nvif/client.c-56-
drivers/gpu/drm/nouveau/nvif/client.c:57: strscpy_pad(args.name, name, sizeof(args.name));
drivers/gpu/drm/nouveau/nvif/client.c-58- ret = nvif_object_ctor(parent != client ? &parent->object : NULL,
--
drivers/hwmon/macsmc-hwmon.c=467=static int macsmc_hwmon_create_sensor(struct device *dev, struct apple_smc *smc,
--
drivers/hwmon/macsmc-hwmon.c-487- else
drivers/hwmon/macsmc-hwmon.c:488: strscpy_pad(sensor->label, label, sizeof(sensor->label));
drivers/hwmon/macsmc-hwmon.c-489-
--
drivers/hwmon/macsmc-hwmon.c=500=static int macsmc_hwmon_create_fan(struct device *dev, struct apple_smc *smc,
--
drivers/hwmon/macsmc-hwmon.c-522- } else {
drivers/hwmon/macsmc-hwmon.c:523: strscpy_pad(fan->label, label, sizeof(fan->label));
drivers/hwmon/macsmc-hwmon.c-524- fan->attrs |= HWMON_F_LABEL;
--
drivers/infiniband/core/sa_query.c=760=static void ib_nl_set_path_rec_attrs(struct sk_buff *skb,
--
drivers/infiniband/core/sa_query.c-773- header = skb_put(skb, NLMSG_ALIGN(sizeof(*header)));
drivers/infiniband/core/sa_query.c:774: strscpy_pad(header->device_name,
drivers/infiniband/core/sa_query.c-775- dev_name(&query->port->agent->device->dev),
--
drivers/infiniband/hw/hfi1/chip.c=5325=static char *is_misc_err_name(char *buf, size_t bsize, unsigned int source)
--
drivers/infiniband/hw/hfi1/chip.c-5327- if (source < ARRAY_SIZE(cce_misc_names))
drivers/infiniband/hw/hfi1/chip.c:5328: strscpy_pad(buf, cce_misc_names[source], bsize);
drivers/infiniband/hw/hfi1/chip.c-5329- else
--
drivers/infiniband/hw/hfi1/chip.c=5365=static char *is_various_name(char *buf, size_t bsize, unsigned int source)
--
drivers/infiniband/hw/hfi1/chip.c-5367- if (source < ARRAY_SIZE(various_names))
drivers/infiniband/hw/hfi1/chip.c:5368: strscpy_pad(buf, various_names[source], bsize);
drivers/infiniband/hw/hfi1/chip.c-5369- else
--
drivers/infiniband/hw/irdma/i40iw_if.c=185=static int i40iw_probe(struct auxiliary_device *aux_dev, const struct auxiliary_device_id *id)
--
drivers/infiniband/hw/irdma/i40iw_if.c-191-
drivers/infiniband/hw/irdma/i40iw_if.c:192: strscpy_pad(i40iw_client.name, "irdma", I40E_CLIENT_STR_LENGTH);
drivers/infiniband/hw/irdma/i40iw_if.c-193- i40e_client_device_register(cdev_info, &i40iw_client);
--
drivers/md/dm-ioctl.c=1406=static void retrieve_status(struct dm_table *table,
--
drivers/md/dm-ioctl.c-1441- spec->length = ti->len;
drivers/md/dm-ioctl.c:1442: strscpy_pad(spec->target_type, ti->type->name,
drivers/md/dm-ioctl.c-1443- sizeof(spec->target_type));
--
drivers/message/fusion/mptctl.c=1226=mptctl_getiocinfo (MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
--
drivers/message/fusion/mptctl.c-1330- */
drivers/message/fusion/mptctl.c:1331: strscpy_pad(karg->driverVersion, MPT_LINUX_PACKAGE_NAME,
drivers/message/fusion/mptctl.c-1332- sizeof(karg->driverVersion));
--
drivers/message/fusion/mptctl.c=1473=mptctl_readtest (MPT_ADAPTER *ioc, unsigned long arg)
--
drivers/message/fusion/mptctl.c-1495-#endif
drivers/message/fusion/mptctl.c:1496: strscpy_pad(karg.name, ioc->name, sizeof(karg.name));
drivers/message/fusion/mptctl.c:1497: strscpy_pad(karg.product, ioc->prod_name, sizeof(karg.product));
drivers/message/fusion/mptctl.c-1498-
--
drivers/message/fusion/mptctl.c=2320=mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
--
drivers/message/fusion/mptctl.c-2394-
drivers/message/fusion/mptctl.c:2395: strscpy_pad(karg.serial_number, " ", sizeof(karg.serial_number));
drivers/message/fusion/mptctl.c-2396- if (mpt_config(ioc, &cfg) == 0) {
--
drivers/message/fusion/mptctl.c-2408- if (strlen(pdata->BoardTracerNumber) > 1) {
drivers/message/fusion/mptctl.c:2409: strscpy_pad(karg.serial_number,
drivers/message/fusion/mptctl.c-2410- pdata->BoardTracerNumber,
--
drivers/net/bonding/bond_main.c=6093=static int __init bond_check_params(struct bond_params *params)
--
drivers/net/bonding/bond_main.c-6473- if (primary)
drivers/net/bonding/bond_main.c:6474: strscpy_pad(params->primary, primary, sizeof(params->primary));
drivers/net/bonding/bond_main.c-6475-
--
drivers/net/bonding/bond_options.c=1520=static int bond_option_primary_set(struct bonding *bond,
--
drivers/net/bonding/bond_options.c-1556- }
drivers/net/bonding/bond_options.c:1557: strscpy_pad(bond->params.primary, primary, IFNAMSIZ);
drivers/net/bonding/bond_options.c-1558-
--
drivers/net/ethernet/8390/ne.c=1047=static int netdev_boot_setup_add(char *name, struct ifmap *map)
--
drivers/net/ethernet/8390/ne.c-1054- if (s[i].name[0] == '\0' || s[i].name[0] == ' ') {
drivers/net/ethernet/8390/ne.c:1055: strscpy_pad(s[i].name, name);
drivers/net/ethernet/8390/ne.c-1056- memcpy(&s[i].map, map, sizeof(s[i].map));
--
drivers/net/ethernet/brocade/bna/bfa_ioc.c=2840=bfa_ioc_get_adapter_manufacturer(struct bfa_ioc *ioc, char *manufacturer)
drivers/net/ethernet/brocade/bna/bfa_ioc.c-2841-{
drivers/net/ethernet/brocade/bna/bfa_ioc.c:2842: strscpy_pad(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN);
drivers/net/ethernet/brocade/bna/bfa_ioc.c-2843-}
--
drivers/net/ethernet/cavium/liquidio/lio_main.c=1677=static int load_firmware(struct octeon_device *oct)
--
drivers/net/ethernet/cavium/liquidio/lio_main.c-1685- tmp_fw_type = LIO_FW_NAME_TYPE_NIC;
drivers/net/ethernet/cavium/liquidio/lio_main.c:1686: strscpy_pad(fw_type, tmp_fw_type, sizeof(fw_type));
drivers/net/ethernet/cavium/liquidio/lio_main.c-1687- } else {
--
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c=598=static void mlx5_fw_tracer_save_trace(struct mlx5_fw_tracer *tracer,
--
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c-608- trace_data->event_id = event_id;
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c:609: strscpy_pad(trace_data->msg, msg, TRACE_STR_MSG);
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c-610-
--
drivers/net/pse-pd/pd692x0.c=1599=static enum fw_upload_err pd692x0_fw_write(struct fw_upload *fwl,
--
drivers/net/pse-pd/pd692x0.c-1686-err:
drivers/net/pse-pd/pd692x0.c:1687: strscpy_pad(line, "S7\r\n", sizeof(line));
drivers/net/pse-pd/pd692x0.c-1688- pd692x0_fw_write_line(client, line, true);
--
drivers/net/wireless/intel/ipw2x00/ipw2200.c=9658=static int ipw_wx_get_wireless_mode(struct net_device *dev,
--
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9665- case IEEE_A:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:9666: strscpy_pad(extra, "802.11a (1)", MAX_WX_STRING);
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9667- break;
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9668- case IEEE_B:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:9669: strscpy_pad(extra, "802.11b (2)", MAX_WX_STRING);
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9670- break;
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9671- case IEEE_A | IEEE_B:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:9672: strscpy_pad(extra, "802.11ab (3)", MAX_WX_STRING);
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9673- break;
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9674- case IEEE_G:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:9675: strscpy_pad(extra, "802.11g (4)", MAX_WX_STRING);
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9676- break;
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9677- case IEEE_A | IEEE_G:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:9678: strscpy_pad(extra, "802.11ag (5)", MAX_WX_STRING);
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9679- break;
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9680- case IEEE_B | IEEE_G:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:9681: strscpy_pad(extra, "802.11bg (6)", MAX_WX_STRING);
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9682- break;
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9683- case IEEE_A | IEEE_B | IEEE_G:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:9684: strscpy_pad(extra, "802.11abg (7)", MAX_WX_STRING);
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9685- break;
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9686- default:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:9687: strscpy_pad(extra, "unknown", MAX_WX_STRING);
drivers/net/wireless/intel/ipw2x00/ipw2200.c-9688- break;
--
drivers/net/wireless/intel/iwlwifi/fw/dbg-old.c=732=iwl_fw_error_dump_file(struct iwl_fw_runtime *fwrt,
--
drivers/net/wireless/intel/iwlwifi/fw/dbg-old.c-845- sizeof(dump_info->fw_human_readable));
drivers/net/wireless/intel/iwlwifi/fw/dbg-old.c:846: strscpy_pad(dump_info->dev_human_readable,
drivers/net/wireless/intel/iwlwifi/fw/dbg-old.c-847- fwrt->trans->info.name,
drivers/net/wireless/intel/iwlwifi/fw/dbg-old.c-848- sizeof(dump_info->dev_human_readable));
drivers/net/wireless/intel/iwlwifi/fw/dbg-old.c:849: strscpy_pad(dump_info->bus_human_readable, fwrt->dev->bus->name,
drivers/net/wireless/intel/iwlwifi/fw/dbg-old.c-850- sizeof(dump_info->bus_human_readable));
--
drivers/nvme/target/trace.h=55=static inline void __assign_req_name(char *name, struct nvmet_req *req)
--
drivers/nvme/target/trace.h-61-
drivers/nvme/target/trace.h:62: strscpy_pad(name, req->ns->device_path, DISK_NAME_LEN);
drivers/nvme/target/trace.h-63-}
--
drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c=931=static int create_component(struct vchiq_mmal_instance *instance,
--
drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c-942- m.u.component_create.client_component = component->client_component;
drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c:943: strscpy_pad(m.u.component_create.name, name,
drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c-944- sizeof(m.u.component_create.name));
--
drivers/rpmsg/qcom_glink_native.c=1398=static void qcom_glink_remove_rpmsg_device(struct qcom_glink *glink, struct glink_channel *channel)
--
drivers/rpmsg/qcom_glink_native.c-1402- if (channel->rpdev) {
drivers/rpmsg/qcom_glink_native.c:1403: strscpy_pad(chinfo.name, channel->name, sizeof(chinfo.name));
drivers/rpmsg/qcom_glink_native.c-1404- chinfo.src = RPMSG_ADDR_ANY;
--
drivers/rpmsg/qcom_smd.c=1274=static void qcom_channel_state_worker(struct work_struct *work)
--
drivers/rpmsg/qcom_smd.c-1327-
drivers/rpmsg/qcom_smd.c:1328: strscpy_pad(chinfo.name, channel->name, sizeof(chinfo.name));
drivers/rpmsg/qcom_smd.c-1329- chinfo.src = RPMSG_ADDR_ANY;
--
drivers/rpmsg/rpmsg_core.c=522=int rpmsg_register_device_override(struct rpmsg_device *rpdev,
--
drivers/rpmsg/rpmsg_core.c-528- if (driver_override)
drivers/rpmsg/rpmsg_core.c:529: strscpy_pad(rpdev->id.name, driver_override, RPMSG_NAME_SIZE);
drivers/rpmsg/rpmsg_core.c-530-
--
drivers/rpmsg/rpmsg_ns.c=31=static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,
--
drivers/rpmsg/rpmsg_ns.c-52-
drivers/rpmsg/rpmsg_ns.c:53: strscpy_pad(chinfo.name, msg->name, sizeof(chinfo.name));
drivers/rpmsg/rpmsg_ns.c-54- chinfo.src = RPMSG_ADDR_ANY;
--
drivers/rpmsg/virtio_rpmsg_bus.c=316=static int virtio_rpmsg_announce_create(struct rpmsg_device *rpdev)
--
drivers/rpmsg/virtio_rpmsg_bus.c-327-
drivers/rpmsg/virtio_rpmsg_bus.c:328: strscpy_pad(nsm.name, rpdev->id.name, sizeof(nsm.name));
drivers/rpmsg/virtio_rpmsg_bus.c-329- nsm.addr = cpu_to_rpmsg32(rpdev, rpdev->ept->addr);
--
drivers/rpmsg/virtio_rpmsg_bus.c=340=static int virtio_rpmsg_announce_destroy(struct rpmsg_device *rpdev)
--
drivers/rpmsg/virtio_rpmsg_bus.c-351-
drivers/rpmsg/virtio_rpmsg_bus.c:352: strscpy_pad(nsm.name, rpdev->id.name, sizeof(nsm.name));
drivers/rpmsg/virtio_rpmsg_bus.c-353- nsm.addr = cpu_to_rpmsg32(rpdev, rpdev->ept->addr);
--
drivers/scsi/elx/libefc/efc_node.h=23=efc_node_evt_set(struct efc_sm_ctx *ctx, enum efc_sm_event evt,
--
drivers/scsi/elx/libefc/efc_node.h-28- if (evt == EFC_EVT_ENTER) {
drivers/scsi/elx/libefc/efc_node.h:29: strscpy_pad(node->current_state_name, handler,
drivers/scsi/elx/libefc/efc_node.h-30- sizeof(node->current_state_name));
--
drivers/scsi/elx/libefc/efc_node.h-33- sizeof(node->prev_state_name));
drivers/scsi/elx/libefc/efc_node.h:34: strscpy_pad(node->current_state_name, "invalid",
drivers/scsi/elx/libefc/efc_node.h-35- sizeof(node->current_state_name));
--
drivers/scsi/fnic/fdls_disc.c=1834=static void fdls_fdmi_register_hba(struct fnic_iport_s *iport)
--
drivers/scsi/fnic/fdls_disc.c-1901-
drivers/scsi/fnic/fdls_disc.c:1902: strscpy_pad(data, FNIC_FDMI_MANUFACTURER, FNIC_FDMI_MANU_LEN);
drivers/scsi/fnic/fdls_disc.c-1903- fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_MANUFACTURER,
--
drivers/scsi/fnic/fdls_disc.c-1910- if (!err) {
drivers/scsi/fnic/fdls_disc.c:1911: strscpy_pad(data, fw_info->hw_serial_number,
drivers/scsi/fnic/fdls_disc.c-1912- FNIC_FDMI_SERIAL_LEN);
--
drivers/scsi/fnic/fdls_disc.c-1921- fnic->subsys_desc_len = FNIC_FDMI_MODEL_LEN - 1;
drivers/scsi/fnic/fdls_disc.c:1922: strscpy_pad(data, fnic->subsys_desc, FNIC_FDMI_MODEL_LEN);
drivers/scsi/fnic/fdls_disc.c-1923- fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_MODEL, FNIC_FDMI_MODEL_LEN,
--
drivers/scsi/fnic/fdls_disc.c-1928-
drivers/scsi/fnic/fdls_disc.c:1929: strscpy_pad(data, FNIC_FDMI_MODEL_DESCRIPTION, FNIC_FDMI_MODEL_DES_LEN);
drivers/scsi/fnic/fdls_disc.c-1930- fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_MODEL_DES,
--
drivers/scsi/fnic/fdls_disc.c-1936- if (!err) {
drivers/scsi/fnic/fdls_disc.c:1937: strscpy_pad(data, fw_info->hw_version, FNIC_FDMI_HW_VER_LEN);
drivers/scsi/fnic/fdls_disc.c-1938- fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_HARDWARE_VERSION,
--
drivers/scsi/fnic/fdls_disc.c-1944-
drivers/scsi/fnic/fdls_disc.c:1945: strscpy_pad(data, DRV_VERSION, FNIC_FDMI_DR_VER_LEN);
drivers/scsi/fnic/fdls_disc.c-1946- fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_DRIVER_VERSION,
--
drivers/scsi/fnic/fdls_disc.c-1951-
drivers/scsi/fnic/fdls_disc.c:1952: strscpy_pad(data, "N/A", FNIC_FDMI_ROM_VER_LEN);
drivers/scsi/fnic/fdls_disc.c-1953- fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_ROM_VERSION,
--
drivers/scsi/fnic/fdls_disc.c-1959- if (!err) {
drivers/scsi/fnic/fdls_disc.c:1960: strscpy_pad(data, fw_info->fw_version, FNIC_FDMI_FW_VER_LEN);
drivers/scsi/fnic/fdls_disc.c-1961- fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_FIRMWARE_VERSION,
--
drivers/scsi/fnic/fdls_disc.c=1979=static void fdls_fdmi_register_pa(struct fnic_iport_s *iport)
--
drivers/scsi/fnic/fdls_disc.c-2083- fnic->host->host_no);
drivers/scsi/fnic/fdls_disc.c:2084: strscpy_pad(data, tmp_data, FNIC_FDMI_OS_NAME_LEN);
drivers/scsi/fnic/fdls_disc.c-2085- fnic_fdmi_attr_set(fdmi_attr, FNIC_FDMI_TYPE_OS_NAME,
--
drivers/scsi/fnic/fdls_disc.c-2091- sprintf(fc_host_system_hostname(fnic->host), "%s", utsname()->nodename);
drivers/scsi/fnic/fdls_disc.c:2092: strscpy_pad(data, fc_host_system_hostname(fnic->host),
drivers/scsi/fnic/fdls_disc.c-2093- FNIC_FDMI_HN_LEN);
--
drivers/scsi/hpsa.c=7226=static void init_driver_version(char *driver_version, int len)
drivers/scsi/hpsa.c-7227-{
drivers/scsi/hpsa.c:7228: strscpy_pad(driver_version, HPSA " " HPSA_DRIVER_VERSION, len);
drivers/scsi/hpsa.c-7229-}
--
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c=1501=static long ibmvscsis_adapter_info(struct scsi_info *vscsi,
--
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c-1561- /* Copy our info */
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:1562: strscpy_pad(info->srp_version, SRP_VERSION,
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c-1563- sizeof(info->srp_version));
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:1564: strscpy_pad(info->partition_name, vscsi->dds.partition_name,
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c-1565- sizeof(info->partition_name));
--
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c=1613=static int ibmvscsis_cap_mad(struct scsi_info *vscsi, struct iu_entry *iue)
--
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c-1647- if (rc == H_SUCCESS) {
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:1648: strscpy_pad(cap->name, dev_name(&vscsi->dma_dev->dev),
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c-1649- sizeof(cap->name));
--
drivers/scsi/scsi_devinfo.c=285=static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length,
--
drivers/scsi/scsi_devinfo.c-296- if (compatible)
drivers/scsi/scsi_devinfo.c:297: strscpy_pad(to, from, to_length);
drivers/scsi/scsi_devinfo.c-298- else
--
drivers/staging/greybus/fw-management.c=107=static int fw_mgmt_interface_fw_version_operation(struct fw_mgmt *fw_mgmt,
--
drivers/staging/greybus/fw-management.c-125-
drivers/staging/greybus/fw-management.c:126: ret = strscpy_pad(fw_info->firmware_tag, response.firmware_tag);
drivers/staging/greybus/fw-management.c-127- if (ret == -E2BIG)
--
drivers/staging/greybus/fw-management.c=135=static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt,
--
drivers/staging/greybus/fw-management.c-149-
drivers/staging/greybus/fw-management.c:150: ret = strscpy_pad(request.firmware_tag, tag);
drivers/staging/greybus/fw-management.c-151- if (ret == -E2BIG) {
--
drivers/staging/greybus/fw-management.c=235=static int fw_mgmt_backend_fw_version_operation(struct fw_mgmt *fw_mgmt,
--
drivers/staging/greybus/fw-management.c-242-
drivers/staging/greybus/fw-management.c:243: ret = strscpy_pad(request.firmware_tag, fw_info->firmware_tag);
drivers/staging/greybus/fw-management.c-244- if (ret == -E2BIG) {
--
drivers/staging/greybus/fw-management.c=287=static int fw_mgmt_backend_fw_update_operation(struct fw_mgmt *fw_mgmt,
--
drivers/staging/greybus/fw-management.c-292-
drivers/staging/greybus/fw-management.c:293: ret = strscpy_pad(request.firmware_tag, tag);
drivers/staging/greybus/fw-management.c-294- if (ret == -E2BIG) {
--
drivers/video/fbdev/fsl-diu-fb.c=784=static void set_fix(struct fb_info *info)
--
drivers/video/fbdev/fsl-diu-fb.c-789-
drivers/video/fbdev/fsl-diu-fb.c:790: strscpy_pad(fix->id, mfbi->id);
]
|
| 28/2 |
2026/09/17 02:21 |
llm |
expert |
0m
Model:
Tokens:
input: 47678
output: 23
thoughts: 49
Thoughts: **Investigating the Definition of `strscpy_pad`**
Okay, so I need to track down where this `strscpy_pad` function is actually defined. My immediate instinct is to look in `include/linux/string.h` since it seems like a core string manipulation function. However, I also have to consider it could be implemented internally, so `lib/string.c` is the next logical place to check. It's a common pattern in the kernel to have corresponding `.h` and `.c` files for utility functions. Given the name, I'd bet it's probably within the library file. Let's start with `lib/string.c` β it's likely to be right there.
|
| 29/2 |
2026/09/17 02:21 |
tool |
grepper |
0m
Error:
Args: map[Expression:ssize_t strscpy_pad]
Results:
|
| 30/2 |
2026/09/17 02:21 |
llm |
expert |
0m
Model:
Tokens:
input: 47920
output: 32
thoughts: 21
Thoughts: **Checking the String Library**
Okay, time to dig into the kernel's string library. Specifically, I need to verify the implementation of `strscpy_pad`. I'll open up `include/linux/string.h` to see exactly how it's defined and how it's intended to be used. This is where the core logic will reside. I need to refresh my understanding of how it handles destination size, padding characters, and potential boundary conditions. A close look here will provide the details I need to evaluate its effectiveness or any potential edge cases that may be relevant to the current problem at hand.
|
| 31/2 |
2026/09/17 02:21 |
tool |
grepper |
0m
Args: map[Expression:strscpy_pad PathPrefix:include/linux/string.h]
Results: map[Output:include/linux/string.h=70=ssize_t sized_strscpy(char *, const char *, size_t);
--
include/linux/string.h-81-
include/linux/string.h:82:#define __strscpy_pad0(dst, src, ...) \
include/linux/string.h:83: sized_strscpy_pad(dst, src, sizeof(dst) + __must_be_array(dst) + \
include/linux/string.h-84- __must_be_cstr(dst) + __must_be_cstr(src))
include/linux/string.h:85:#define __strscpy_pad1(dst, src, size) \
include/linux/string.h:86: sized_strscpy_pad(dst, src, size + __must_be_cstr(dst) + __must_be_cstr(src))
include/linux/string.h-87-
--
include/linux/string.h-103- * doesn't unnecessarily force the tail of the destination buffer to be
include/linux/string.h:104: * zero padded. If padding is desired please use strscpy_pad().
include/linux/string.h-105- *
--
include/linux/string.h-112-
include/linux/string.h:113:#define sized_strscpy_pad(dest, src, count) ({ \
include/linux/string.h-114- char *__dst = (dest); \
--
include/linux/string.h-125-/**
include/linux/string.h:126: * strscpy_pad() - Copy a C-string into a sized buffer
include/linux/string.h-127- * @dst: Where to copy the string to
--
include/linux/string.h-144- */
include/linux/string.h:145:#define strscpy_pad(dst, src, ...) \
include/linux/string.h:146: CONCATENATE(__strscpy_pad, COUNT_ARGS(__VA_ARGS__))(dst, src, __VA_ARGS__)
include/linux/string.h-147-
]
|
| 32/2 |
2026/09/17 02:21 |
llm |
expert |
0m
Model:
Tokens:
input: 48660
output: 36
thoughts: 37
Thoughts: Okay, here's my interpretation of that thought process, from an expert's perspective:
**Diving into the `strscpy_pad` rabbit hole...**
Right, `strscpy_pad`. That's just a macro, so it's probably a convenience wrapper. I figured as much. The name hints it's likely dealing with string copying, and probably padding the target buffer somehow. Okay, let's see what's *actually* going on under the hood... it's calling `sized_strscpy_pad`. Time to investigate *that* function. I'm guessing that the "sized" part probably gives the developer more explicit control over the target buffer size, preventing potential buffer overflows, and managing the length and padding parameters. Now, let's see exactly how.
|
| 33/2 |
2026/09/17 02:21 |
tool |
grepper |
0m
Args: map[Expression:#define sized_strscpy_pad PathPrefix:include/linux/string.h]
Results: map[Output:include/linux/string.h=70=ssize_t sized_strscpy(char *, const char *, size_t);
--
include/linux/string.h-112-
include/linux/string.h:113:#define sized_strscpy_pad(dest, src, count) ({ \
include/linux/string.h-114- char *__dst = (dest); \
]
|
| 34/2 |
2026/09/17 02:21 |
llm |
expert |
0m
Model:
Tokens:
input: 49019
output: 35
thoughts: 16
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Analyzing the Function Definition**
Alright, the initial prompt is straightforward: let's dive right into the definition of `sized_strscpy_pad`. That immediately tells me this function is likely dealing with string manipulation, specifically a *copy* operation with some constraints β the "sized" aspect. The "pad" component is intriguing. I'm immediately curious about what this padding signifies. Is it zero-padding, space-padding, or something else entirely? The 'scpy' prefix suggests a "safe copy" function which is good. I need to understand the details to know how the function is implemented and if it addresses any common buffer overflow vulnerabilities. Knowing the details is crucial to assessing its utility and potential risks. Let's see how it works.
|
| 35/2 |
2026/09/17 02:21 |
tool |
read-file |
0m
Args: map[File:include/linux/string.h FirstLine:110 LineCount:20]
Results: map[Contents: 110: #define strscpy(dst, src, ...) \
111: CONCATENATE(__strscpy, COUNT_ARGS(__VA_ARGS__))(dst, src, __VA_ARGS__)
112:
113: #define sized_strscpy_pad(dest, src, count) ({ \
114: char *__dst = (dest); \
115: const char *__src = (src); \
116: const size_t __count = (count); \
117: ssize_t __wrote; \
118: \
119: __wrote = sized_strscpy(__dst, __src, __count); \
120: if (__wrote >= 0 && __wrote < __count) \
121: memset(__dst + __wrote + 1, 0, __count - __wrote - 1); \
122: __wrote; \
123: })
124:
125: /**
126: * strscpy_pad() - Copy a C-string into a sized buffer
127: * @dst: Where to copy the string to
128: * @src: Where to copy the string from
129: * @...: Size of destination buffer
]
|
| 36/2 |
2026/09/17 02:21 |
llm |
expert |
0m
Model:
Tokens:
input: 49620
output: 34
thoughts: 29
Thoughts: Here's my take on those thoughts:
**Analyzing `sized_strscpy_pad`'s Implementation**
Okay, so `sized_strscpy_pad` is basically a wrapper function. It's calling `sized_strscpy` underneath. That's a good starting point. Now, to understand *how* it's working, and what added functionality it offers, I need to dive into the core logic of `sized_strscpy`. Let's dig into `sized_strscpy` and see what's happening.
|
| 37/2 |
2026/09/17 02:21 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:lib/string.c Name:sized_strscpy]
Results: map[SourceCode: 98: ssize_t sized_strscpy(char *dest, const char *src, size_t count)
99: {
100: const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
101: size_t max = count;
102: long res = 0;
103:
104: if (count == 0 || WARN_ON_ONCE(count > INT_MAX))
105: return -E2BIG;
106:
107: #ifndef CONFIG_DCACHE_WORD_ACCESS
108: #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
109: /*
110: * If src is unaligned, don't cross a page boundary,
111: * since we don't know if the next page is mapped.
112: */
113: if ((long)src & (sizeof(long) - 1))
114: max = min(PAGE_SIZE - ((long)src & (PAGE_SIZE - 1)), max);
115: #else
116: /* If src or dest is unaligned, don't do word-at-a-time. */
117: if (((long) dest | (long) src) & (sizeof(long) - 1))
118: max = 0;
119: #endif
120: #endif
121:
122: /*
123: * load_unaligned_zeropad() or read_word_at_a_time() below may read
124: * uninitialized bytes after the trailing zero and use them in
125: * comparisons. Disable this optimization under KMSAN to prevent
126: * false positive reports.
127: */
128: if (IS_ENABLED(CONFIG_KMSAN))
129: max = 0;
130:
131: while (max >= sizeof(unsigned long)) {
132: unsigned long c, data;
133:
134: #ifdef CONFIG_DCACHE_WORD_ACCESS
135: c = load_unaligned_zeropad(src+res);
136: #else
137: c = read_word_at_a_time(src+res);
138: #endif
139: if (has_zero(c, &data, &constants)) {
140: data = prep_zero_mask(c, data, &constants);
141: data = create_zero_mask(data);
142: *(unsigned long *)(dest+res) = c & zero_bytemask(data);
143: return res + find_zero(data);
144: }
145: count -= sizeof(unsigned long);
146: if (unlikely(!count)) {
147: c &= ALLBUTLAST_BYTE_MASK;
148: *(unsigned long *)(dest+res) = c;
149: return -E2BIG;
150: }
151: *(unsigned long *)(dest+res) = c;
152: res += sizeof(unsigned long);
153: max -= sizeof(unsigned long);
154: }
155:
156: while (count > 1) {
157: char c;
158:
159: c = src[res];
160: dest[res] = c;
161: if (!c)
162: return res;
163: res++;
164: count--;
165: }
166:
167: /* Force NUL-termination. */
168: dest[res] = '\0';
169:
170: /* Return E2BIG if the source didn't stop */
171: return src[res] ? -E2BIG : res;
172: }
SourceFile:lib/string.c]
|
| 38/2 |
2026/09/17 02:21 |
llm |
expert |
0m
Model:
Tokens:
input: 50939
output: 47
thoughts: 1700
Thoughts: **Analyzing a Potential Kernel Information Leak**
Okay, here's the situation: I've got this `sized_strscpy` function, which, as the name suggests, copies at most a certain number of bytes. Specifically, I'm looking at `drm_property_add_enum`, where `strscpy_pad` is used, copying data to `prop_enum->name`, which has a size of 32 bytes (DRM_PROP_NAME_LEN). My initial thought was that this always copies up to 32 bytes from `name` to the destination. But wait, if `name` isn't null-terminated, `strlen(name)` could be anything. And there is a check! If `strlen(name)` is greater than or equal to 32, it returns an error and *doesn't* call `strscpy_pad`. That seems safe, right?
But, what if `strlen(name)` *is* less than 32, but the string goes past the allocated buffer? Like, say, if the valid string ends at index `255`, but the null byte is further down the line (maybe at index `260`). In that scenario, `strlen` would read past the allocated buffer. I realized this is a potential out-of-bounds read vulnerability. If `strlen` reads a null byte within range, the check will pass. Then `strscpy_pad` comes along and copies the data, potentially over-reading and leaking memory. This leaked data, if read back via `DRM_IOCTL_MODE_GETPROPERTY`, could leak information to userspace!
The `kmalloc` slab used by the program is `kmalloc-256`, meaning we are dealing with 256 byte allocations. That allocation size is important, because if a USB device returns exactly 256 bytes, and the null terminator occurs past the allocated buffer, `strlen` could read past the bounds of the allocated buffer. If a subsequent slab allocation contains a null byte, we have an out-of-bounds read and an information leak.
The bug report shows the warning message: `strlen(name) >= DRM_PROP_NAME_LEN`. It looked like the syzkaller reproducer didn't trigger an information leak because the next object in the slab didn't contain a null byte quickly enough. However, an attacker could specifically arrange the heap layout to trigger an out-of-bounds read that leaks at most 15 bytes of memory. Is 15 bytes useful? Yes, those 15 bytes could include pointers or other sensitive information, useful for defeating KASLR or aiding in exploit chains. This confirms it's an exploitable information leak.
So, the next question is, can an unprivileged user trigger this? It appears the vulnerability is in the USB device probe and is triggered when a USB device is plugged in via the `gud_probe` function. The code that's the source of the vulnerability is reached by a peripheral trigger. It's triggered when a USB device matching specific IDs is connected. The syzkaller reproducer uses `/dev/raw-gadget`, but this would require root privileges. However, anyone with physical access can plug in a malicious USB device. So, yes, it's a peripheral trigger.
Finally, are there any other ways to reach `drm_property_add_enum` with an untrusted string? The report specifically mentioned `gud_connector_add_tv_mode`. I need to review other related properties and callers to ensure there aren't other potential triggers for this information leak.
|
| 39/2 |
2026/09/17 02:21 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/gpu/drm/gud/gud_connector.c Name:gud_connector_add_properties]
Results: map[SourceCode: 474: static int gud_connector_add_properties(struct gud_device *gdrm, struct gud_connector *gconn)
475: {
476: struct drm_connector *connector = &gconn->connector;
477: struct drm_device *drm = &gdrm->drm;
478: struct gud_property_req *properties;
479: unsigned int i, num_properties;
480: int ret;
481:
482: properties = kzalloc_objs(*properties, GUD_CONNECTOR_PROPERTIES_MAX_NUM);
483: if (!properties)
484: return -ENOMEM;
485:
486: ret = gud_usb_get(gdrm, GUD_REQ_GET_CONNECTOR_PROPERTIES, connector->index,
487: properties, GUD_CONNECTOR_PROPERTIES_MAX_NUM * sizeof(*properties));
488: if (ret <= 0)
489: goto out;
490: if (ret % sizeof(*properties)) {
491: ret = -EIO;
492: goto out;
493: }
494:
495: num_properties = ret / sizeof(*properties);
496: ret = 0;
497:
498: gconn->properties = kcalloc(num_properties, sizeof(*gconn->properties), GFP_KERNEL);
499: if (!gconn->properties) {
500: ret = -ENOMEM;
501: goto out;
502: }
503:
504: for (i = 0; i < num_properties; i++) {
505: u16 prop = le16_to_cpu(properties[i].prop);
506: u64 val = le64_to_cpu(properties[i].val);
507: struct drm_property *property;
508: unsigned int *state_val;
509:
510: drm_dbg(drm, "property: %u = %llu(0x%llx)\n", prop, val, val);
511:
512: switch (prop) {
513: case GUD_PROPERTY_TV_LEFT_MARGIN:
514: fallthrough;
515: case GUD_PROPERTY_TV_RIGHT_MARGIN:
516: fallthrough;
517: case GUD_PROPERTY_TV_TOP_MARGIN:
518: fallthrough;
519: case GUD_PROPERTY_TV_BOTTOM_MARGIN:
520: ret = drm_mode_create_tv_margin_properties(drm);
521: if (ret)
522: goto out;
523: break;
524: case GUD_PROPERTY_TV_MODE:
525: ret = gud_connector_add_tv_mode(gdrm, connector);
526: if (ret)
527: goto out;
528: break;
529: case GUD_PROPERTY_TV_BRIGHTNESS:
530: fallthrough;
531: case GUD_PROPERTY_TV_CONTRAST:
532: fallthrough;
533: case GUD_PROPERTY_TV_FLICKER_REDUCTION:
534: fallthrough;
535: case GUD_PROPERTY_TV_OVERSCAN:
536: fallthrough;
537: case GUD_PROPERTY_TV_SATURATION:
538: fallthrough;
539: case GUD_PROPERTY_TV_HUE:
540: /* This is a no-op if already added. */
541: ret = drm_mode_create_tv_properties_legacy(drm, 0, NULL);
542: if (ret)
543: goto out;
544: break;
545: case GUD_PROPERTY_BACKLIGHT_BRIGHTNESS:
546: if (val > 100) {
547: ret = -EINVAL;
548: goto out;
549: }
550: gconn->initial_brightness = val;
551: break;
552: default:
553: /* New ones might show up in future devices, skip those we don't know. */
554: drm_dbg(drm, "Ignoring unknown property: %u\n", prop);
555: continue;
556: }
557:
558: gconn->properties[gconn->num_properties++] = prop;
559:
560: if (prop == GUD_PROPERTY_BACKLIGHT_BRIGHTNESS)
561: continue; /* not a DRM property */
562:
563: property = gud_connector_property_lookup(connector, prop);
564: if (drm_WARN_ON(drm, IS_ERR(property)))
565: continue;
566:
567: state_val = gud_connector_tv_state_val(prop, &gconn->initial_tv_state);
568: if (drm_WARN_ON(drm, IS_ERR(state_val)))
569: continue;
570:
571: *state_val = val;
572: drm_object_attach_property(&connector->base, property, 0);
573: }
574: out:
575: kfree(properties);
576:
577: return ret;
578: }
SourceFile:drivers/gpu/drm/gud/gud_connector.c]
|
| 40/2 |
2026/09/17 02:21 |
llm |
expert |
0m
Model:
Tokens:
input: 55057
output: 25
thoughts: 1294
Thoughts: **Exploiting the `gud_connector_add_tv_mode` Vulnerability**
Okay, so `gud_connector_add_tv_mode` is the key function here, it's the only one that appears to read strings from the USB device. Let's break down the exploitability of this issue.
First, we're looking at an out-of-bounds read, potentially leaking up to 15 bytes from a `kmalloc-256` slab. This data gets copied into `prop_enum->name`, a 32-byte buffer. This leaked data is accessible from userspace through `DRM_IOCTL_MODE_GETPROPERTY`. Thatβs an information leak, and information leaks are, by definition, considered exploitable.
The trigger is a physical event: plugging in a malicious USB device. That's our peripheral trigger.
Now, can this be triggered from a VM guest? Hmm... typically, a "VM Guest Trigger" is about the guest *triggering* a bug in the host. This bug is in the USB driver. Unless the guest has control over the host's USB controller (which isn't common), or if it can emulate a USB device (e.g., using `dummy_hcd`), the guest can't directly cause a USB device to plug in. So, the direct "VM Guest Trigger" should be considered False.
What about a "VM Host Trigger" in a confidential computing context? If the host presents a malicious *virtual* USB device to a confidential guest, the guest kernel will process it. Technically, the host *could* trigger the bug in the guest. However, USB isn't a *standard* paravirtualized feature for confidential VMs; they typically use virtio. So, Iβll mark "VM Host Trigger" as False, leaning towards the fact that USB is not a typical paravirtualized feature.
Now, accessibility. Can an *unprivileged* process trigger this? No. Plugging in a physical USB device requires either physical access or root privileges for a virtual device, so "Unprivileged" is False. What about user namespaces? Again, the tools needed (`raw-gadget`, `dummy_hcd`) aren't accessible from within a user namespace without elevated privileges. So, "UserNamespace" is also False.
Finally, Denial of Service. Initially, I thought that a `WARN_ON` might be the only result, not causing a crash. However, further analysis makes me reconsider. The `strlen` that performs the OOB read reads up to 15 bytes out of bounds, and the `kmalloc-256` allocation size and alignment makes a crash likely. Objects are 256 bytes in size and aligned. If the buffer is placed at the end of a page and the next page isn't mapped, the `strlen` will cause a page fault when trying to read beyond the allocation. This can definitely cause a kernel crash. After checking, kmalloc-256 objects can indeed be placed at the end of a page. Therefore, Denial of Service is absolutely True. This is a classic OOB read leading to a crash.
So to summarize the bug. It is an exploitable OOB read leading to a heap data leak and a possible crash.
|
| 41/2 |
2026/09/17 02:22 |
tool |
codesearch-find-references |
0m
Args: map[Name:drm_property_add_enum]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:drm_connector_attach_scaling_mode_property SourceFile:drivers/gpu/drm/drm_connector.c SourceLine:2461] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:drm_create_scaling_filter_prop SourceFile:drivers/gpu/drm/drm_plane.c SourceLine:1743] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:drm_mode_create_tv_properties_legacy SourceFile:drivers/gpu/drm/drm_connector.c SourceLine:2216] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:drm_plane_create_blend_mode_property SourceFile:drivers/gpu/drm/drm_blend.c SourceLine:623] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:drm_property_create_bitmask SourceFile:drivers/gpu/drm/drm_property.c SourceLine:229] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:drm_property_create_enum SourceFile:drivers/gpu/drm/drm_property.c SourceLine:177] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:intel_sdvo_tv_create_property SourceFile:drivers/gpu/drm/i915/display/intel_sdvo.c SourceLine:3107] map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:__UNIQUE_ID_addressable_drm_property_add_enum_920 SourceFile:drivers/gpu/drm/drm_property.c SourceLine:431] map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:__gendwarfksyms_ptr_drm_property_add_enum SourceFile:drivers/gpu/drm/drm_property.c SourceLine:431] map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:__gendwarfksyms_ptr_drm_property_add_enum SourceFile:drivers/gpu/drm/drm_property.c SourceLine:431]] TruncatedOutput:false]
|
| 42/2 |
2026/09/17 02:22 |
llm |
expert |
0m
Model:
Tokens:
input: 57721
output: 53
thoughts: 29
Thoughts: Here's my take:
**Investigating Property Creation in the SDVO TV Output**
Okay, so `intel_sdvo_tv_create_property` is the key function here. The code suggests it's responsible for creating properties specific to the SDVO (Serial Digital Video Output) TV output. Now, I see that this function *also* calls `drm_property_add_enum`. That's interesting, because `drm_property_add_enum` is the function we use to build up an enumerated property, essentially a list of allowed values. It's used for things like selecting resolutions or refresh rates, or even the type of the signal to be transmitted. So the connection is clear - `intel_sdvo_tv_create_property` is building some kind of enumerated property using `drm_property_add_enum`, likely specific to the TV capabilities of the SDVO output. My next step will be to verify what the enumerated values represent, so I can grasp exactly how the SDVO TV configuration happens.
|
| 43/2 |
2026/09/17 02:22 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/gpu/drm/i915/display/intel_sdvo.c Name:intel_sdvo_tv_create_property]
Results: map[SourceCode:3072: static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,
3073: struct intel_sdvo_connector *intel_sdvo_connector,
3074: int type)
3075: {
3076: struct intel_display *display = to_intel_display(&intel_sdvo->base);
3077: struct intel_sdvo_tv_format format;
3078: u32 format_map, i;
3079:
3080: if (!intel_sdvo_set_target_output(intel_sdvo, type))
3081: return false;
3082:
3083: BUILD_BUG_ON(sizeof(format) != 6);
3084: if (!intel_sdvo_get_value(intel_sdvo,
3085: SDVO_CMD_GET_SUPPORTED_TV_FORMATS,
3086: &format, sizeof(format)))
3087: return false;
3088:
3089: memcpy(&format_map, &format, min(sizeof(format_map), sizeof(format)));
3090:
3091: if (format_map == 0)
3092: return false;
3093:
3094: intel_sdvo_connector->format_supported_num = 0;
3095: for (i = 0 ; i < TV_FORMAT_NUM; i++)
3096: if (format_map & (1 << i))
3097: intel_sdvo_connector->tv_format_supported[intel_sdvo_connector->format_supported_num++] = i;
3098:
3099:
3100: intel_sdvo_connector->tv_format =
3101: drm_property_create(display->drm, DRM_MODE_PROP_ENUM,
3102: "mode", intel_sdvo_connector->format_supported_num);
3103: if (!intel_sdvo_connector->tv_format)
3104: return false;
3105:
3106: for (i = 0; i < intel_sdvo_connector->format_supported_num; i++)
3107: drm_property_add_enum(intel_sdvo_connector->tv_format, i,
3108: tv_format_names[intel_sdvo_connector->tv_format_supported[i]]);
3109:
3110: intel_sdvo_connector->base.base.state->tv.legacy_mode = intel_sdvo_connector->tv_format_supported[0];
3111: drm_object_attach_property(&intel_sdvo_connector->base.base.base,
3112: intel_sdvo_connector->tv_format, 0);
3113: return true;
3114:
3115: }
SourceFile:drivers/gpu/drm/i915/display/intel_sdvo.c]
|
| 44/2 |
2026/09/17 02:22 |
llm |
expert |
0m
Model:
Tokens:
input: 58844
output: 46
thoughts: 2577
Thoughts: **Vulnerability Analysis: Out-of-Bounds Read in GUD Driver (CVE)**
Alright, here's my understanding of this situation. The `intel_sdvo_tv_create_property` function itself looks safe, relying on a static string array. My main concern lies with `gud_connector_add_tv_mode`, specifically within the Generic USB Display (GUD) driver. This driver is, by its very nature, a USB driver, making it vulnerable to malicious USB devices β peripheral trigger confirmed.
I've made sure to exhaustively search for alternative trigger methods for `gud_probe`, which is the GUD driver's probe function. Since it's a USB driver, it's only triggered by USB devices.
Now, let's address the questions at hand:
* **Exploitable:** Absolutely. This is an out-of-bounds read that leaks heap data to user space and has the potential for a kernel crash.
* **Denial of Service:** Also true. The OOB read could hit an unmapped page, resulting in a kernel crash, which will lead to USB device DoS.
* **Privilege:** Not accessible from unprivileged processes because it requires physical access or root privileges to either use a dummy_hcd or raw-gadget, so it can be used only by users with physical access or root access.
* **User Namespace:** Inaccessible from user namespaces, also.
* **VM Guest/Host/Network/File Trigger:** All false.
* **Peripheral Trigger:** Confirmed: it's a USB driver, so a malicious USB device can trigger the vulnerability.
Now, I'm checking to make sure that an unprivileged user cannot trigger a USB device connection, which is not possible. It is a hardware event. The user must have either physical access or root access to have any effect.
I've checked to make sure `gud_usb_get` can return a non-null-terminated buffer. The `usb_control_msg` call inside is responsible for this transfer, which doesn't null-terminate the received data. If the USB device returns a buffer without null bytes, then the `buf` will be non-null-terminated, confirming my suspicion.
Let's dissect the OOB read. `kmalloc(256, GFP_KERNEL)` allocates the buffer. If the USB device returns 256 bytes, then `strlen` called on a pointer 240 bytes into that buffer could read up to 256 bytes out, which goes past the buffer's allocated space, triggering the OOB read.
I've also checked to ensure `kmalloc` indeed allocates exactly 256 bytes. It does, which means `buf[256]` reads the beginning of the next object in the slab. This is a classic OOB read.
Is there any data leakage? If the next object contains a null byte, the `strlen` function will return a length less than 32. Since 16 bytes of data can be taken from `buf` to be copied to `prop_enum->name`, this means that this is a valid data leak.
Could it crash? If the buffer is the last object in a page, then reading `buf[256]` goes to the next unmapped page, which results in a page fault and then kernel crash/panic. Killing the USB hub worker thread leads to DoS.
I've reviewed the syzkaller reproducer. I see that the `syz_usb_connect` system call can be used for USB device emulation. I can see the reproducer providing the device descriptor and responses for control transfers. The reproduced sends the value 0x52 as `GUD_REQ_GET_CONNECTOR_TV_MODE_VALUES`. It seems a bit messy, but it triggers the bug. The bug report shows the warning `strlen(name) >= DRM_PROP_NAME_LEN` was triggered.
It's clear that the reproducer triggers the OOB read, and it can read more than 16 bytes without encountering null bytes.
It seems that the impact is if the `strlen(name)` is >= 32, then `drm_property_add_enum` returns `-EINVAL`. The attacker can return 256 bytes from the USB device and cause a read of the next heap object. If the next object doesn't have a null byte in the first 15 bytes, then the first part (16 bytes) of this object gets copied to user space, so, repeated triggering of this vulnerability might leak different heap objects, leading to an information leak.
I also checked to see what happens if `drm_property_add_enum` returns `-EINVAL`. It looks like this return value is ignored
|
| 45/2 |
2026/09/17 02:22 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/gpu/drm/drm_connector.c Name:drm_mode_create_tv_properties_legacy]
Results: map[SourceCode:2152: /**
2153: * drm_mode_create_tv_properties_legacy - create TV specific connector properties
2154: * @dev: DRM device
2155: * @num_modes: number of different TV formats (modes) supported
2156: * @modes: array of pointers to strings containing name of each format
2157: *
2158: * Called by a driver's TV initialization routine, this function creates
2159: * the TV specific connector properties for a given device. Caller is
2160: * responsible for allocating a list of format names and passing them to
2161: * this routine.
2162: *
2163: * NOTE: This functions registers the deprecated "mode" connector
2164: * property to select the analog TV mode (ie, NTSC, PAL, etc.). New
2165: * drivers must use drm_mode_create_tv_properties() instead.
2166: *
2167: * Returns:
2168: * 0 on success or a negative error code on failure.
2169: */
2170: int drm_mode_create_tv_properties_legacy(struct drm_device *dev,
2171: unsigned int num_modes,
2172: const char * const modes[])
2173: {
2174: struct drm_property *tv_selector;
2175: struct drm_property *tv_subconnector;
2176: unsigned int i;
2177:
2178: if (dev->mode_config.tv_select_subconnector_property)
2179: return 0;
2180:
2181: /*
2182: * Basic connector properties
2183: */
2184: tv_selector = drm_property_create_enum(dev, 0,
2185: "select subconnector",
2186: drm_tv_select_enum_list,
2187: ARRAY_SIZE(drm_tv_select_enum_list));
2188: if (!tv_selector)
2189: goto nomem;
2190:
2191: dev->mode_config.tv_select_subconnector_property = tv_selector;
2192:
2193: tv_subconnector =
2194: drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
2195: "subconnector",
2196: drm_tv_subconnector_enum_list,
2197: ARRAY_SIZE(drm_tv_subconnector_enum_list));
2198: if (!tv_subconnector)
2199: goto nomem;
2200: dev->mode_config.tv_subconnector_property = tv_subconnector;
2201:
2202: /*
2203: * Other, TV specific properties: margins & TV modes.
2204: */
2205: if (drm_mode_create_tv_margin_properties(dev))
2206: goto nomem;
2207:
2208: if (num_modes) {
2209: dev->mode_config.legacy_tv_mode_property =
2210: drm_property_create(dev, DRM_MODE_PROP_ENUM,
2211: "mode", num_modes);
2212: if (!dev->mode_config.legacy_tv_mode_property)
2213: goto nomem;
2214:
2215: for (i = 0; i < num_modes; i++)
2216: drm_property_add_enum(dev->mode_config.legacy_tv_mode_property,
2217: i, modes[i]);
2218: }
2219:
2220: dev->mode_config.tv_brightness_property =
2221: drm_property_create_range(dev, 0, "brightness", 0, 100);
2222: if (!dev->mode_config.tv_brightness_property)
2223: goto nomem;
2224:
2225: dev->mode_config.tv_contrast_property =
2226: drm_property_create_range(dev, 0, "contrast", 0, 100);
2227: if (!dev->mode_config.tv_contrast_property)
2228: goto nomem;
2229:
2230: dev->mode_config.tv_flicker_reduction_property =
2231: drm_property_create_range(dev, 0, "flicker reduction", 0, 100);
2232: if (!dev->mode_config.tv_flicker_reduction_property)
2233: goto nomem;
2234:
2235: dev->mode_config.tv_overscan_property =
2236: drm_property_create_range(dev, 0, "overscan", 0, 100);
2237: if (!dev->mode_config.tv_overscan_property)
2238: goto nomem;
2239:
2240: dev->mode_config.tv_saturation_property =
2241: drm_property_create_range(dev, 0, "saturation", 0, 100);
2242: if (!dev->mode_config.tv_saturation_property)
2243: goto nomem;
2244:
2245: dev->mode_config.tv_hue_property =
2246: drm_property_create_range(dev, 0, "hue", 0, 100);
2247: if (!dev->mode_config.tv_hue_property)
2248: goto nomem;
2249:
2250: return 0;
2251: nomem:
2252: return -ENOMEM;
2253: }
SourceFile:drivers/gpu/drm/drm_connector.c]
|
| 46/2 |
2026/09/17 02:22 |
llm |
expert |
0m
Model:
Tokens:
input: 64150
output: 66
thoughts: 3714
Thoughts: **Vulnerability Analysis: Information Leak and Denial of Service via Out-of-Bounds Read in `drm_mode_create_tv_properties_legacy`**
Okay, here's my assessment. `drm_mode_create_tv_properties_legacy` is the key. The function, specifically when called within the `gud` USB display driver, has a glaring vulnerability. It ignores the return value of `drm_property_add_enum`, which means even if that function fails due to a name length issue (specifically, `strlen(name) >= DRM_PROP_NAME_LEN`), the probe CONTINUES.
If `drm_property_add_enum` returns `-EINVAL`, it *doesn't* add the enum, but the subsequent code continues. If the string is less than 32, it will copy data out of bounds! I'm seeing a potential for an attacker to craft a malicious USB device that can cause an information leak. The `strlen` function can read past the end of the allocated buffer due to a missing null byte, potentially leaking bytes from adjacent heap memory. The crucial part is that `strlen` checks for a null byte, so the attacker would need to either exploit the heap to control the next object (or parts of it) to include a null byte. If a null byte *isn't* found within the first 16 bytes beyond the allocated buffer, `strlen` will return a value of greater or equal to 32, skipping the enum from being added, but the probe STILL succeeds. This is a very reliable info leak.
This also leads to a denial of service if `strlen` reads into an unmapped page. This is because reading past the end of the page will cause a kernel panic, a crash.
The trigger is clearly a peripheral device β a malicious USB device. No network or filesystem triggers are possible, and an unprivileged process can't directly connect a USB device, so it's not a remote vulnerability. The `gud` driver utilizes `kmalloc(256)`, this means, the vulnerability occurs when the USB device returns data without null-termination, where `strlen` can read up to 255 bytes and beyond.
The syzkaller reproducer works by sending crafted control transfers to the `gud` driver. The analysis of the syzkaller reproducer clearly demonstrates how to trigger the `strlen` out-of-bounds read and reveals how the attacker might craft a USB device to make it leak heap data from userspace. I've reconfirmed that the vulnerability persists even if adding an enum fails.
|
| 47/2 |
2026/09/17 02:23 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 48/2 |
2026/09/17 02:23 |
llm |
expert |
0m
Model:
Tokens:
input: 68542
output: 669
thoughts: 323
Thoughts: **Finalizing the Response: Out-of-Bounds Read in DRM**
Okay, the analysis is complete, time to synthesize this into a polished response. The crux of the issue boils down to an out-of-bounds read vulnerability, and it's quite interesting how this one is triggered. The root cause lies within the `drm_property_add_enum` function, but the culprit is the `gud` (Generic USB Display) driver. My understanding is this driver is reading TV mode names directly from the USB device, allocating a `kmalloc` buffer to hold these strings. The code then passes these names to `drm_mode_create_tv_properties_legacy`, which in turn hands them over to `drm_property_add_enum`.
The critical flaw? `drm_property_add_enum` uses `strlen(name)` on these names. If the USB device doesn't ensure null-termination of these strings (which, of course, is a significant assumption to make when dealing with external, potentially malicious input!), `strlen` will happily read past the end of the allocated buffer. This is textbook out-of-bounds read territory.
The consequence? Well, a kernel crash is on the table, a straightforward Denial of Service, if that read happens to hit an unmapped page. However, it gets more interesting. If a null byte *does* happen to be present within the *next* 15 bytes of the adjacent heap object, then `strscpy_pad` will, alarmingly, copy the out-of-bounds bytes into the property name.
Here's the kicker: The return value of `drm_property_add_enum` is blithely ignored by `drm_mode_create_tv_properties_legacy`. That means the probe can still succeed, and the leaked heap data is now accessible to userspace. In other words, you have an exploitable information leak! That's concerning, since the data could be anything depending on how the heap is managed.
The attack vector is well-defined: this is triggered by plugging in a malicious USB device. It's a peripheral trigger, so we're looking at a physical attack, and an unprivileged user can't trigger it without physical access, so remote exploitation is out. This, of course, changes the overall threat model, but it is still serious.
|
| 49/1 |
2026/09/17 02:23 |
action |
format-explanation |
0m
Results: map[Explanation:**Analysis of the Bug**
The bug report indicates a `WARN_ON` triggered in `drm_property_add_enum` due to
`strlen(name) >= DRM_PROP_NAME_LEN`.
1. **Root Cause**:
The `gud` (Generic USB Display) driver queries the USB device for TV mode
names during probe (`gud_connector_add_tv_mode`). It allocates a buffer using
`kmalloc` and reads the mode names directly from the USB device via a control
transfer (`gud_usb_get`). The driver assumes the data returned by the USB
device is properly null-terminated or at least contains null bytes within the
expected boundaries.
The driver then passes these strings to
`drm_mode_create_tv_properties_legacy`, which in turn calls
`drm_property_add_enum`. `drm_property_add_enum` calls `strlen(name)` on the
provided string. If a malicious USB device returns a buffer completely devoid
of null bytes, `strlen` will read past the end of the `kmalloc` allocated
buffer, resulting in an out-of-bounds (OOB) read.
2. **Exploitability (Information Leak)**:
If the OOB read by `strlen` encounters a null byte within the adjacent heap
memory (specifically within the next 15 bytes, such that `strlen(name) <
DRM_PROP_NAME_LEN`), the `WARN_ON` is bypassed. The code then proceeds to
call `strscpy_pad`, which copies the out-of-bounds heap data into the
`prop_enum->name` field.
Crucially, `drm_mode_create_tv_properties_legacy` ignores the return value of
`drm_property_add_enum`. This means the USB device probe will successfully
complete, and the DRM device will be registered. A local attacker can then
use the `DRM_IOCTL_MODE_GETPROPERTY` ioctl to read the property enums,
effectively leaking up to 15 bytes of adjacent kernel heap memory to
userspace. This information leak can be used to bypass KASLR or leak
sensitive pointers, making the bug **Exploitable**.
3. **Denial of Service (DoS)**:
If the `kmalloc` buffer happens to be allocated at the very end of a page,
and the subsequent page is unmapped, the `strlen` call will attempt to read
from unmapped memory. This will cause a page fault in kernel space, leading
to a kernel oops/panic and crashing the system. Thus, it can be used for
**Denial of Service**.
4. **Trigger Mechanism**:
The vulnerability is located in the USB device probe path of the `gud`
driver. It requires the kernel to process a malicious USB device descriptor
and control transfer responses. Therefore, it can be triggered by physically
plugging in a malicious USB device (**Peripheral Trigger**). It cannot be
triggered over the network, via a filesystem, or by an unprivileged user
process (unless the user has physical access to plug in the device, or root
privileges to emulate one via `dummy_hcd`/`raw-gadget`).]
|