diff mbox series

[walnascar] binutils: Fix CVE-2025-7546

Message ID 20250716123455.901574-1-Yash.Shinde@windriver.com
State Under Review
Delegated to: Steve Sakoman
Headers show
Series [walnascar] binutils: Fix CVE-2025-7546 | expand

Commit Message

Yash Shinde July 16, 2025, 12:34 p.m. UTC
From: Yash Shinde <Yash.Shinde@windriver.com>

Report corrupted group section instead of trying to recover.

CVE: CVE-2025-7546
Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=41461010eb7c79fee7a9d5f6209accdaac66cc6b]
PR  33050 [https://sourceware.org/bugzilla/show_bug.cgi?id=33050]

Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
---
 .../binutils/binutils-2.44.inc                |  1 +
 .../binutils/0018-CVE-2025-7546.patch         | 58 +++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 meta/recipes-devtools/binutils/binutils/0018-CVE-2025-7546.patch

Comments

Khem Raj July 17, 2025, 1:32 a.m. UTC | #1
LGTM

On Wed, Jul 16, 2025 at 5:45 AM Yash Shinde via lists.openembedded.org
<Yash.Shinde=windriver.com@lists.openembedded.org> wrote:
>
> From: Yash Shinde <Yash.Shinde@windriver.com>
>
> Report corrupted group section instead of trying to recover.
>
> CVE: CVE-2025-7546
> Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=41461010eb7c79fee7a9d5f6209accdaac66cc6b]
> PR  33050 [https://sourceware.org/bugzilla/show_bug.cgi?id=33050]
>
> Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
> ---
>  .../binutils/binutils-2.44.inc                |  1 +
>  .../binutils/0018-CVE-2025-7546.patch         | 58 +++++++++++++++++++
>  2 files changed, 59 insertions(+)
>  create mode 100644 meta/recipes-devtools/binutils/binutils/0018-CVE-2025-7546.patch
>
> diff --git a/meta/recipes-devtools/binutils/binutils-2.44.inc b/meta/recipes-devtools/binutils/binutils-2.44.inc
> index e5df62b14e..3c32ad6cc2 100644
> --- a/meta/recipes-devtools/binutils/binutils-2.44.inc
> +++ b/meta/recipes-devtools/binutils/binutils-2.44.inc
> @@ -42,5 +42,6 @@ SRC_URI = "\
>       file://0017-CVE-2025-1181-2.patch \
>       file://0016-CVE-2025-5244.patch \
>       file://0016-CVE-2025-3198.patch \
> +     file://0018-CVE-2025-7546.patch \
>  "
>  S  = "${WORKDIR}/git"
> diff --git a/meta/recipes-devtools/binutils/binutils/0018-CVE-2025-7546.patch b/meta/recipes-devtools/binutils/binutils/0018-CVE-2025-7546.patch
> new file mode 100644
> index 0000000000..23c38091a2
> --- /dev/null
> +++ b/meta/recipes-devtools/binutils/binutils/0018-CVE-2025-7546.patch
> @@ -0,0 +1,58 @@
> +From 41461010eb7c79fee7a9d5f6209accdaac66cc6b Mon Sep 17 00:00:00 2001
> +From: "H.J. Lu" <hjl.tools@gmail.com>
> +Date: Sat, 21 Jun 2025 06:52:00 +0800
> +Subject: [PATCH] elf: Report corrupted group section
> +
> +Report corrupted group section instead of trying to recover.
> +
> +       PR binutils/33050
> +       * elf.c (bfd_elf_set_group_contents): Report corrupted group
> +       section.
> +
> +Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=41461010eb7c79fee7a9d5f6209accdaac66cc6b]
> +CVE: CVE-2025-7546
> +
> +Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> +Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
> +---
> + bfd/elf.c | 23 ++++++++++-------------
> + 1 file changed, 10 insertions(+), 13 deletions(-)
> +
> +diff --git a/bfd/elf.c b/bfd/elf.c
> +index 14ce15c7254..ee894eb05f2 100644
> +--- a/bfd/elf.c
> ++++ b/bfd/elf.c
> +@@ -3971,20 +3971,17 @@ bfd_elf_set_group_contents (bfd *abfd, asection *sec, void *failedptrarg)
> +       break;
> +     }
> +
> +-  /* We should always get here with loc == sec->contents + 4, but it is
> +-     possible to craft bogus SHT_GROUP sections that will cause segfaults
> +-     in objcopy without checking loc here and in the loop above.  */
> +-  if (loc == sec->contents)
> +-    BFD_ASSERT (0);
> +-  else
> ++  /* We should always get here with loc == sec->contents + 4.  Return
> ++     an error for bogus SHT_GROUP sections.  */
> ++  loc -= 4;
> ++  if (loc != sec->contents)
> +     {
> +-      loc -= 4;
> +-      if (loc != sec->contents)
> +-      {
> +-        BFD_ASSERT (0);
> +-        memset (sec->contents + 4, 0, loc - sec->contents);
> +-        loc = sec->contents;
> +-      }
> ++      /* xgettext:c-format */
> ++      _bfd_error_handler (_("%pB: corrupted group section: `%pA'"),
> ++                        abfd, sec);
> ++      bfd_set_error (bfd_error_bad_value);
> ++      *failedptr = true;
> ++      return;
> +     }
> +
> +   H_PUT_32 (abfd, sec->flags & SEC_LINK_ONCE ? GRP_COMDAT : 0, loc);
> +--
> +2.43.5
> +
> --
> 2.49.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#220450): https://lists.openembedded.org/g/openembedded-core/message/220450
> Mute This Topic: https://lists.openembedded.org/mt/114183822/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/recipes-devtools/binutils/binutils-2.44.inc b/meta/recipes-devtools/binutils/binutils-2.44.inc
index e5df62b14e..3c32ad6cc2 100644
--- a/meta/recipes-devtools/binutils/binutils-2.44.inc
+++ b/meta/recipes-devtools/binutils/binutils-2.44.inc
@@ -42,5 +42,6 @@  SRC_URI = "\
      file://0017-CVE-2025-1181-2.patch \
      file://0016-CVE-2025-5244.patch \
      file://0016-CVE-2025-3198.patch \
+     file://0018-CVE-2025-7546.patch \
 "
 S  = "${WORKDIR}/git"
