From patchwork Fri Feb 19 12:18:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 1442138 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=metanate.com header.i=@metanate.com header.a=rsa-sha256 header.s=stronger header.b=kwXH2igC; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DhrjW04ZTz9s1l for ; Fri, 19 Feb 2021 23:38:54 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4A1AC86C8E; Fri, 19 Feb 2021 12:38:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UecVuvEPT94n; Fri, 19 Feb 2021 12:38:51 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id ED36386C62; Fri, 19 Feb 2021 12:38:50 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 46AFA1BF364 for ; Fri, 19 Feb 2021 12:38:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 4087786934 for ; Fri, 19 Feb 2021 12:38:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UGaESFzb4Y0C for ; Fri, 19 Feb 2021 12:38:49 +0000 (UTC) X-Greylist: delayed 00:20:06 by SQLgrey-1.7.6 Received: from metanate.com (dougal.metanate.com [90.155.101.14]) by fraxinus.osuosl.org (Postfix) with ESMTPS id EA54B81A1D for ; Fri, 19 Feb 2021 12:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Content-Type:Reply-To:Content-ID:Content-Description: In-Reply-To:References; bh=ilX2NeE4jXE+Q95rlKcEamTQOkE/fPk5VQAgJOe2GHw=; b=kw XH2igCFg0UzScaNdAmh11r6sLUCDRVWm0YchyIDaOd2pAgkCDClP64k/gxZ2S1iETofzBGoqAZS1H QZ/oI6Qkkj4pDdU80PtfN+tQ8UFnFbfaxZT3flHmzaiZorLRBJNFKmZgl/504In2giB4keQdqo1Qw p6KUkDjGSp+jcgGGRgCi08yMV+vW/rJczKfMsW9NrWkudlR8FsWFIRJEi2QgyX0LiZ53R8W+Eb+Zb 7Ef5BDIEV0M/+APtRQTHg3BhGyVs6ON7QzOzdJF5BvlKEEHLMihZKSNlO+fnp9AK8Dyau3ghs4gkI GbZzhRy4liMHopxpfVxgeQ3fKvmHpH/w==; Received: from [81.174.171.191] (helo=donbot.metanate.com) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lD4k1-0002H0-H4; Fri, 19 Feb 2021 12:18:37 +0000 From: John Keeping To: buildroot@buildroot.org Date: Fri, 19 Feb 2021 12:18:27 +0000 Message-Id: <20210219121827.3895308-1-john@metanate.com> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 X-Authenticated: YES Subject: [Buildroot] [PATCH] package/libusb: apply upstream patch to fix descriptor parsing X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zoltan Gyarmati , John Keeping Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" v1.0.24 of libusb has a bug in the Linux backend where it fails to enumerate any device with more than one configuration. Backport the upstream patch which fixes this as otherwise libusb based applications are unable to communicate with any devices advertising more than one configuration. Signed-off-by: John Keeping --- ...parsing-of-descriptors-for-multi-con.patch | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 package/libusb/0001-linux_usbfs-Fix-parsing-of-descriptors-for-multi-con.patch diff --git a/package/libusb/0001-linux_usbfs-Fix-parsing-of-descriptors-for-multi-con.patch b/package/libusb/0001-linux_usbfs-Fix-parsing-of-descriptors-for-multi-con.patch new file mode 100644 index 0000000000..601b322e54 --- /dev/null +++ b/package/libusb/0001-linux_usbfs-Fix-parsing-of-descriptors-for-multi-con.patch @@ -0,0 +1,62 @@ +From 623e2a995d156e115c91f56a3ec691bdc333df8b Mon Sep 17 00:00:00 2001 +From: Chris Dickens +Date: Sun, 13 Dec 2020 15:49:19 -0800 +Subject: [PATCH 1/1] linux_usbfs: Fix parsing of descriptors for + multi-configuration devices + +Commit e2be556bd2 ("linux_usbfs: Parse config descriptors during device +initialization") introduced a regression for devices with multiple +configurations. The logic that verifies the reported length of the +configuration descriptors failed to count the length of the +configuration descriptor itself and would truncate the actual length by +9 bytes, leading to a parsing error for subsequent descriptors. + +Closes #825 + +Signed-off-by: Chris Dickens +(cherry picked from commit f6d2cb561402c3b6d3627c0eb89e009b503d9067) +Signed-off-by: John Keeping +--- + libusb/os/linux_usbfs.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c +index fb2ed53..4d2dc8d 100644 +--- a/libusb/os/linux_usbfs.c ++++ b/libusb/os/linux_usbfs.c +@@ -641,7 +641,12 @@ static int seek_to_next_config(struct libusb_context *ctx, + uint8_t *buffer, size_t len) + { + struct usbi_descriptor_header *header; +- int offset = 0; ++ int offset; ++ ++ /* Start seeking past the config descriptor */ ++ offset = LIBUSB_DT_CONFIG_SIZE; ++ buffer += LIBUSB_DT_CONFIG_SIZE; ++ len -= LIBUSB_DT_CONFIG_SIZE; + + while (len > 0) { + if (len < 2) { +@@ -718,7 +723,7 @@ static int parse_config_descriptors(struct libusb_device *dev) + } + + if (priv->sysfs_dir) { +- /* ++ /* + * In sysfs wTotalLength is ignored, instead the kernel returns a + * config descriptor with verified bLength fields, with descriptors + * with an invalid bLength removed. +@@ -727,8 +732,7 @@ static int parse_config_descriptors(struct libusb_device *dev) + int offset; + + if (num_configs > 1 && idx < num_configs - 1) { +- offset = seek_to_next_config(ctx, buffer + LIBUSB_DT_CONFIG_SIZE, +- remaining - LIBUSB_DT_CONFIG_SIZE); ++ offset = seek_to_next_config(ctx, buffer, remaining); + if (offset < 0) + return offset; + sysfs_config_len = (uint16_t)offset; +-- +2.30.1 +