diff options
| author | Tobias Herzog <t-herzog@gmx.de> | 2017-03-30 16:15:10 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-25 09:44:36 -0400 |
| commit | 809ae061d998359783c1bb0c52bba14f4a6397c4 (patch) | |
| tree | 96f2da7d48e5e0954989c66b3595e63af8e49141 /drivers/usb | |
| parent | 198ab4031873b5511d6ef9b4777cabc4eebcaf18 (diff) | |
cdc-acm: fix possible invalid access when processing notification
commit 1bb9914e1730417d530de9ed37e59efdc647146b upstream.
Notifications may only be 8 bytes long. Accessing the 9th and
10th byte of unimplemented/unknown notifications may be insecure.
Also check the length of known notifications before accessing anything
behind the 8th byte.
Signed-off-by: Tobias Herzog <t-herzog@gmx.de>
Acked-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
| -rw-r--r-- | drivers/usb/class/cdc-acm.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index c5ff13f22b24..a876d47246dc 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
| @@ -311,6 +311,12 @@ static void acm_ctrl_irq(struct urb *urb) | |||
| 311 | break; | 311 | break; |
| 312 | 312 | ||
| 313 | case USB_CDC_NOTIFY_SERIAL_STATE: | 313 | case USB_CDC_NOTIFY_SERIAL_STATE: |
| 314 | if (le16_to_cpu(dr->wLength) != 2) { | ||
| 315 | dev_dbg(&acm->control->dev, | ||
| 316 | "%s - malformed serial state\n", __func__); | ||
| 317 | break; | ||
| 318 | } | ||
| 319 | |||
| 314 | newctrl = get_unaligned_le16(data); | 320 | newctrl = get_unaligned_le16(data); |
| 315 | 321 | ||
| 316 | if (!acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) { | 322 | if (!acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) { |
| @@ -347,11 +353,10 @@ static void acm_ctrl_irq(struct urb *urb) | |||
| 347 | 353 | ||
| 348 | default: | 354 | default: |
| 349 | dev_dbg(&acm->control->dev, | 355 | dev_dbg(&acm->control->dev, |
| 350 | "%s - unknown notification %d received: index %d " | 356 | "%s - unknown notification %d received: index %d len %d\n", |
| 351 | "len %d data0 %d data1 %d\n", | ||
| 352 | __func__, | 357 | __func__, |
| 353 | dr->bNotificationType, dr->wIndex, | 358 | dr->bNotificationType, dr->wIndex, dr->wLength); |
| 354 | dr->wLength, data[0], data[1]); | 359 | |
| 355 | break; | 360 | break; |
| 356 | } | 361 | } |
| 357 | exit: | 362 | exit: |
