summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorHarish Sadineni <Harish.Sadineni@windriver.com>2025-05-29 05:12:02 -0700
committerSteve Sakoman <steve@sakoman.com>2025-06-04 09:06:31 -0700
commit6fceeca06718b8a84528ae86f406460a8d712a56 (patch)
tree2ae964c77119929829a4baa6e94f2e814ab0a004 /meta/recipes-devtools
parent14d260ab2503c75c78f2c4b1e0d6e8b6e287959b (diff)
downloadpoky-6fceeca06718b8a84528ae86f406460a8d712a56.tar.gz
binutils: fix CVE-2025-1180
Backporting the fix from PR 32636 to fix PR 32642 (ld SEGV (illegal read access) in _bfd_elf_write_section_eh_frame (bfd/elf-eh-frame.c:2234:29) with --gc-sections --gc-keep-exported option) https://nvd.nist.gov/vuln/detail/CVE-2025-1180 is associated with PR32642 which will get fixed with commit from PR 32636. Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=f9978defb6fab0bd8583942d97c112b0932ac814] CVE: CVE-2025-1180 (From OE-Core rev: 8178f44f18777b2c8acc0afb9fd43921a9a8e76e) Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/binutils/binutils-2.38.inc1
-rw-r--r--meta/recipes-devtools/binutils/binutils/0040-CVE-2025-1180.patch164
2 files changed, 165 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils-2.38.inc b/meta/recipes-devtools/binutils/binutils-2.38.inc
index 82dd5c9eb6..01fd03d2f4 100644
--- a/meta/recipes-devtools/binutils/binutils-2.38.inc
+++ b/meta/recipes-devtools/binutils/binutils-2.38.inc
@@ -74,5 +74,6 @@ SRC_URI = "\
74 file://0037-CVE-2024-53589.patch \ 74 file://0037-CVE-2024-53589.patch \
75 file://0038-CVE-2025-0840.patch \ 75 file://0038-CVE-2025-0840.patch \
76 file://0039-CVE-2025-1178.patch \ 76 file://0039-CVE-2025-1178.patch \
77 file://0040-CVE-2025-1180.patch \
77" 78"
78S = "${WORKDIR}/git" 79S = "${WORKDIR}/git"
diff --git a/meta/recipes-devtools/binutils/binutils/0040-CVE-2025-1180.patch b/meta/recipes-devtools/binutils/binutils/0040-CVE-2025-1180.patch
new file mode 100644
index 0000000000..a422f9d1ae
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils/0040-CVE-2025-1180.patch
@@ -0,0 +1,164 @@
1From 82670cebd1fcecfc16c075c1bd9ec404e3f9af41 Mon Sep 17 00:00:00 2001
2From: Nick Clifton <nickc@redhat.com>
3Date: Thu, 29 May 2025 02:41:27 -0700
4Subject: [PATCH] Prevent illegal memory access when indexing into the
5 sym_hashes array of the elf bfd cookie structure.
6
7PR 32636
8
9(cherry picked from commit: f9978defb6fab0bd8583942d97c112b0932ac814)
10
11Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=f9978defb6fab0bd8583942d97c112b0932ac814]
12CVE: CVE-2025-1180
13
14Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
15---
16 bfd/elflink.c | 90 ++++++++++++++++++++++++++-------------------------
17 1 file changed, 46 insertions(+), 44 deletions(-)
18
19diff --git a/bfd/elflink.c b/bfd/elflink.c
20index f8521426cad..4c21a0229e7 100644
21--- a/bfd/elflink.c
22+++ b/bfd/elflink.c
23@@ -62,15 +62,16 @@ struct elf_find_verdep_info
24 static bool _bfd_elf_fix_symbol_flags
25 (struct elf_link_hash_entry *, struct elf_info_failed *);
26
27-asection *
28-_bfd_elf_section_for_symbol (struct elf_reloc_cookie *cookie,
29- unsigned long r_symndx,
30- bool discard)
31+static struct elf_link_hash_entry *
32+get_ext_sym_hash (struct elf_reloc_cookie *cookie, unsigned long r_symndx)
33 {
34- if (r_symndx >= cookie->locsymcount
35- || ELF_ST_BIND (cookie->locsyms[r_symndx].st_info) != STB_LOCAL)
36+ struct elf_link_hash_entry *h = NULL;
37+
38+ if ((r_symndx >= cookie->locsymcount
39+ || ELF_ST_BIND (cookie->locsyms[r_symndx].st_info) != STB_LOCAL)
40+ /* Guard against corrupt input. See PR 32636 for an example. */
41+ && r_symndx >= cookie->extsymoff)
42 {
43- struct elf_link_hash_entry *h;
44
45 h = cookie->sym_hashes[r_symndx - cookie->extsymoff];
46
47@@ -78,6 +79,22 @@ _bfd_elf_section_for_symbol (struct elf_reloc_cookie *cookie,
48 || h->root.type == bfd_link_hash_warning)
49 h = (struct elf_link_hash_entry *) h->root.u.i.link;
50
51+ }
52+
53+ return h;
54+}
55+
56+asection *
57+_bfd_elf_section_for_symbol (struct elf_reloc_cookie *cookie,
58+ unsigned long r_symndx,
59+ bool discard)
60+{
61+ struct elf_link_hash_entry *h;
62+
63+ h = get_ext_sym_hash (cookie, r_symndx);
64+
65+ if (h != NULL)
66+ {
67 if ((h->root.type == bfd_link_hash_defined
68 || h->root.type == bfd_link_hash_defweak)
69 && discarded_section (h->root.u.def.section))
70@@ -85,21 +102,20 @@ _bfd_elf_section_for_symbol (struct elf_reloc_cookie *cookie,
71 else
72 return NULL;
73 }
74- else
75- {
76- /* It's not a relocation against a global symbol,
77- but it could be a relocation against a local
78- symbol for a discarded section. */
79- asection *isec;
80- Elf_Internal_Sym *isym;
81
82- /* Need to: get the symbol; get the section. */
83- isym = &cookie->locsyms[r_symndx];
84- isec = bfd_section_from_elf_index (cookie->abfd, isym->st_shndx);
85- if (isec != NULL
86- && discard ? discarded_section (isec) : 1)
87- return isec;
88- }
89+ /* It's not a relocation against a global symbol,
90+ but it could be a relocation against a local
91+ symbol for a discarded section. */
92+ asection *isec;
93+ Elf_Internal_Sym *isym;
94+
95+ /* Need to: get the symbol; get the section. */
96+ isym = &cookie->locsyms[r_symndx];
97+ isec = bfd_section_from_elf_index (cookie->abfd, isym->st_shndx);
98+ if (isec != NULL
99+ && discard ? discarded_section (isec) : 1)
100+ return isec;
101+
102 return NULL;
103 }
104
105@@ -13642,22 +13658,12 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec,
106 if (r_symndx == STN_UNDEF)
107 return NULL;
108
109- if (r_symndx >= cookie->locsymcount
110- || ELF_ST_BIND (cookie->locsyms[r_symndx].st_info) != STB_LOCAL)
111+ h = get_ext_sym_hash (cookie, r_symndx);
112+
113+ if (h != NULL)
114 {
115 bool was_marked;
116
117- h = cookie->sym_hashes[r_symndx - cookie->extsymoff];
118- if (h == NULL)
119- {
120- info->callbacks->einfo (_("%F%P: corrupt input: %pB\n"),
121- sec->owner);
122- return NULL;
123- }
124- while (h->root.type == bfd_link_hash_indirect
125- || h->root.type == bfd_link_hash_warning)
126- h = (struct elf_link_hash_entry *) h->root.u.i.link;
127-
128 was_marked = h->mark;
129 h->mark = 1;
130 /* Keep all aliases of the symbol too. If an object symbol
131@@ -14703,17 +14709,12 @@ bfd_elf_reloc_symbol_deleted_p (bfd_vma offset, void *cookie)
132 if (r_symndx == STN_UNDEF)
133 return true;
134
135- if (r_symndx >= rcookie->locsymcount
136- || ELF_ST_BIND (rcookie->locsyms[r_symndx].st_info) != STB_LOCAL)
137- {
138- struct elf_link_hash_entry *h;
139-
140- h = rcookie->sym_hashes[r_symndx - rcookie->extsymoff];
141-
142- while (h->root.type == bfd_link_hash_indirect
143- || h->root.type == bfd_link_hash_warning)
144- h = (struct elf_link_hash_entry *) h->root.u.i.link;
145+ struct elf_link_hash_entry *h;
146
147+ h = get_ext_sym_hash (rcookie, r_symndx);
148+
149+ if (h != NULL)
150+ {
151 if ((h->root.type == bfd_link_hash_defined
152 || h->root.type == bfd_link_hash_defweak)
153 && (h->root.u.def.section->owner != rcookie->abfd
154@@ -14737,6 +14738,7 @@ bfd_elf_reloc_symbol_deleted_p (bfd_vma offset, void *cookie)
155 || discarded_section (isec)))
156 return true;
157 }
158+
159 return false;
160 }
161 return false;
162--
1632.49.0
164