All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Oliver Neukum <oneukum@suse.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org,
	Daniel Caujolle-Bert <f1rmb.daniel@gmail.com>,
	Johan Hovold <johan@kernel.org>,
	stable@vger.kernel.org
Subject: [PATCH v2 2/4] USB: cdc-acm: handle broken union descriptors
Date: Mon, 21 Sep 2020 15:59:49 +0200	[thread overview]
Message-ID: <20200921135951.24045-3-johan@kernel.org> (raw)
In-Reply-To: <20200921135951.24045-1-johan@kernel.org>

Handle broken union functional descriptors where the master-interface
doesn't exist or where its class is of neither Communication or Data
type (as required by the specification) by falling back to
"combined-interface" probing.

Note that this still allows for handling union descriptors with switched
interfaces.

This specifically makes the Whistler radio scanners TRX series devices
work with the driver without adding further quirks to the device-id
table.

Link: https://lore.kernel.org/r/5f4ca4f8.1c69fb81.a4487.0f5f@mx.google.com
Reported-by: Daniel Caujolle-Bert <f1rmb.daniel@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/class/cdc-acm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index e28ac640ff9c..f42ade505569 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1240,9 +1240,21 @@ static int acm_probe(struct usb_interface *intf,
 			}
 		}
 	} else {
+		int class = -1;
+
 		data_intf_num = union_header->bSlaveInterface0;
 		control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0);
 		data_interface = usb_ifnum_to_if(usb_dev, data_intf_num);
+
+		if (control_interface)
+			class = control_interface->cur_altsetting->desc.bInterfaceClass;
+
+		if (class != USB_CLASS_COMM && class != USB_CLASS_CDC_DATA) {
+			dev_dbg(&intf->dev, "Broken union descriptor, assuming single interface\n");
+			combined_interfaces = 1;
+			control_interface = data_interface = intf;
+			goto look_for_collapsed_interface;
+		}
 	}
 
 	if (!control_interface || !data_interface) {
-- 
2.26.2


  parent reply	other threads:[~2020-09-21 14:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-21 13:59 [PATCH v2 0/4] USB: cdc-acm: handle broken union descriptors Johan Hovold
2020-09-21 13:59 ` [PATCH v2 1/4] Revert "cdc-acm: hardening against malicious devices" Johan Hovold
2020-09-21 13:59 ` Johan Hovold [this message]
2020-09-22  9:53   ` [PATCH v2 2/4] USB: cdc-acm: handle broken union descriptors <Daniel Caujolle-Bert>
2020-09-21 13:59 ` [PATCH v2 3/4] USB: cdc-acm: use common data-class define Johan Hovold
2020-09-21 13:59 ` [PATCH v2 4/4] USB: cdc-acm: clean up no-union-descriptor handling Johan Hovold
2020-09-21 14:16   ` Oliver Neukum
2020-09-21 14:28     ` Johan Hovold
2020-09-21 15:04       ` Oliver Neukum
2020-09-21 15:16         ` Johan Hovold
2020-09-21 17:17           ` Oliver Neukum
2020-09-22  7:05             ` Johan Hovold
2020-09-22 10:40               ` Oliver Neukum
2020-09-22 10:54                 ` Johan Hovold
2020-09-22 11:41                   ` Oliver Neukum
2020-09-22 11:47                     ` Johan Hovold
2020-09-21 14:21 ` [PATCH v2 0/4] USB: cdc-acm: handle broken union descriptors <Daniel Caujolle-Bert>
2020-09-21 16:19 ` <Daniel Caujolle-Bert>
2020-09-22  7:08   ` Johan Hovold
2020-09-22  9:56     ` <Daniel Caujolle-Bert>
2020-09-22 10:07       ` Johan Hovold
2020-09-22 12:10 ` Oliver Neukum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200921135951.24045-3-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=f1rmb.daniel@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.