Skip to contentSkip to conversation

binutils: Fix CVE-2025-69646

PATCH In review [email protected] 2 participants 4 messages Apr 20 – Jun 18

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 binutils: Fix CVE-2025-69646

From: Harish Sadineni <[email protected]>

CVE: CVE-2025-69646

PR 33638
* dwarf.c (display_debug_rnglists_list): Return bool. Rename "inital_length" to plain "length". Verify length is large enough to read header. Limit length to rest of section. Similarly limit offset_entry_count. (display_debug_ranges): Check display_debug_rnglists_unit_header return status. Stop output on error.

Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=598704a00cbac5e85c2bedd363357b5bf6fcee33]

---
 .../binutils/binutils-2.42.inc                |   1 +
 .../binutils/0031-CVE-2025-69646.patch        | 187 ++++++++++++++++++
 2 files changed, 188 insertions(+)
 create mode 100644 meta/recipes-devtools/binutils/binutils/0031-CVE-2025-69646.patch
meta/recipes-devtools/binutils/binutils-2.42.inc +1 -0
index 839d31242e..beeb758b64 100644
@@ -69,5 +69,6 @@ SRC_URI = "\
      file://0028-CVE-2025-11494.patch \
      file://0029-CVE-2025-11839.patch \
      file://0030-CVE-2025-11840.patch \
+     file://0031-CVE-2025-69646.patch \
 "
 S  = "${WORKDIR}/git"
meta/recipes-devtools/binutils/binutils/0031-CVE-2025-69646.patch new file +187 -0

187 lines not on this page · raw message

Signature · 1 line
2.49.0
#1 lore raw
Quoted 12 lines · Harish via lists.openembedded.org Sadineni

From: Harish Sadineni <[email protected]>

CVE: CVE-2025-69646

PR 33638
* dwarf.c (display_debug_rnglists_list): Return bool. Rename "inital_length" to plain "length". Verify length is large enough to read header. Limit length to rest of section. Similarly limit offset_entry_count. (display_debug_ranges): Check display_debug_rnglists_unit_header return status. Stop output on error.

Quoted 4 lines

Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=598704a00cbac5e85c2bedd363357b5bf6fcee33]

---

Hello Harish,

This patch was lost for a time, my fault, sorry.

Now, when I try to apply it, do_patch fails for binutils. Could you rebase on the latest scarthgap and send a v2?

Thanks!

Quoted 209 lines
 .../binutils/binutils-2.42.inc                |   1 +
 .../binutils/0031-CVE-2025-69646.patch        | 187 ++++++++++++++++++
 2 files changed, 188 insertions(+)
 create mode 100644 meta/recipes-devtools/binutils/binutils/0031-CVE-2025-69646.patch
meta/recipes-devtools/binutils/binutils-2.42.inc +1 -0
index 839d31242e..beeb758b64 100644
@@ -69,5 +69,6 @@ SRC_URI = "\
      file://0028-CVE-2025-11494.patch \
      file://0029-CVE-2025-11839.patch \
      file://0030-CVE-2025-11840.patch \
+     file://0031-CVE-2025-69646.patch \
 "
 S  = "${WORKDIR}/git"
