Skip to content

Commit feab51a

Browse files
committed
USB: core: harden cdc_parse_cdc_header
commit 2e1c42391ff2556387b3cb6308b24f6f65619feb upstream. Andrey Konovalov reported a possible out-of-bounds problem for the cdc_parse_cdc_header function. He writes: It looks like cdc_parse_cdc_header() doesn't validate buflen before accessing buffer[1], buffer[2] and so on. The only check present is while (buflen > 0). So fix this issue up by properly validating the buffer length matches what the descriptor says it is. Reported-by: Andrey Konovalov <andreyknvl@google.com> Tested-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5d9a9c3 commit feab51a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/net/usb/usbnet.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,10 @@ int cdc_parse_cdc_header(struct usb_cdc_parsed_header *hdr,
19901990
elength = 1;
19911991
goto next_desc;
19921992
}
1993+
if ((buflen < elength) || (elength < 3)) {
1994+
dev_err(&intf->dev, "invalid descriptor buffer length\n");
1995+
break;
1996+
}
19931997
if (buffer[1] != USB_DT_CS_INTERFACE) {
19941998
dev_err(&intf->dev, "skipping garbage\n");
19951999
goto next_desc;

0 commit comments

Comments
 (0)