From patchwork Mon Sep 21 11:35:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 297570 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77749C43465 for ; Mon, 21 Sep 2020 11:36:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 457272071A for ; Mon, 21 Sep 2020 11:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600688182; bh=zvcSKdka8MWJDFF0L4+TxqQovqXBODY1v6/sOJYC9yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mRWMyN/8GBw6GQCWYroN/2bCFdLfbj7D+K70PIYjKvJXOILg28j4WhEZYx1ZSohqA Epb0KEEtW57wXZCVgj7BCpcavE1hXpgSrSyrHGqfl1dvg8kfds9M8PG5DiPClNiDZG YezGWdLDwwBrOfBt6gG/VRdVjozV02+cFbx2qlyQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726738AbgIULgV (ORCPT ); Mon, 21 Sep 2020 07:36:21 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43665 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726430AbgIULgU (ORCPT ); Mon, 21 Sep 2020 07:36:20 -0400 Received: by mail-lf1-f65.google.com with SMTP id y2so13581272lfy.10 for ; Mon, 21 Sep 2020 04:36:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QeNREgn/VBFyeE24M7SC8hPxyEUzwzXz3H+WzHOfyA8=; b=L396xKC1E1IKeHA6Gk+i0JqY9AFOtA9HyBfpWp1qPmE0j8kkXHjnFu27B7IXpwQ/U5 WHrxg+JwuGgM7T40//0svvfU0h0qtGmSeSgSwhrCF0iZmnjPlGIUfn4T5GLynyeky+nt fyjn22oi9K2iJ+H7BE4vHuNt2/dTjmE5Ye/gyxJ+1XrxxgTgnVOf0sGPIVc84x4A6RiP ltqrzXRYRPKEHLOTys7hMthdjU+Qggno46IbQBIUUZRH5Swcp8DZe4U7c0VNyw9hW3tp 0EYRdYBQw2AMtt63cTSAiL6m24wkkz7zwXbdzhwWG0wST9Rh+p87zW1FlzLb/3hGuVJd FKBA== X-Gm-Message-State: AOAM53071sTAnHWQvDO3bgYl1V7YCFp0D5FM3vVnHPY1c6rvo0emMGI5 8tBTbNi22tAHWcp+FXSV5E/aHsKqH4U= X-Google-Smtp-Source: ABdhPJyNVLRQzI97ecwBgfZ+VJ39XcfNVtbrzByEuP8eqyYGfQYGFUUUjMklj0sWNTAFJE6iEVYSBg== X-Received: by 2002:ac2:4301:: with SMTP id l1mr14050269lfh.389.1600688178408; Mon, 21 Sep 2020 04:36:18 -0700 (PDT) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id z10sm2497275lfa.10.2020.09.21.04.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 04:36:17 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kKK79-0008OB-4S; Mon, 21 Sep 2020 13:36:11 +0200 From: Johan Hovold To: Oliver Neukum Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Daniel Caujolle-Bert , Johan Hovold Subject: [PATCH 1/4] Revert "cdc-acm: hardening against malicious devices" Date: Mon, 21 Sep 2020 13:35:22 +0200 Message-Id: <20200921113525.32187-2-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200921113525.32187-1-johan@kernel.org> References: <20200921113525.32187-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This reverts commit 2ad9d544f2497a7bf239c34bd2b86fd19683dbb5. Drop bogus sanity check; an interface in the active configuration will always have a current altsetting assigned by USB core. Signed-off-by: Johan Hovold --- drivers/usb/class/cdc-acm.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 7f6f3ab5b8a6..e28ac640ff9c 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -1196,9 +1196,6 @@ static int acm_probe(struct usb_interface *intf, return -EINVAL; } - if (!intf->cur_altsetting) - return -EINVAL; - if (!buflen) { if (intf->cur_altsetting->endpoint && intf->cur_altsetting->endpoint->extralen && @@ -1252,8 +1249,6 @@ static int acm_probe(struct usb_interface *intf, dev_dbg(&intf->dev, "no interfaces\n"); return -ENODEV; } - if (!data_interface->cur_altsetting || !control_interface->cur_altsetting) - return -ENODEV; if (data_intf_num != call_intf_num) dev_dbg(&intf->dev, "Separate call control interface. That is not fully supported.\n"); From patchwork Mon Sep 21 11:35:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 258482 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF9BCC43463 for ; Mon, 21 Sep 2020 11:36:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8911920EDD for ; Mon, 21 Sep 2020 11:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600688182; bh=sbCQymTuHxktI/0ws4xrHPJ2GPSG0mcIsea5gvdDVlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SuR+8kj1hRudwMvJkgznyiRYo/11r0EOl6XLjY9/CKMNeDobUyJHVANyxFQOkVdD0 X7qxm/mVE4AJ/iAARRITFISzh7/0YW93huKlVEYOn84jrpkJjLyTsOyDJCbeP6Us8d Ej+TKdRy8GC0rPdYulahHpQU7pBeo46WmLABSPpg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726746AbgIULgV (ORCPT ); Mon, 21 Sep 2020 07:36:21 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:44286 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726597AbgIULgV (ORCPT ); Mon, 21 Sep 2020 07:36:21 -0400 Received: by mail-lf1-f68.google.com with SMTP id d15so13588116lfq.11 for ; Mon, 21 Sep 2020 04:36:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5ihnzTTzQ2wZgtaBo9C1DcEQgiZYLpfLStKr4kjaXDI=; b=L2WggUL2bO1syGTrXzUBsllz00KtsKkT5PQPmNTMEnfdVhlXz1Yc3mCLpgm/JzusR+ /mMYSm8SO+/UGrslNrH4z8L/Grj26eIu1MVDuiZvEfR/PBkRzQefEZfJBBXr/DgYSba1 BxMXoTUCCtEPCl1zgXbR433AIqvdOpXjCXQrN0DzgYgZrxStKeIxzSS0L7aVIfb+39kV V+KBHqKRqGMoUCNP8ArbsxG5G4ff1VP8kbmQMjk0w+XY3JUz5jWajZnVQq1Xiy72nzy3 /Yi1naTjwsLhs1YGoSW75TdAzpJZl4hTuwAEnbtbtVdjLd92mdvZR60qNMuiXU0K+Mmw 8H6A== X-Gm-Message-State: AOAM5337UxlVP3gSNXAAnLajjmfy7HGPLGcBo4xdAT4a9PhwsJUQ5Dzj UHc4kozWmlBQe0UPehYjhec= X-Google-Smtp-Source: ABdhPJyxcjJVpd7FaaTiUZqgq7ZGCPuNb8LumBXB1hYYpAyq0tlY/ih12JyoOV7EkDkhK/6YG43F0A== X-Received: by 2002:ac2:5299:: with SMTP id q25mr14816482lfm.198.1600688178978; Mon, 21 Sep 2020 04:36:18 -0700 (PDT) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id b16sm2637540ljh.34.2020.09.21.04.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 04:36:17 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kKK79-0008OG-7q; Mon, 21 Sep 2020 13:36:11 +0200 From: Johan Hovold To: Oliver Neukum Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Daniel Caujolle-Bert , Johan Hovold Subject: [PATCH 2/4] USB: cdc-acm: handle broken union descriptors Date: Mon, 21 Sep 2020 13:35:23 +0200 Message-Id: <20200921113525.32187-3-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200921113525.32187-1-johan@kernel.org> References: <20200921113525.32187-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.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 is 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 Signed-off-by: Johan Hovold --- 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..5b1a1cd0168d 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_warn(&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) { From patchwork Mon Sep 21 11:35:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 258481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D1FEC43465 for ; Mon, 21 Sep 2020 11:36:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FFD820EDD for ; Mon, 21 Sep 2020 11:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600688184; bh=aBB7PJLGloTLJSayybz8B582NjI4EP0M/t58gISF1X0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=IBfCpO/aecGILbumO1fVQUeGXb8oAyvDvkCOVAza6OipVsEGrJ7m5tFXv+k7Idkji V60naYrBKzc+oIDT9MakK1SsC6HMgtbJWQMxJT50Qfx89lihzRpnLs6yC1cG6dNgfE KmIjVaSG3is6k5PuueXLCORqmlnapDSAy+8ynvtE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726749AbgIULgX (ORCPT ); Mon, 21 Sep 2020 07:36:23 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:38361 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726696AbgIULgW (ORCPT ); Mon, 21 Sep 2020 07:36:22 -0400 Received: by mail-lj1-f194.google.com with SMTP id w3so10774719ljo.5 for ; Mon, 21 Sep 2020 04:36:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LPkgVcY9ITc2c7lL7eTIAvOiaRX9cWDsucFq3t5mnnE=; b=I0omz30ZAAuzCG6NcwiEb2pqlrimpFU4ldeG9xq8bTPUULZ6uzyaUWKe/kM1jdoKJc BQDcc4AK5r2SyKkPRDMatGjWbNlQvGdQ/P42SlmfS+CmKC7antggQ+0a63yLSQdk//3N xRWaRCrafykkcDBxssMYK4XOHwi0rRzQb4JyH4qQxS70K3B+LlNZGMjwDxYuCiZb5cps +J6Kq6BsJh82jCJW5w4AxTClVvTdcwFVTIUZyJRVGqHSGX0AOAmEgODVB4E5FXZ0Sw5P II0xZbvBoVzf2gTkAA8BmyVoPbzHiyZlnlbNUGtku46N0sQaUsMcDi/6Lf6AA9KBtwNb HIig== X-Gm-Message-State: AOAM532v9uoROr0pyIEjWWMwJXmUYEEJcruykBQ5I0PF68qoGyF2hh2d L+JYKfOCi+65Q0DOc3iMvrs= X-Google-Smtp-Source: ABdhPJytgBMaq5FjPwWrRcpVbj6C3q7Rd2kWAItdx/uYK47RoPTyCOhWI5qZAMKfsRYGdT0KW1EGhg== X-Received: by 2002:a05:651c:200b:: with SMTP id s11mr15418397ljo.196.1600688179909; Mon, 21 Sep 2020 04:36:19 -0700 (PDT) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id s11sm2649689ljh.56.2020.09.21.04.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 04:36:18 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kKK79-0008OL-B5; Mon, 21 Sep 2020 13:36:11 +0200 From: Johan Hovold To: Oliver Neukum Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Daniel Caujolle-Bert , Johan Hovold Subject: [PATCH 3/4] USB: cdc-acm: use common data-class define Date: Mon, 21 Sep 2020 13:35:24 +0200 Message-Id: <20200921113525.32187-4-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200921113525.32187-1-johan@kernel.org> References: <20200921113525.32187-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use the data-class define provided by USB core and drop the driver-specific one. Signed-off-by: Johan Hovold --- drivers/usb/class/cdc-acm.c | 6 ++---- drivers/usb/class/cdc-acm.h | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 5b1a1cd0168d..2758e295871e 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -1287,10 +1287,8 @@ static int acm_probe(struct usb_interface *intf, skip_normal_probe: /*workaround for switched interfaces */ - if (data_interface->cur_altsetting->desc.bInterfaceClass - != CDC_DATA_INTERFACE_TYPE) { - if (control_interface->cur_altsetting->desc.bInterfaceClass - == CDC_DATA_INTERFACE_TYPE) { + if (data_interface->cur_altsetting->desc.bInterfaceClass != USB_CLASS_CDC_DATA) { + if (control_interface->cur_altsetting->desc.bInterfaceClass == USB_CLASS_CDC_DATA) { dev_dbg(&intf->dev, "Your device has switched interfaces.\n"); swap(control_interface, data_interface); diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h index cd5e9d8ab237..b7174a0098a5 100644 --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h @@ -131,8 +131,6 @@ struct acm { unsigned long quirks; }; -#define CDC_DATA_INTERFACE_TYPE 0x0a - /* constants describing various quirks and errors */ #define NO_UNION_NORMAL BIT(0) #define SINGLE_RX_URB BIT(1) From patchwork Mon Sep 21 11:35:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 297569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D32A5C43466 for ; Mon, 21 Sep 2020 11:36:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A01E12071A for ; Mon, 21 Sep 2020 11:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600688183; bh=D3ajGOH/H1ug0zsvBXf63urj+aMRpRbkxOT8k8DHQk0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=bEhwPNmyOhc3s/CgJfltHdTJGz/BRwMRgVE21uQbAy/hozwIc43mDZjRCw/qax5qH /OrXMEiAxabV9zYjVlaM48YswiT+DJxs2gbJvvLH4o/bCtZ8TzopE4Emh5JGcfDUDo 022nnJDeZuL0Pe/EIAEyo+98QL2ekJiLmZ1hDIQ0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726748AbgIULgX (ORCPT ); Mon, 21 Sep 2020 07:36:23 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:44287 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726690AbgIULgV (ORCPT ); Mon, 21 Sep 2020 07:36:21 -0400 Received: by mail-lf1-f68.google.com with SMTP id d15so13588139lfq.11 for ; Mon, 21 Sep 2020 04:36:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mT/W9gPoT8HPtWMjLt/eX8O8tgNIOA/33FYtdIYgctA=; b=X7U4f9Y/We8XmZhp8SQL/j6FaM78XylWUvR+gtK1IUSY5jAzCDMmoHhDBjwllquVSS 49vXXpl73qZ+5C5NWIoS/k5SzLy1YXdWqMmKjVM1xxxn8HxSP7RlvTKdBv6ec0zwQrL0 QwqHJWn1KX7DI+DTc03qbupFPqi2RVhdvNe6JtL9m2ufM0VirC/qdCUPbRsBc4DeRhMH RvzVUUV5GC7o651TPznrYEFUz/FCOeEG4oyZzOBgOW2Y1JMjtt/WiEXkwiryZ4XI6XRc Ft7iSte7DnAkegeh4HKtnU2vyGxppZ/316zWH+yxXaI6HszFgrVppcDbVLel46oLJtj/ +DFg== X-Gm-Message-State: AOAM531qTKnbdecxFdzYScAjmyWvWHFiNjgVYPbJKiyc6pugr88jDAC4 H9dNrfGpfKppx5OPp24sH84= X-Google-Smtp-Source: ABdhPJz3S43zAcu/gERGOeZM2BBbVIMeWWs8WqMB4g7GOzNJi9sD7lAR2GjstKfBNQfrsfYd3+y7QQ== X-Received: by 2002:a05:6512:3191:: with SMTP id i17mr14796436lfe.460.1600688179495; Mon, 21 Sep 2020 04:36:19 -0700 (PDT) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id b28sm2489744lfq.107.2020.09.21.04.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 04:36:18 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kKK79-0008OR-Dx; Mon, 21 Sep 2020 13:36:11 +0200 From: Johan Hovold To: Oliver Neukum Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Daniel Caujolle-Bert , Johan Hovold Subject: [RFC 4/4] USB: cdc-acm: clean up handling of quirky devices Date: Mon, 21 Sep 2020 13:35:25 +0200 Message-Id: <20200921113525.32187-5-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200921113525.32187-1-johan@kernel.org> References: <20200921113525.32187-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Instead of falling back to "combined-interface" probing when detecting broken union and call-management descriptors, assume all interfaces with three endpoints are of "combined-interface" type. This allows for the removal of the NO_DATA_INTERFACE quirk and makes the probe algorithm somewhat easier to follow. Signed-off-by: Johan Hovold --- drivers/usb/class/cdc-acm.c | 44 ++++++++++--------------------------- drivers/usb/class/cdc-acm.h | 11 +++++----- 2 files changed, 16 insertions(+), 39 deletions(-) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 2758e295871e..eda883ce6d9d 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -1217,44 +1217,27 @@ static int acm_probe(struct usb_interface *intf, if (cmgmd) call_intf_num = cmgmd->bDataInterface; + if (intf->cur_altsetting->desc.bNumEndpoints == 3) { + dev_dbg(&intf->dev, "assuming single interface\n"); + combined_interfaces = 1; + control_interface = data_interface = intf; + goto look_for_collapsed_interface; + } + if (!union_header) { if (call_intf_num > 0) { dev_dbg(&intf->dev, "No union descriptor, using call management descriptor\n"); - /* quirks for Droids MuIn LCD */ - if (quirks & NO_DATA_INTERFACE) { - data_interface = usb_ifnum_to_if(usb_dev, 0); - } else { - data_intf_num = call_intf_num; - data_interface = usb_ifnum_to_if(usb_dev, data_intf_num); - } + data_intf_num = call_intf_num; + data_interface = usb_ifnum_to_if(usb_dev, data_intf_num); control_interface = intf; } else { - if (intf->cur_altsetting->desc.bNumEndpoints != 3) { - dev_dbg(&intf->dev,"No union descriptor, giving up\n"); - return -ENODEV; - } else { - dev_warn(&intf->dev,"No union descriptor, testing for castrated device\n"); - combined_interfaces = 1; - control_interface = data_interface = intf; - goto look_for_collapsed_interface; - } + dev_dbg(&intf->dev, "No union descriptor, giving up\n"); + return -ENODEV; } } 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_warn(&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) { @@ -1881,11 +1864,6 @@ static const struct usb_device_id acm_ids[] = { /* NOTE: non-Nokia COMM/ACM/0xff is likely MSFT RNDIS... NOT a modem! */ - /* Support for Droids MuIn LCD */ - { USB_DEVICE(0x04d8, 0x000b), - .driver_info = NO_DATA_INTERFACE, - }, - #if IS_ENABLED(CONFIG_INPUT_IMS_PCU) { USB_DEVICE(0x04d8, 0x0082), /* Application mode */ .driver_info = IGNORE_DEVICE, diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h index b7174a0098a5..b2135095898f 100644 --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h @@ -135,9 +135,8 @@ struct acm { #define NO_UNION_NORMAL BIT(0) #define SINGLE_RX_URB BIT(1) #define NO_CAP_LINE BIT(2) -#define NO_DATA_INTERFACE BIT(4) -#define IGNORE_DEVICE BIT(5) -#define QUIRK_CONTROL_LINE_STATE BIT(6) -#define CLEAR_HALT_CONDITIONS BIT(7) -#define SEND_ZERO_PACKET BIT(8) -#define DISABLE_ECHO BIT(9) +#define IGNORE_DEVICE BIT(3) +#define QUIRK_CONTROL_LINE_STATE BIT(4) +#define CLEAR_HALT_CONDITIONS BIT(5) +#define SEND_ZERO_PACKET BIT(6) +#define DISABLE_ECHO BIT(7)