Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1600870 > unrolled thread

[PATCH 2/4] cdc-acm: fix possible invalid access when processing notification

Started byTobias Herzog <t-herzog@gmx.de>
First post2017-03-14 21:20 +0100
Last post2017-03-15 10:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/4] cdc-acm: fix possible invalid access when processing notification Tobias Herzog <t-herzog@gmx.de> - 2017-03-14 21:20 +0100
    Re: [PATCH 2/4] cdc-acm: fix possible invalid access when  processing notification Oliver Neukum <oneukum@suse.com> - 2017-03-15 10:30 +0100

#1600870 — [PATCH 2/4] cdc-acm: fix possible invalid access when processing notification

FromTobias Herzog <t-herzog@gmx.de>
Date2017-03-14 21:20 +0100
Subject[PATCH 2/4] cdc-acm: fix possible invalid access when processing notification
Message-ID<tl15f-5mY-23@gated-at.bofh.it>
Notifications may only be 8 bytes so 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>
---
 drivers/usb/class/cdc-acm.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 40714fe..b99127e 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -296,6 +296,12 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf)
 		break;
 
 	case USB_CDC_NOTIFY_SERIAL_STATE:
+		if (dr->wLength != 2) {
+			dev_dbg(&acm->control->dev,
+				"%s - malformed serial state\n", __func__);
+			break;
+		}
+
 		newctrl = get_unaligned_le16(data);
 
 		if (!acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
@@ -332,11 +338,10 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf)
 
 	default:
 		dev_dbg(&acm->control->dev,
-			"%s - unknown notification %d received: index %d "
-			"len %d data0 %d data1 %d\n",
+			"%s - unknown notification %d received: index %d len %d\n",
 			__func__,
 			dr->bNotificationType, dr->wIndex,
-			dr->wLength, data[0], data[1]);
+			dr->wLength);
 	}
 }
 
-- 
2.1.4

[toc] | [next] | [standalone]


#1601171 — Re: [PATCH 2/4] cdc-acm: fix possible invalid access when processing notification

FromOliver Neukum <oneukum@suse.com>
Date2017-03-15 10:30 +0100
SubjectRe: [PATCH 2/4] cdc-acm: fix possible invalid access when processing notification
Message-ID<tldpL-5Cc-15@gated-at.bofh.it>
In reply to#1600870
Am Dienstag, den 14.03.2017, 21:14 +0100 schrieb Tobias Herzog:
> Notifications may only be 8 bytes so 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>
> ---
>  drivers/usb/class/cdc-acm.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
> index 40714fe..b99127e 100644
> --- a/drivers/usb/class/cdc-acm.c
> +++ b/drivers/usb/class/cdc-acm.c
> @@ -296,6 +296,12 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf)
>  		break;
>  
>  	case USB_CDC_NOTIFY_SERIAL_STATE:
> +		if (dr->wLength != 2) {

Endianness

> +			dev_dbg(&acm->control->dev,
> +				"%s - malformed serial state\n", __func__);
> +			break;
> +		}
> +
>  		newctrl = get_unaligned_le16(data);
>  
>  		if (!acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
> @@ -332,11 +338,10 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf)
>  
>  	default:
>  		dev_dbg(&acm->control->dev,
> -			"%s - unknown notification %d received: index %d "
> -			"len %d data0 %d data1 %d\n",
> +			"%s - unknown notification %d received: index %d len %d\n",
>  			__func__,
>  			dr->bNotificationType, dr->wIndex,
> -			dr->wLength, data[0], data[1]);
> +			dr->wLength);
>  	}
>  }
>  

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web