meta/recipes-devtools/binutils/binutils/0031-CVE-2025-69646.patch new file +187 -0
new file mode 100644
index 0000000000..42b0b858cc
@@ -0,0 +1,187 @@
+From 598704a00cbac5e85c2bedd363357b5bf6fcee33 Mon Sep 17 00:00:00 2001
+From: Alan Modra <[email protected]>
+Date: Sat, 22 Nov 2025 09:22:10 +1030
+Subject: [PATCH] PR 33638, debug_rnglists output
+
+The fuzzed testcase in this PR continuously outputs an error about
+the debug_rnglists header.  Fixed by taking notice of the error and
+stopping output.  The patch also limits the length in all cases, not
+just when a relocation is present, and limits the offset entry count
+read from the header.  I removed the warning and the test for relocs
+because the code can't work reliably with unresolved relocs in the
+length field.
+
+	PR 33638
+	* dwarf.c (display_debug_rnglists_list): Return bool.  Rename
+	"inital_length" to plain "length".  Verify length is large
+	enough to read header.  Limit length to rest of section.
+	Similarly limit offset_entry_count.
+	(display_debug_ranges): Check display_debug_rnglists_unit_header
+	return status.  Stop output on error.
+
+Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=598704a00cbac5e85c2bedd363357b5bf6fcee33]
+CVE: CVE-2025-69646
+
+Signed-off-by: Harish Sadineni <[email protected]>
+---
+ binutils/dwarf.c | 67 ++++++++++++++++++++++++------------------------
+ 1 file changed, 34 insertions(+), 33 deletions(-)
+
+diff --git a/binutils/dwarf.c b/binutils/dwarf.c
+index 615e051b2bf..d718d97c771 100644
+--- a/binutils/dwarf.c
++++ b/binutils/dwarf.c
+@@ -8206,7 +8206,7 @@ display_debug_rnglists_list (unsigned char * start,
+   return start;
+ }
+ 
+-static int
++static bool
+ display_debug_rnglists_unit_header (struct dwarf_section *  section,
+ 				    uint64_t *              unit_offset,
+ 				    unsigned char *         poffset_size)
+@@ -8214,7 +8214,8 @@ display_debug_rnglists_unit_header (struct dwarf_section *  section,
+   uint64_t        start_offset = *unit_offset;
+   unsigned char * p = section->start + start_offset;
+   unsigned char * finish = section->start + section->size;
+-  uint64_t        initial_length;
++  unsigned char * hdr;
++  uint64_t        length;
+   unsigned char   segment_selector_size;
+   unsigned int    offset_entry_count;
+   unsigned int    i;
+@@ -8223,66 +8224,59 @@ display_debug_rnglists_unit_header (struct dwarf_section *  section,
+   unsigned char   offset_size;
+ 
+   /* Get and check the length of the block.  */
+-  SAFE_BYTE_GET_AND_INC (initial_length, p, 4, finish);
++  SAFE_BYTE_GET_AND_INC (length, p, 4, finish);
+ 
+-  if (initial_length == 0xffffffff)
++  if (length == 0xffffffff)
+     {
+       /* This section is 64-bit DWARF 3.  */
+-      SAFE_BYTE_GET_AND_INC (initial_length, p, 8, finish);
++      SAFE_BYTE_GET_AND_INC (length, p, 8, finish);
+       *poffset_size = offset_size = 8;
+     }
+   else
+     *poffset_size = offset_size = 4;
+ 
+-  if (initial_length > (size_t) (finish - p))
+-    {
+-      /* If the length field has a relocation against it, then we should
+-	 not complain if it is inaccurate (and probably negative).
+-	 It is copied from .debug_line handling code.  */
+-      if (reloc_at (section, (p - section->start) - offset_size))
+-	initial_length = finish - p;
+-      else
+-	{
+-	  warn (_("The length field (%#" PRIx64
+-		  ") in the debug_rnglists header is wrong"
+-		  " - the section is too small\n"),
+-		initial_length);
+-	  return 0;
+-	}
+-    }
+-
+-  /* Report the next unit offset to the caller.  */
+-  *unit_offset = (p - section->start) + initial_length;
++  if (length < 8)
++    return false;
+ 
+   /* Get the other fields in the header.  */
++  hdr = p;
+   SAFE_BYTE_GET_AND_INC (version, p, 2, finish);
+   SAFE_BYTE_GET_AND_INC (address_size, p, 1, finish);
+   SAFE_BYTE_GET_AND_INC (segment_selector_size, p, 1, finish);
+   SAFE_BYTE_GET_AND_INC (offset_entry_count, p, 4, finish);
+ 
+   printf (_(" Table at Offset: %#" PRIx64 ":\n"), start_offset);
+-  printf (_("  Length:          %#" PRIx64 "\n"), initial_length);
++  printf (_("  Length:          %#" PRIx64 "\n"), length);
+   printf (_("  DWARF version:   %u\n"), version);
+   printf (_("  Address size:    %u\n"), address_size);
+   printf (_("  Segment size:    %u\n"), segment_selector_size);
+   printf (_("  Offset entries:  %u\n"), offset_entry_count);
+ 
++  if (length > (size_t) (finish - hdr))
++    length = finish - hdr;
++
++  /* Report the next unit offset to the caller.  */
++  *unit_offset = (hdr - section->start) + length;
++
+   /* Check the fields.  */
+   if (segment_selector_size != 0)
+     {
+       warn (_("The %s section contains "
+ 	      "unsupported segment selector size: %d.\n"),
+ 	    section->name, segment_selector_size);
+-      return 0;
++      return false;
+     }
+ 
+   if (version < 5)
+     {
+       warn (_("Only DWARF version 5+ debug_rnglists info "
+ 	      "is currently supported.\n"));
+-      return 0;
++      return false;
+     }
+ 
++  uint64_t max_off_count = (length - 8) / offset_size;
++  if (offset_entry_count > max_off_count)
++    offset_entry_count = max_off_count;
+   if (offset_entry_count != 0)
+     {
+       printf (_("\n   Offsets starting at %#tx:\n"), p - section->start);
+@@ -8296,7 +8290,7 @@ display_debug_rnglists_unit_header (struct dwarf_section *  section,
+ 	}
+     }
+ 
+-  return 1;
++  return true;
+ }
+ 
+ static bool
+@@ -8327,6 +8321,7 @@ display_debug_ranges (struct dwarf_section *section,
+   uint64_t last_offset = 0;
+   uint64_t next_rnglists_cu_offset = 0;
+   unsigned char offset_size;
++  bool ok_header = true;
+ 
+   if (bytes == 0)
+     {
+@@ -8419,8 +8414,12 @@ display_debug_ranges (struct dwarf_section *section,
+       /* If we've moved on to the next compile unit in the rnglists section - dump the unit header(s).  */
+       if (is_rnglists && next_rnglists_cu_offset < offset)
+ 	{
+-	  while (next_rnglists_cu_offset < offset)
+-	    display_debug_rnglists_unit_header (section, &next_rnglists_cu_offset, &offset_size);
++	  while (ok_header && next_rnglists_cu_offset < offset)
++	    ok_header = display_debug_rnglists_unit_header (section,
++							    &next_rnglists_cu_offset,
++							    &offset_size);
++	  if (!ok_header)
++	    break;
+ 	  printf (_("    Offset   Begin    End\n"));
+ 	}
+ 
+@@ -8461,10 +8460,12 @@ display_debug_ranges (struct dwarf_section *section,
+     }
+ 
+   /* Display trailing empty (or unreferenced) compile units, if any.  */
+-  if (is_rnglists)
++  if (is_rnglists && ok_header)
+     while (next_rnglists_cu_offset < section->size)
+-      display_debug_rnglists_unit_header (section, &next_rnglists_cu_offset, &offset_size);
+-
++      if (!display_debug_rnglists_unit_header (section,
++					       &next_rnglists_cu_offset,
++					       &offset_size))
++	break;
+   putchar ('\n');
+ 
+   free (range_entries);
+-- 
+2.49.0
Signature · 2 lines
Yoann Congal
Smile ECS
#2 lore raw
Quoted 18 lines · Yoann Congal

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 14 lines · Harish via lists.openembedded.org Sadineni

From: Harish Sadineni <[email protected]>

CVE: CVE-2025-69646

PR 33638
* dwarf.c (display_debug_rnglists_list): Return bool. Rename "inital_length" to plain "length". Verify length is large enough to read header. Limit length to rest of section. Similarly limit offset_entry_count. (display_debug_ranges): Check display_debug_rnglists_unit_header return status. Stop output on error.

Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=598704a00cbac5e85c2bedd363357b5bf6fcee33]

Quoted 8 lines
Quoted 2 lines

---

Hello Harish,

This patch was lost for a time, my fault, sorry.

Now, when I try to apply it, do_patch fails for binutils. Could you rebase on the latest scarthgap and send a v2?

Hi Yoann,

CVE-2025-69648 is a duplicate of CVE-2025-69646.

The fix for CVE-2025-69648 has already been merged into Scarthgap, so the corresponding fix for CVE-2025-69646 is already present and no additional patch is required.

Thanks,
Harish

Quoted 217 lines

Thanks!

Quoted 199 lines
  .../binutils/binutils-2.42.inc                |   1 +
  .../binutils/0031-CVE-2025-69646.patch        | 187 ++++++++++++++++++
  2 files changed, 188 insertions(+)

create mode 100644 meta/recipes-devtools/binutils/binutils/0031-CVE-2025-69646.patch

meta/recipes-devtools/binutils/binutils-2.42.inc +1 -0
index 839d31242e..beeb758b64 100644
@@ -69,5 +69,6 @@ SRC_URI = "\
       file://0028-CVE-2025-11494.patch \
       file://0029-CVE-2025-11839.patch \
       file://0030-CVE-2025-11840.patch \
+     file://0031-CVE-2025-69646.patch \
  "
  S  = "${WORKDIR}/git"
meta/recipes-devtools/binutils/binutils/0031-CVE-2025-69646.patch new file +177 -0
new file mode 100644
index 0000000000..42b0b858cc
@@ -0,0 +1,187 @@
+From 598704a00cbac5e85c2bedd363357b5bf6fcee33 Mon Sep 17 00:00:00 2001
+From: Alan Modra <[email protected]>
+Date: Sat, 22 Nov 2025 09:22:10 +1030
+Subject: [PATCH] PR 33638, debug_rnglists output
+
+The fuzzed testcase in this PR continuously outputs an error about
+the debug_rnglists header.  Fixed by taking notice of the error and
+stopping output.  The patch also limits the length in all cases, not
+just when a relocation is present, and limits the offset entry count
+read from the header.  I removed the warning and the test for relocs
+because the code can't work reliably with unresolved relocs in the
+length field.
+
+     PR 33638
+     * dwarf.c (display_debug_rnglists_list): Return bool.  Rename
+     "inital_length" to plain "length".  Verify length is large
+     enough to read header.  Limit length to rest of section.
+     Similarly limit offset_entry_count.
+     (display_debug_ranges): Check display_debug_rnglists_unit_header
+     return status.  Stop output on error.
+
+Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=598704a00cbac5e85c2bedd363357b5bf6fcee33]
+CVE: CVE-2025-69646
+
+Signed-off-by: Harish Sadineni <[email protected]>
+---
+ binutils/dwarf.c | 67 ++++++++++++++++++++++++------------------------
+ 1 file changed, 34 insertions(+), 33 deletions(-)
+
+diff --git a/binutils/dwarf.c b/binutils/dwarf.c
+index 615e051b2bf..d718d97c771 100644
+--- a/binutils/dwarf.c
++++ b/binutils/dwarf.c
+@@ -8206,7 +8206,7 @@ display_debug_rnglists_list (unsigned char * start,
+   return start;
+ }
+
+-static int
++static bool
+ display_debug_rnglists_unit_header (struct dwarf_section *  section,
+                                 uint64_t *              unit_offset,
+                                 unsigned char *         poffset_size)
+@@ -8214,7 +8214,8 @@ display_debug_rnglists_unit_header (struct dwarf_section *  section,
+   uint64_t        start_offset = *unit_offset;
+   unsigned char * p = section->start + start_offset;
+   unsigned char * finish = section->start + section->size;
+-  uint64_t        initial_length;
++  unsigned char * hdr;
++  uint64_t        length;
+   unsigned char   segment_selector_size;
+   unsigned int    offset_entry_count;
+   unsigned int    i;
+@@ -8223,66 +8224,59 @@ display_debug_rnglists_unit_header (struct dwarf_section *  section,
+   unsigned char   offset_size;
+
+   /* Get and check the length of the block.  */
+-  SAFE_BYTE_GET_AND_INC (initial_length, p, 4, finish);
++  SAFE_BYTE_GET_AND_INC (length, p, 4, finish);
+
+-  if (initial_length == 0xffffffff)
++  if (length == 0xffffffff)
+     {
+       /* This section is 64-bit DWARF 3.  */
+-      SAFE_BYTE_GET_AND_INC (initial_length, p, 8, finish);
++      SAFE_BYTE_GET_AND_INC (length, p, 8, finish);
+       *poffset_size = offset_size = 8;
+     }
+   else
+     *poffset_size = offset_size = 4;
+
+-  if (initial_length > (size_t) (finish - p))
+-    {
+-      /* If the length field has a relocation against it, then we should
+-     not complain if it is inaccurate (and probably negative).
+-     It is copied from .debug_line handling code.  */
+-      if (reloc_at (section, (p - section->start) - offset_size))
+-    initial_length = finish - p;
+-      else
+-    {
+-      warn (_("The length field (%#" PRIx64
+-              ") in the debug_rnglists header is wrong"
+-              " - the section is too small\n"),
+-            initial_length);
+-      return 0;
+-    }
+-    }
+-
+-  /* Report the next unit offset to the caller.  */
+-  *unit_offset = (p - section->start) + initial_length;
++  if (length < 8)
++    return false;
+
+   /* Get the other fields in the header.  */
++  hdr = p;
+   SAFE_BYTE_GET_AND_INC (version, p, 2, finish);
+   SAFE_BYTE_GET_AND_INC (address_size, p, 1, finish);
+   SAFE_BYTE_GET_AND_INC (segment_selector_size, p, 1, finish);
+   SAFE_BYTE_GET_AND_INC (offset_entry_count, p, 4, finish);
+
+   printf (_(" Table at Offset: %#" PRIx64 ":\n"), start_offset);
+-  printf (_("  Length:          %#" PRIx64 "\n"), initial_length);
++  printf (_("  Length:          %#" PRIx64 "\n"), length);
+   printf (_("  DWARF version:   %u\n"), version);
+   printf (_("  Address size:    %u\n"), address_size);
+   printf (_("  Segment size:    %u\n"), segment_selector_size);
+   printf (_("  Offset entries:  %u\n"), offset_entry_count);
+
++  if (length > (size_t) (finish - hdr))
++    length = finish - hdr;
++
++  /* Report the next unit offset to the caller.  */
++  *unit_offset = (hdr - section->start) + length;
++
+   /* Check the fields.  */
+   if (segment_selector_size != 0)
+     {
+       warn (_("The %s section contains "
+           "unsupported segment selector size: %d.\n"),
+         section->name, segment_selector_size);
+-      return 0;
++      return false;
+     }
+
+   if (version < 5)
+     {
+       warn (_("Only DWARF version 5+ debug_rnglists info "
+           "is currently supported.\n"));
+-      return 0;
++      return false;
+     }
+
++  uint64_t max_off_count = (length - 8) / offset_size;
++  if (offset_entry_count > max_off_count)
++    offset_entry_count = max_off_count;
+   if (offset_entry_count != 0)
+     {
+       printf (_("\n   Offsets starting at %#tx:\n"), p - section->start);
+@@ -8296,7 +8290,7 @@ display_debug_rnglists_unit_header (struct dwarf_section *  section,
+     }
+     }
+
+-  return 1;
++  return true;
+ }
+
+ static bool
+@@ -8327,6 +8321,7 @@ display_debug_ranges (struct dwarf_section *section,
+   uint64_t last_offset = 0;
+   uint64_t next_rnglists_cu_offset = 0;
+   unsigned char offset_size;
++  bool ok_header = true;
+
+   if (bytes == 0)
+     {
+@@ -8419,8 +8414,12 @@ display_debug_ranges (struct dwarf_section *section,
+       /* If we've moved on to the next compile unit in the rnglists section - dump the unit header(s).  */
+       if (is_rnglists && next_rnglists_cu_offset < offset)
+     {
+-      while (next_rnglists_cu_offset < offset)
+-        display_debug_rnglists_unit_header (section, &next_rnglists_cu_offset, &offset_size);
++      while (ok_header && next_rnglists_cu_offset < offset)
++        ok_header = display_debug_rnglists_unit_header (section,
++                                                        &next_rnglists_cu_offset,
++                                                        &offset_size);
++      if (!ok_header)
++        break;
+       printf (_("    Offset   Begin    End\n"));
+     }
+
+@@ -8461,10 +8460,12 @@ display_debug_ranges (struct dwarf_section *section,
+     }
+
+   /* Display trailing empty (or unreferenced) compile units, if any.  */
+-  if (is_rnglists)
++  if (is_rnglists && ok_header)
+     while (next_rnglists_cu_offset < section->size)
+-      display_debug_rnglists_unit_header (section, &next_rnglists_cu_offset, &offset_size);

meta/recipes-devtools/binutils/binutils/0031-CVE-2025-69646.patch line 187

Quoted 10 lines
meta/recipes-devtools/binutils/binutils/0031-CVE-2025-69646.patch new file +10 -0
+-
++      if (!display_debug_rnglists_unit_header (section,
++                                           &next_rnglists_cu_offset,
++                                           &offset_size))
++    break;
+   putchar ('\n');
+
+   free (range_entries);
+--
+2.49.0

--
Yoann Congal
Smile ECS

#3 lore raw
Quoted 32 lines · Harish Sadineni
Quoted 2 lines · Yoann Congal

CAUTION: This email comes from a non Wind River email account! Do not click links or open attachments unless you recognize the sender

and know the content is safe.

Quoted 2 lines

On Mon Apr 20, 2026 at 6:24 AM CEST, Harish via lists.openembedded.org

Quoted 12 lines · Sadineni
Quoted 12 lines

From: Harish Sadineni <[email protected]>

CVE: CVE-2025-69646

PR 33638
* dwarf.c (display_debug_rnglists_list): Return bool. Rename "inital_length" to plain "length". Verify length is large enough to read header. Limit length to rest of section. Similarly limit offset_entry_count. (display_debug_ranges): Check display_debug_rnglists_unit_header return status. Stop output on error.

Quoted 1 line
Quoted 1 line

Upstream-Status: Backport [

https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=598704a00cbac5e85c2bedd363357b5bf6fcee33
]

Quoted 9 lines
Quoted 3 lines

---

Hello Harish,

This patch was lost for a time, my fault, sorry.

Now, when I try to apply it, do_patch fails for binutils. Could you rebase on the latest scarthgap and send a v2?

Quoted 8 lines

Hi Yoann,

CVE-2025-69648 is a duplicate of CVE-2025-69646.

The fix for CVE-2025-69648 has already been merged into Scarthgap, so the corresponding fix for CVE-2025-69646 is already present and no additional patch is required.

That explains the do_patch failure...

In that case, CVE-2025-69646 needs to be added to the "CVE: " line in
https://git.openembedded.org/openembedded-core/tree/meta/recipes-devtools/binutils/binutils/CVE-2025-69648.patch?h=scarthgap

What do you think? If that's correct, could you please send the patch for it?

Thanks!Could you handle it please?

Thanks,

Quoted 5 lines

Harish

Quoted 3 lines

Thanks!

[...]

Signature · 2 lines
Yoann Congal
Smile ECS