diff options
| author | Xinyu Liu <katieeliu@tencent.com> | 2025-06-30 10:02:56 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-08-28 16:28:31 +0200 |
| commit | 5badd56c711e2c8371d1670f9bd486697575423c (patch) | |
| tree | 9deae76d57e7dc10ed23b2927a8ba3d0b8a7a961 /drivers/usb/core | |
| parent | 492207cf8372f558f5ef31db3e737df9097fa99b (diff) | |
| download | linux-5badd56c711e2c8371d1670f9bd486697575423c.tar.gz linux-5badd56c711e2c8371d1670f9bd486697575423c.tar.bz2 linux-5badd56c711e2c8371d1670f9bd486697575423c.zip | |
usb: core: config: Prevent OOB read in SS endpoint companion parsing
commit cf16f408364efd8a68f39011a3b073c83a03612d upstream.
usb_parse_ss_endpoint_companion() checks descriptor type before length,
enabling a potentially odd read outside of the buffer size.
Fix this up by checking the size first before looking at any of the
fields in the descriptor.
Signed-off-by: Xinyu Liu <katieeliu@tencent.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/core')
| -rw-r--r-- | drivers/usb/core/config.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 847dd32c0f5e..3180419424c0 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -81,8 +81,14 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno, */ desc = (struct usb_ss_ep_comp_descriptor *) buffer; - if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP || - size < USB_DT_SS_EP_COMP_SIZE) { + if (size < USB_DT_SS_EP_COMP_SIZE) { + dev_notice(ddev, + "invalid SuperSpeed endpoint companion descriptor " + "of length %d, skipping\n", size); + return; + } + + if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP) { dev_notice(ddev, "No SuperSpeed endpoint companion for config %d " " interface %d altsetting %d ep %d: " "using minimum values\n", |