diff --git a/meta/recipes-devtools/binutils/binutils/0018-CVE-2025-7546.patch b/meta/recipes-devtools/binutils/binutils/0018-CVE-2025-7546.patch
new file mode 100644
index 0000000000..23c38091a2
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils/0018-CVE-2025-7546.patch
@@ -0,0 +1,58 @@ 
+From 41461010eb7c79fee7a9d5f6209accdaac66cc6b Mon Sep 17 00:00:00 2001
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Sat, 21 Jun 2025 06:52:00 +0800
+Subject: [PATCH] elf: Report corrupted group section
+
+Report corrupted group section instead of trying to recover.
+
+	PR binutils/33050
+	* elf.c (bfd_elf_set_group_contents): Report corrupted group
+	section.
+
+Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=41461010eb7c79fee7a9d5f6209accdaac66cc6b]
+CVE: CVE-2025-7546
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
+---
+ bfd/elf.c | 23 ++++++++++-------------
+ 1 file changed, 10 insertions(+), 13 deletions(-)
+
+diff --git a/bfd/elf.c b/bfd/elf.c
+index 14ce15c7254..ee894eb05f2 100644
+--- a/bfd/elf.c
++++ b/bfd/elf.c
+@@ -3971,20 +3971,17 @@ bfd_elf_set_group_contents (bfd *abfd, asection *sec, void *failedptrarg)
+ 	break;
+     }
+ 
+-  /* We should always get here with loc == sec->contents + 4, but it is
+-     possible to craft bogus SHT_GROUP sections that will cause segfaults
+-     in objcopy without checking loc here and in the loop above.  */
+-  if (loc == sec->contents)
+-    BFD_ASSERT (0);
+-  else
++  /* We should always get here with loc == sec->contents + 4.  Return
++     an error for bogus SHT_GROUP sections.  */
++  loc -= 4;
++  if (loc != sec->contents)
+     {
+-      loc -= 4;
+-      if (loc != sec->contents)
+-	{
+-	  BFD_ASSERT (0);
+-	  memset (sec->contents + 4, 0, loc - sec->contents);
+-	  loc = sec->contents;
+-	}
++      /* xgettext:c-format */
++      _bfd_error_handler (_("%pB: corrupted group section: `%pA'"),
++			  abfd, sec);
++      bfd_set_error (bfd_error_bad_value);
++      *failedptr = true;
++      return;
+     }
+ 
+   H_PUT_32 (abfd, sec->flags & SEC_LINK_ONCE ? GRP_COMDAT : 0, loc);
+-- 
+2.43.5
+