mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-13 13:46:22 -04:00
usb: xusbatm: don't rely on id table pointer arithmetic
The current code is broken when dynamic ID is involved; in such cases usb_device_id parameter of probe lives on the heap and the pointer arithmetic will get an index that is wildly out of bound. xusbatm initialize the USB device IDs dynamically so it can just use driver_info too. Even with conversion, xusbatm still cannot support dynamic IDs, so also set no_dynamic_id. Signed-off-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260707-usb_dyn_id_uaf-v2-6-632dcf3adfba@garyguo.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ce8101c331
commit
eb6cd6d3d8
@@ -79,7 +79,7 @@ static int xusbatm_bind(struct usbatm_data *usbatm,
|
||||
struct usb_interface *intf, const struct usb_device_id *id)
|
||||
{
|
||||
struct usb_device *usb_dev = interface_to_usbdev(intf);
|
||||
int drv_ix = id - xusbatm_usb_ids;
|
||||
int drv_ix = id->driver_info;
|
||||
int rx_alt = rx_altsetting[drv_ix];
|
||||
int tx_alt = tx_altsetting[drv_ix];
|
||||
struct usb_interface *rx_intf = xusbatm_find_intf(usb_dev, rx_alt, rx_endpoint[drv_ix]);
|
||||
@@ -168,7 +168,8 @@ static struct usb_driver xusbatm_usb_driver = {
|
||||
.name = xusbatm_driver_name,
|
||||
.probe = xusbatm_usb_probe,
|
||||
.disconnect = usbatm_usb_disconnect,
|
||||
.id_table = xusbatm_usb_ids
|
||||
.id_table = xusbatm_usb_ids,
|
||||
.no_dynamic_id = 1,
|
||||
};
|
||||
|
||||
static int __init xusbatm_init(void)
|
||||
@@ -190,6 +191,7 @@ static int __init xusbatm_init(void)
|
||||
xusbatm_usb_ids[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
|
||||
xusbatm_usb_ids[i].idVendor = vendor[i];
|
||||
xusbatm_usb_ids[i].idProduct = product[i];
|
||||
xusbatm_usb_ids[i].driver_info = i;
|
||||
|
||||
xusbatm_drivers[i].driver_name = xusbatm_driver_name;
|
||||
xusbatm_drivers[i].bind = xusbatm_bind;
|
||||
|
||||
Reference in New Issue
Block a user