aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-09-21 10:58:48 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-09-21 11:01:38 -0400
commit2e1c42391ff2556387b3cb6308b24f6f65619feb (patch)
treede17bf75f6f81fb1d2d14748ede49e7d3f3c2f88
parent60e70ecd7ae0f09ed07699517071eacb01c26d13 (diff)
USB: core: harden cdc_parse_cdc_header
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> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/core/message.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 4c38ea41ae96..371a07d874a3 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -2069,6 +2069,10 @@ int cdc_parse_cdc_header(struct usb_cdc_parsed_header *hdr,
2069 elength = 1; 2069 elength = 1;
2070 goto next_desc; 2070 goto next_desc;
2071 } 2071 }
2072 if ((buflen < elength) || (elength < 3)) {
2073 dev_err(&intf->dev, "invalid descriptor buffer length\n");
2074 break;
2075 }
2072 if (buffer[1] != USB_DT_CS_INTERFACE) { 2076 if (buffer[1] != USB_DT_CS_INTERFACE) {
2073 dev_err(&intf->dev, "skipping garbage\n"); 2077 dev_err(&intf->dev, "skipping garbage\n");
2074 goto next_desc; 2078 goto next_desc;