lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <B0A92094-0F80-4B93-9CC0-274C75E6B095@mork.no>
Date:	Thu, 16 Jul 2015 22:18:28 +0200
From:	Bjørn Mork <bjorn@...k.no>
To:	Oliver Neukum <oneukum@...e.com>, linux-usb@...r.kernel.org,
	netdev@...r.kernel.org
Subject: Re: [PATCH 2/8] cdc-ncm: use common CDC parser

I'm on vacation without any usable Internet or other code access, so you'll have to excuse me if I'm missing something.  But this seems to leave union_desc uninitialized, doesn't it?

Bjørn

On July 16, 2015 9:24:34 PM CEST, Oliver Neukum <oneukum@...e.com> wrote:
>Switch to the common parser
>
>Signed-off-by: Oliver Neukum <oneukum@...e.com>
>---
>drivers/net/usb/cdc_ncm.c | 69
>+++++++----------------------------------------
> 1 file changed, 9 insertions(+), 60 deletions(-)
>
>diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
>index db40175..2cef13a 100644
>--- a/drivers/net/usb/cdc_ncm.c
>+++ b/drivers/net/usb/cdc_ncm.c
>@@ -698,6 +698,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct
>usb_interface *intf, u8 data_
> 	int len;
> 	int temp;
> 	u8 iface_no;
>+	struct usb_cdc_parsed_header hdr;
> 
> 	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
> 	if (!ctx)
>@@ -722,66 +723,14 @@ int cdc_ncm_bind_common(struct usbnet *dev,
>struct usb_interface *intf, u8 data_
> 	len = intf->cur_altsetting->extralen;
> 
> 	/* parse through descriptors associated with control interface */
>-	while ((len > 0) && (buf[0] > 2) && (buf[0] <= len)) {
>-
>-		if (buf[1] != USB_DT_CS_INTERFACE)
>-			goto advance;
>-
>-		switch (buf[2]) {
>-		case USB_CDC_UNION_TYPE:
>-			if (buf[0] < sizeof(*union_desc))
>-				break;
>-
>-			union_desc = (const struct usb_cdc_union_desc *)buf;
>-			/* the master must be the interface we are probing */
>-			if (intf->cur_altsetting->desc.bInterfaceNumber !=
>-			    union_desc->bMasterInterface0) {
>-				dev_dbg(&intf->dev, "bogus CDC Union\n");
>-				goto error;
>-			}
>-			ctx->data = usb_ifnum_to_if(dev->udev,
>-						    union_desc->bSlaveInterface0);
>-			break;
>-
>-		case USB_CDC_ETHERNET_TYPE:
>-			if (buf[0] < sizeof(*(ctx->ether_desc)))
>-				break;
>-
>-			ctx->ether_desc =
>-					(const struct usb_cdc_ether_desc *)buf;
>-			break;
>-
>-		case USB_CDC_NCM_TYPE:
>-			if (buf[0] < sizeof(*(ctx->func_desc)))
>-				break;
>-
>-			ctx->func_desc = (const struct usb_cdc_ncm_desc *)buf;
>-			break;
>-
>-		case USB_CDC_MBIM_TYPE:
>-			if (buf[0] < sizeof(*(ctx->mbim_desc)))
>-				break;
>-
>-			ctx->mbim_desc = (const struct usb_cdc_mbim_desc *)buf;
>-			break;
>-
>-		case USB_CDC_MBIM_EXTENDED_TYPE:
>-			if (buf[0] < sizeof(*(ctx->mbim_extended_desc)))
>-				break;
>-
>-			ctx->mbim_extended_desc =
>-				(const struct usb_cdc_mbim_extended_desc *)buf;
>-			break;
>-
>-		default:
>-			break;
>-		}
>-advance:
>-		/* advance to next descriptor */
>-		temp = buf[0];
>-		buf += temp;
>-		len -= temp;
>-	}
>+	cdc_parse_cdc_header(&hdr, intf, buf, len);
>+
>+	ctx->data = usb_ifnum_to_if(dev->udev, 
>+				    hdr.usb_cdc_union_desc->bSlaveInterface0);
>+	ctx->ether_desc = hdr.usb_cdc_ether_desc;
>+	ctx->func_desc = hdr.usb_cdc_ncm_desc;
>+	ctx->mbim_desc = hdr.usb_cdc_mbim_desc;
>+	ctx->mbim_extended_desc = hdr.usb_cdc_mbim_extended_desc;
> 
> 	/* some buggy devices have an IAD but no CDC Union */
>	if (!union_desc && intf->intf_assoc &&
>intf->intf_assoc->bInterfaceCount == 2) {

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