From: Anil Dongare <[email protected]>

- Pick the upstream patch [1] as mentioned in [2] and [3].
- To successfully apply the fixed commit, apply the dependent commits [4], 
which are
  included in v1.0.28.

[1] 
https://github.com/libusb/libusb/commit/bc0886173ea15b8cc9bba2918f58a97a7f185231
[2] https://security-tracker.debian.org/tracker/CVE-2026-23679.
[3] https://security-tracker.debian.org/tracker/CVE-2026-47104.
[4] 
https://github.com/libusb/libusb/commit/016a0de33ac94b19c7772d6c20fbea7fec23bf68

Signed-off-by: Anil Dongare <[email protected]>
---
 ...-2026-23679_CVE-2026-47104-dependent.patch | 46 ++++++++++
 .../CVE-2026-23679_CVE-2026-47104.patch       | 88 +++++++++++++++++++
 meta/recipes-support/libusb/libusb1_1.0.27.bb |  2 +
 3 files changed, 136 insertions(+)
 create mode 100644 
meta/recipes-support/libusb/libusb1/CVE-2026-23679_CVE-2026-47104-dependent.patch
 create mode 100644 
meta/recipes-support/libusb/libusb1/CVE-2026-23679_CVE-2026-47104.patch

diff --git 
a/meta/recipes-support/libusb/libusb1/CVE-2026-23679_CVE-2026-47104-dependent.patch
 
