binutils: Fix CVE-2025-5244

PR32858 ld segfault on fuzzed object
We missed one place where it is necessary to check for empty groups.

Backport a patch from upstream to fix CVE-2025-5244
Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=d1458933830456e54223d9fc61f0d9b3a19256f5]

(From OE-Core rev: 81e5831ea48e9d1e4b37e4ef6af11d382d7f1df8)

Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
This commit is contained in:
Deepesh Varatharajan
2025-06-05 01:51:56 -07:00
committed by Steve Sakoman
parent dd4d53ffa1
commit 8119405fb0
2 changed files with 26 additions and 0 deletions

View File

@@ -40,5 +40,6 @@ SRC_URI = "\
file://CVE-2025-1182.patch \
file://0016-CVE-2025-1181-1.patch \
file://0017-CVE-2025-1181-2.patch \
file://0016-CVE-2025-5244.patch \
"
S = "${WORKDIR}/git"

View File

@@ -0,0 +1,25 @@
From: Alan Modra <amodra@gmail.com>
Date: Thu, 10 Apr 2025 19:41:49 +0930
Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=d1458933830456e54223d9fc61f0d9b3a19256f5]
CVE: CVE-2025-5244
PR32858 ld segfault on fuzzed object
We missed one place where it is necessary to check for empty groups.
Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
diff --git a/bfd/elflink.c b/bfd/elflink.c
index a76e8e38da7..549b7b7dd92 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -14408,7 +14408,8 @@ elf_gc_sweep (bfd *abfd, struct bfd_link_info *info)
if (o->flags & SEC_GROUP)
{
asection *first = elf_next_in_group (o);
- o->gc_mark = first->gc_mark;
+ if (first != NULL)
+ o->gc_mark = first->gc_mark;
}
if (o->gc_mark)