summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/files
diff options
context:
space:
mode:
authorHitendra Prajapati <hprajapati@mvista.com>2025-02-28 11:44:11 +0530
committerSteve Sakoman <steve@sakoman.com>2025-03-04 08:46:02 -0800
commit9c934f60ce05ba23e9ecaa1e5d540b3baae9a540 (patch)
treeea11c12bec45df51adbca1e5733b636fbdadaa73 /meta/recipes-devtools/elfutils/files
parent4e4cac541dce6e574d7b3805b782a5a979e6802f (diff)
downloadpoky-9c934f60ce05ba23e9ecaa1e5d540b3baae9a540.tar.gz
elfutils: Fix multiple CVEs
Backport fixes for: * CVE-2025-1352 - Upstream-Status: Backport from https://sourceware.org/git/?p=elfutils.git;a=commit;h=2636426a091bd6c6f7f02e49ab20d4cdc6bfc753 * CVE-2025-1372 - Upstream-Status: Backport from https://sourceware.org/git/?p=elfutils.git;a=commit;h=73db9d2021cab9e23fd734b0a76a612d52a6f1db (From OE-Core rev: 8ea258ad9c83be5d9548a796f7dda4ac820fc435) Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-devtools/elfutils/files')
-rw-r--r--meta/recipes-devtools/elfutils/files/CVE-2025-1352.patch153
-rw-r--r--meta/recipes-devtools/elfutils/files/CVE-2025-1372.patch50
2 files changed, 203 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/files/CVE-2025-1352.patch b/meta/recipes-devtools/elfutils/files/CVE-2025-1352.patch
new file mode 100644
index 0000000000..ac56a3d2a5
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/CVE-2025-1352.patch
@@ -0,0 +1,153 @@
1From 2636426a091bd6c6f7f02e49ab20d4cdc6bfc753 Mon Sep 17 00:00:00 2001
2From: Mark Wielaard <mark@klomp.org>
3Date: Sat, 8 Feb 2025 20:00:12 +0100
4Subject: [PATCH] libdw: Simplify __libdw_getabbrev and fix dwarf_offabbrev
5 issue
6
7__libdw_getabbrev could crash on reading a bad abbrev by trying to
8deallocate memory it didn't allocate itself. This could happen because
9dwarf_offabbrev would supply its own memory when calling
10__libdw_getabbrev. No other caller did this.
11
12Simplify the __libdw_getabbrev common code by not taking external
13memory to put the abbrev result in (this would also not work correctly
14if the abbrev was already cached). And make dwarf_offabbrev explicitly
15copy the result (if there was no error or end of abbrev).
16
17 * libdw/dwarf_getabbrev.c (__libdw_getabbrev): Don't take
18 Dwarf_Abbrev result argument. Always just allocate abb when
19 abbrev not found in cache.
20 (dwarf_getabbrev): Don't pass NULL as last argument to
21 __libdw_getabbrev.
22 * libdw/dwarf_tag.c (__libdw_findabbrev): Likewise.
23 * libdw/dwarf_offabbrev.c (dwarf_offabbrev): Likewise. And copy
24 abbrev into abbrevp on success.
25 * libdw/libdw.h (dwarf_offabbrev): Document return values.
26 * libdw/libdwP.h (__libdw_getabbrev): Don't take Dwarf_Abbrev
27 result argument.
28
29https://sourceware.org/bugzilla/show_bug.cgi?id=32650
30
31Signed-off-by: Mark Wielaard <mark@klomp.org>
32
33Upstream-Status: Backport [https://sourceware.org/git/?p=elfutils.git;a=commitdiff;h=2636426a091bd6c6f7f02e49ab20d4cdc6bfc753]
34CVE: CVE-2025-1352
35Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
36---
37 libdw/dwarf_getabbrev.c | 12 ++++--------
38 libdw/dwarf_offabbrev.c | 10 +++++++---
39 libdw/dwarf_tag.c | 3 +--
40 libdw/libdw.h | 4 +++-
41 libdw/libdwP.h | 3 +--
42 5 files changed, 16 insertions(+), 16 deletions(-)
43
44diff --git a/libdw/dwarf_getabbrev.c b/libdw/dwarf_getabbrev.c
45index 13bee49..b19edfe 100644
46--- a/libdw/dwarf_getabbrev.c
47+++ b/libdw/dwarf_getabbrev.c
48@@ -1,5 +1,6 @@
49 /* Get abbreviation at given offset.
50 Copyright (C) 2003, 2004, 2005, 2006, 2014, 2017 Red Hat, Inc.
51+ Copyright (C) 2025 Mark J. Wielaard <mark@klomp.org>
52 This file is part of elfutils.
53 Written by Ulrich Drepper <drepper@redhat.com>, 2003.
54
55@@ -38,7 +39,7 @@
56 Dwarf_Abbrev *
57 internal_function
58 __libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu, Dwarf_Off offset,
59- size_t *lengthp, Dwarf_Abbrev *result)
60+ size_t *lengthp)
61 {
62 /* Don't fail if there is not .debug_abbrev section. */
63 if (dbg->sectiondata[IDX_debug_abbrev] == NULL)
64@@ -84,12 +85,7 @@ __libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu, Dwarf_Off offset,
65 Dwarf_Abbrev *abb = NULL;
66 if (cu == NULL
67 || (abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code)) == NULL)
68- {
69- if (result == NULL)
70- abb = libdw_typed_alloc (dbg, Dwarf_Abbrev);
71- else
72- abb = result;
73- }
74+ abb = libdw_typed_alloc (dbg, Dwarf_Abbrev);
75 else
76 {
77 foundit = true;
78@@ -182,5 +178,5 @@ dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset, size_t *lengthp)
79 return NULL;
80 }
81
82- return __libdw_getabbrev (dbg, cu, abbrev_offset + offset, lengthp, NULL);
83+ return __libdw_getabbrev (dbg, cu, abbrev_offset + offset, lengthp);
84 }
85diff --git a/libdw/dwarf_offabbrev.c b/libdw/dwarf_offabbrev.c
86index 27cdad6..41df69b 100644
87--- a/libdw/dwarf_offabbrev.c
88+++ b/libdw/dwarf_offabbrev.c
89@@ -41,11 +41,15 @@ dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp,
90 if (dbg == NULL)
91 return -1;
92
93- Dwarf_Abbrev *abbrev = __libdw_getabbrev (dbg, NULL, offset, lengthp,
94- abbrevp);
95+ Dwarf_Abbrev *abbrev = __libdw_getabbrev (dbg, NULL, offset, lengthp);
96
97 if (abbrev == NULL)
98 return -1;
99
100- return abbrev == DWARF_END_ABBREV ? 1 : 0;
101+ if (abbrev == DWARF_END_ABBREV)
102+ return 1;
103+
104+ *abbrevp = *abbrev;
105+
106+ return 0;
107 }
108diff --git a/libdw/dwarf_tag.c b/libdw/dwarf_tag.c
109index d784970..218382a 100644
110--- a/libdw/dwarf_tag.c
111+++ b/libdw/dwarf_tag.c
112@@ -53,8 +53,7 @@ __libdw_findabbrev (struct Dwarf_CU *cu, unsigned int code)
113
114 /* Find the next entry. It gets automatically added to the
115 hash table. */
116- abb = __libdw_getabbrev (cu->dbg, cu, cu->last_abbrev_offset, &length,
117- NULL);
118+ abb = __libdw_getabbrev (cu->dbg, cu, cu->last_abbrev_offset, &length);
119 if (abb == NULL || abb == DWARF_END_ABBREV)
120 {
121 /* Make sure we do not try to search for it again. */
122diff --git a/libdw/libdw.h b/libdw/libdw.h
123index 64d1689..829cc21 100644
124--- a/libdw/libdw.h
125+++ b/libdw/libdw.h
126@@ -587,7 +587,9 @@ extern int dwarf_srclang (Dwarf_Die *die);
127 extern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset,
128 size_t *lengthp);
129
130-/* Get abbreviation at given offset in .debug_abbrev section. */
131+/* Get abbreviation at given offset in .debug_abbrev section. On
132+ success return zero and fills in ABBREVP. When there is no (more)
133+ abbrev at offset returns one. On error returns a negative value. */
134 extern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp,
135 Dwarf_Abbrev *abbrevp)
136 __nonnull_attribute__ (4);
137diff --git a/libdw/libdwP.h b/libdw/libdwP.h
138index 360ad01..05b8364 100644
139--- a/libdw/libdwP.h
140+++ b/libdw/libdwP.h
141@@ -673,8 +673,7 @@ extern Dwarf_Abbrev *__libdw_findabbrev (struct Dwarf_CU *cu,
142
143 /* Get abbreviation at given offset. */
144 extern Dwarf_Abbrev *__libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu,
145- Dwarf_Off offset, size_t *lengthp,
146- Dwarf_Abbrev *result)
147+ Dwarf_Off offset, size_t *lengthp)
148 __nonnull_attribute__ (1) internal_function;
149
150 /* Get abbreviation of given DIE, and optionally set *READP to the DIE memory
151--
1522.25.1
153
diff --git a/meta/recipes-devtools/elfutils/files/CVE-2025-1372.patch b/meta/recipes-devtools/elfutils/files/CVE-2025-1372.patch
new file mode 100644
index 0000000000..b60eba4201
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/CVE-2025-1372.patch
@@ -0,0 +1,50 @@
1From 73db9d2021cab9e23fd734b0a76a612d52a6f1db Mon Sep 17 00:00:00 2001
2From: Mark Wielaard <mark@klomp.org>
3Date: Sun, 9 Feb 2025 00:07:39 +0100
4Subject: [PATCH] readelf: Skip trying to uncompress sections without a name
5
6When combining eu-readelf -z with -x or -p to dump the data or strings
7in an (corrupted ELF) unnamed numbered section eu-readelf could crash
8trying to check whether the section name starts with .zdebug. Fix this
9by skipping sections without a name.
10
11 * src/readelf.c (dump_data_section): Don't try to gnu decompress a
12 section without a name.
13 (print_string_section): Likewise.
14
15https://sourceware.org/bugzilla/show_bug.cgi?id=32656
16
17Signed-off-by: Mark Wielaard <mark@klomp.org>
18
19Upstream-Status: Backport [https://sourceware.org/git/?p=elfutils.git;a=commit;h=73db9d2021cab9e23fd734b0a76a612d52a6f1db]
20CVE: CVE-2025-1372
21Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
22---
23 src/readelf.c | 4 ++--
24 1 file changed, 2 insertions(+), 2 deletions(-)
25
26diff --git a/src/readelf.c b/src/readelf.c
27index 256165d..48eee26 100644
28--- a/src/readelf.c
29+++ b/src/readelf.c
30@@ -12719,7 +12719,7 @@ dump_data_section (Elf_Scn *scn, const GElf_Shdr *shdr, const char *name)
31 _("Couldn't uncompress section"),
32 elf_ndxscn (scn));
33 }
34- else if (startswith (name, ".zdebug"))
35+ else if (name && startswith (name, ".zdebug"))
36 {
37 if (elf_compress_gnu (scn, 0, 0) < 0)
38 printf ("WARNING: %s [%zd]\n",
39@@ -12770,7 +12770,7 @@ print_string_section (Elf_Scn *scn, const GElf_Shdr *shdr, const char *name)
40 _("Couldn't uncompress section"),
41 elf_ndxscn (scn));
42 }
43- else if (startswith (name, ".zdebug"))
44+ else if (name && startswith (name, ".zdebug"))
45 {
46 if (elf_compress_gnu (scn, 0, 0) < 0)
47 printf ("WARNING: %s [%zd]\n",
48--
492.25.1
50