b/meta/recipes-support/libusb/libusb1/CVE-2026-23679_CVE-2026-47104-dependent.patch
new file mode 100644
index 0000000000..04f1e68426
--- /dev/null
+++ 
b/meta/recipes-support/libusb/libusb1/CVE-2026-23679_CVE-2026-47104-dependent.patch
@@ -0,0 +1,46 @@
+From 2c1bb758e3b61355f50df61b6eb474d90bec2fab Mon Sep 17 00:00:00 2001
+From: Sean McBride <[email protected]>
+Date: Sat, 3 Feb 2024 22:32:52 -0500
+Subject: [PATCH] descriptor: Fix potential offsetting of pointer by too
+ much
+
+This was checking that `size` is at least `LIBUSB_DT_CONFIG_SIZE` (9)
+bytes long, but then increments the pointer with `buf +=
+header.bLength`. That could end up pointing past of the end of the
+buffer. There is a subsequent check that would prevent dereferencing it,
+but it's still undefined behaviour to even create such a pointer.
+
+Add a check with a similar pattern as elsewhere in this file.
+
+CVE: CVE-2026-23679 CVE-2026-47104
+Upstream-Status: Backport 
[https://github.com/libusb/libusb/commit/016a0de33ac94b19c7772d6c20fbea7fec23bf68]
+
+Backport Changes:
+- The upstream version_nano.h bump is omitted because this is a security
+  backport to libusb 1.0.27, not a version upgrade.
+
+(cherry picked from commit 016a0de33ac94b19c7772d6c20fbea7fec23bf68)
+Signed-off-by: Anil Dongare <[email protected]>
+---
+ libusb/descriptor.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libusb/descriptor.c b/libusb/descriptor.c
+index 4623ad1..4862c69 100644
+--- a/libusb/descriptor.c
++++ b/libusb/descriptor.c
+@@ -1233,6 +1233,11 @@ static int parse_iad_array(struct libusb_context *ctx,
+                                header.bLength);
+                       return LIBUSB_ERROR_IO;
+               }
++              else if (header.bLength > size) {
++                      usbi_warn(ctx, "short config descriptor read %d/%u",
++                                        size, header.bLength);
++                      return LIBUSB_ERROR_IO;
++              }
+               if (header.bDescriptorType == LIBUSB_DT_INTERFACE_ASSOCIATION)
+                       iad_array->length++;
+               buf += header.bLength;
+-- 
+2.43.7
+
diff --git 
a/meta/recipes-support/libusb/libusb1/CVE-2026-23679_CVE-2026-47104.patch 
b/meta/recipes-support/libusb/libusb1/CVE-2026-23679_CVE-2026-47104.patch
new file mode 100644
index 0000000000..d868207e9a
--- /dev/null
+++ b/meta/recipes-support/libusb/libusb1/CVE-2026-23679_CVE-2026-47104.patch
@@ -0,0 +1,88 @@
+From 0735213e5118d5c9c732b7c891446b35e0d6b8d5 Mon Sep 17 00:00:00 2001
+From: MarkLee131 <[email protected]>
+Date: Sat, 25 Apr 2026 18:33:17 +0800
+Subject: [PATCH] descriptor: Fix two memory-safety bugs in malformed
+ config descriptor handling
+
+Two issues reachable from a malformed config descriptor returned by an
+attached USB device, both surfaced by the same libFuzzer + ASan run.
+
+1) parse_interface() reads bNumEndpoints from the interface descriptor and
+   increments usb_interface->num_altsetting before entering the inner loop
+   that skips class/vendor specific descriptors ahead of the endpoint
+   array. If that loop's bLength > size short-read branch fires, the
+   function returns before the endpoint array is allocated, leaving the
+   caller with bNumEndpoints > 0 and endpoint == NULL. libusb.h documents
+   endpoint as an array sized by bNumEndpoints, and the testlibusb and
+   xusb examples both iterate it accordingly, so a NULL deref follows.
+   Reset bNumEndpoints to 0 before returning so the invariant holds.
+
+2) The first-pass loop in parse_iad_array() compares header.bLength
+   against the original size argument instead of the remaining bytes,
+   so a single descriptor with bLength == size - 1 lets consumed reach
+   size - 1 and the next iteration enters with only one byte of buffer
+   left. The buf[1] read on the second line of the loop body lands one
+   byte past the malloc allocation that backs the descriptor data. The
+   sibling parsers parse_configuration() and parse_interface() in the
+   same file already use the remaining-bytes form. Switch the IAD parser
+   loop guard and bound check to match.
+
+Both code paths are reachable from public APIs (libusb_get_*_config_descriptor
+and libusb_get_*_interface_association_descriptors), with the malformed
+input supplied by the attached device. Minimal reproducers are 20 and
+9 bytes respectively.
+
+Fixes #1813
+
+CVE: CVE-2026-23679 CVE-2026-47104
+Upstream-Status: Backport 
[https://github.com/libusb/libusb/commit/bc0886173ea15b8cc9bba2918f58a97a7f185231]
+
+Backport Changes:
+- The upstream version_nano.h bump is omitted because this is a security
+  backport to libusb 1.0.27, not a version upgrade.
+
+Signed-off-by: MarkLee131 <[email protected]>
+(cherry picked from commit bc0886173ea15b8cc9bba2918f58a97a7f185231)
+Signed-off-by: Anil Dongare <[email protected]>
+---
+ libusb/descriptor.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/libusb/descriptor.c b/libusb/descriptor.c
+index 4862c69..97143bb 100644
+--- a/libusb/descriptor.c
++++ b/libusb/descriptor.c
+@@ -260,6 +260,10 @@ static int parse_interface(libusb_context *ctx,
+                               usbi_warn(ctx,
+                                         "short extra intf desc read %d/%u",
+                                         size, header->bLength);
++                              /* Keep the invariant: bNumEndpoints > 0 implies
++                               * endpoint != NULL. The endpoint array isn't
++                               * allocated yet on this early return. */
++                              ifp->bNumEndpoints = 0;
+                               return parsed;
+                       }
+ 
+@@ -1226,16 +1230,16 @@ static int parse_iad_array(struct libusb_context *ctx,
+ 
+       // First pass: Iterate through desc list, count number of IADs
+       iad_array->length = 0;
+-      while (consumed < size) {
++      while (size - consumed >= DESC_HEADER_LENGTH) {
+               parse_descriptor(buf, "bb", &header);
+               if (header.bLength < 2) {
+                       usbi_err(ctx, "invalid descriptor bLength %d",
+                                header.bLength);
+                       return LIBUSB_ERROR_IO;
+               }
+-              else if (header.bLength > size) {
++              else if (header.bLength > size - consumed) {
+                       usbi_warn(ctx, "short config descriptor read %d/%u",
+-                                        size, header.bLength);
++                                        size - consumed, header.bLength);
+                       return LIBUSB_ERROR_IO;
+               }
+               if (header.bDescriptorType == LIBUSB_DT_INTERFACE_ASSOCIATION)
+-- 
+2.43.7
+
diff --git a/meta/recipes-support/libusb/libusb1_1.0.27.bb 
b/meta/recipes-support/libusb/libusb1_1.0.27.bb
index 5bf854f95d..3c46330164 100644
--- a/meta/recipes-support/libusb/libusb1_1.0.27.bb
+++ b/meta/recipes-support/libusb/libusb1_1.0.27.bb
@@ -14,6 +14,8 @@ BBCLASSEXTEND = "native nativesdk"
 
 SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/libusb-${PV}.tar.bz2 \
            file://run-ptest \
+           file://CVE-2026-23679_CVE-2026-47104-dependent.patch \
+           file://CVE-2026-23679_CVE-2026-47104.patch \
            "
 
 GITHUB_BASE_URI = "https://github.com/libusb/libusb/releases";
-- 
2.42.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#239336): 
https://lists.openembedded.org/g/openembedded-core/message/239336
Mute This Topic: https://lists.openembedded.org/mt/119937341/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to