Skip to content

Commit 9bc7893

Browse files
[AutoPR- Security] Patch gdb for CVE-2026-4647 [MEDIUM] (#16419)
1 parent 3a1e76a commit 9bc7893

2 files changed

Lines changed: 230 additions & 1 deletion

File tree

SPECS/gdb/CVE-2026-4647.patch

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
From 156144e824f9d79b14f37bfb09757d46540062ab Mon Sep 17 00:00:00 2001
2+
From: Alan Modra <amodra@gmail.com>
3+
Date: Fri, 13 Mar 2026 17:28:28 +1030
4+
Subject: [PATCH] PR33919 Out-of-bounds read in XCOFF relocation processing
5+
6+
PR 33919
7+
* coff-rs6000.c (xcoff_calculate_relocation): Don't use explicit
8+
array size.
9+
(xcoff_complain_overflow): Likewise.
10+
(xcoff_rtype2howto): Return a NULL howto rather than aborting.
11+
(_bfd_xcoff_reloc_name_lookup): Use ARRAY_SIZE.
12+
(xcoff_ppc_relocate_section): Sanity check reloc r_type before
13+
accessing xcoff_howto_table. Print r_type using %#x. Remove
14+
now redundant later reloc r_type sanity check.
15+
* coff64-rs6000.c: Similarly.
16+
* libxcoff.h (XCOFF_MAX_CALCULATE_RELOCATION): Don't define.
17+
(XCOFF_MAX_COMPLAIN_OVERFLOW): Don't define.
18+
19+
Signed-off-by: Azure Linux Security Servicing Account <azurelinux-security@microsoft.com>
20+
Upstream-reference: https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=9e99dbc1f19ffaf18d0250788951706066ebe7f2
21+
---
22+
bfd/coff-rs6000.c | 36 +++++++++++++++++++++---------------
23+
bfd/coff64-rs6000.c | 33 ++++++++++++++++++++-------------
24+
bfd/libxcoff.h | 3 ---
25+
3 files changed, 41 insertions(+), 31 deletions(-)
26+
27+
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
28+
index bfa999d..593d5d2 100644
29+
--- a/bfd/coff-rs6000.c
30+
+++ b/bfd/coff-rs6000.c
31+
@@ -155,8 +155,7 @@ static xcoff_complain_function xcoff_complain_overflow_bitfield_func;
32+
static xcoff_complain_function xcoff_complain_overflow_signed_func;
33+
static xcoff_complain_function xcoff_complain_overflow_unsigned_func;
34+
35+
-xcoff_reloc_function *const
36+
-xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION] =
37+
+xcoff_reloc_function *const xcoff_calculate_relocation[] =
38+
{
39+
xcoff_reloc_type_pos, /* R_POS (0x00) */
40+
xcoff_reloc_type_neg, /* R_NEG (0x01) */
41+
@@ -210,8 +209,7 @@ xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION] =
42+
xcoff_reloc_type_toc, /* R_TOCL (0x31) */
43+
};
44+
45+
-xcoff_complain_function *const
46+
-xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW] =
47+
+xcoff_complain_function *const xcoff_complain_overflow[] =
48+
{
49+
xcoff_complain_overflow_dont_func,
50+
xcoff_complain_overflow_bitfield_func,
51+
@@ -1158,8 +1156,11 @@ reloc_howto_type xcoff_howto_table[] =
52+
void
53+
xcoff_rtype2howto (arelent *relent, struct internal_reloc *internal)
54+
{
55+
- if (internal->r_type > R_TOCL)
56+
- abort ();
57+
+ if (internal->r_type >= ARRAY_SIZE (xcoff_howto_table))
58+
+ {
59+
+ relent->howto = NULL;
60+
+ return;
61+
+ }
62+
63+
/* Default howto layout works most of the time */
64+
relent->howto = &xcoff_howto_table[internal->r_type];
65+
@@ -1183,7 +1184,7 @@ xcoff_rtype2howto (arelent *relent, struct internal_reloc *internal)
66+
if (relent->howto->dst_mask != 0
67+
&& (relent->howto->bitsize
68+
!= ((unsigned int) internal->r_size & 0x1f) + 1))
69+
- abort ();
70+
+ relent->howto = NULL;
71+
}
72+
73+
reloc_howto_type *
74+
@@ -1236,9 +1237,7 @@ _bfd_xcoff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
75+
{
76+
unsigned int i;
77+
78+
- for (i = 0;
79+
- i < sizeof (xcoff_howto_table) / sizeof (xcoff_howto_table[0]);
80+
- i++)
81+
+ for (i = 0; i < ARRAY_SIZE (xcoff_howto_table); i++)
82+
if (xcoff_howto_table[i].name != NULL
83+
&& strcasecmp (xcoff_howto_table[i].name, r_name) == 0)
84+
return &xcoff_howto_table[i];
85+
@@ -3681,6 +3680,14 @@ xcoff_ppc_relocate_section (bfd *output_bfd,
86+
the csect including the symbol which it references. */
87+
if (rel->r_type == R_REF)
88+
continue;
89+
+ if (rel->r_type >= ARRAY_SIZE (xcoff_howto_table))
90+
+ {
91+
+ /* xgettext:c-format */
92+
+ _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
93+
+ input_bfd, rel->r_type);
94+
+ bfd_set_error (bfd_error_bad_value);
95+
+ return false;
96+
+ }
97+
98+
/* Retrieve default value in HOWTO table and fix up according
99+
to r_size field, if it can be different.
100+
@@ -3700,7 +3707,7 @@ xcoff_ppc_relocate_section (bfd *output_bfd,
101+
102+
default:
103+
_bfd_error_handler
104+
- (_("%pB: relocation (%d) at 0x%" PRIx64 " has wrong r_rsize (0x%x)\n"),
105+
+ (_("%pB: relocation (%#x) at 0x%" PRIx64 " has wrong r_rsize (0x%x)\n"),
106+
input_bfd, rel->r_type, (uint64_t) rel->r_vaddr, rel->r_size);
107+
return false;
108+
}
109+
@@ -3776,10 +3783,9 @@ xcoff_ppc_relocate_section (bfd *output_bfd,
110+
}
111+
}
112+
113+
- if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION
114+
- || !((*xcoff_calculate_relocation[rel->r_type])
115+
- (input_bfd, input_section, output_bfd, rel, sym, &howto, val,
116+
- addend, &relocation, contents, info)))
117+
+ if (!((*xcoff_calculate_relocation[rel->r_type])
118+
+ (input_bfd, input_section, output_bfd, rel, sym, &howto, val,
119+
+ addend, &relocation, contents, info)))
120+
return false;
121+
122+
/* address */
123+
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
124+
index fa57910..28baf8a 100644
125+
--- a/bfd/coff64-rs6000.c
126+
+++ b/bfd/coff64-rs6000.c
127+
@@ -177,8 +177,7 @@ static bool xcoff64_bad_format_hook
128+
/* Relocation functions */
129+
static xcoff_reloc_function xcoff64_reloc_type_br;
130+
131+
-xcoff_reloc_function *const
132+
-xcoff64_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION] =
133+
+xcoff_reloc_function *const xcoff64_calculate_relocation[] =
134+
{
135+
xcoff_reloc_type_pos, /* R_POS (0x00) */
136+
xcoff_reloc_type_neg, /* R_NEG (0x01) */
137+
@@ -1439,8 +1438,11 @@ reloc_howto_type xcoff64_howto_table[] =
138+
void
139+
xcoff64_rtype2howto (arelent *relent, struct internal_reloc *internal)
140+
{
141+
- if (internal->r_type > R_TOCL)
142+
- abort ();
143+
+ if (internal->r_type >= ARRAY_SIZE (xcoff64_howto_table))
144+
+ {
145+
+ relent->howto = NULL;
146+
+ return;
147+
+ }
148+
149+
/* Default howto layout works most of the time */
150+
relent->howto = &xcoff64_howto_table[internal->r_type];
151+
@@ -1473,7 +1475,7 @@ xcoff64_rtype2howto (arelent *relent, struct internal_reloc *internal)
152+
if (relent->howto->dst_mask != 0
153+
&& (relent->howto->bitsize
154+
!= ((unsigned int) internal->r_size & 0x3f) + 1))
155+
- abort ();
156+
+ relent->howto = NULL;
157+
}
158+
159+
reloc_howto_type *
160+
@@ -1528,9 +1530,7 @@ xcoff64_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
161+
{
162+
unsigned int i;
163+
164+
- for (i = 0;
165+
- i < sizeof (xcoff64_howto_table) / sizeof (xcoff64_howto_table[0]);
166+
- i++)
167+
+ for (i = 0; i < ARRAY_SIZE (xcoff64_howto_table); i++)
168+
if (xcoff64_howto_table[i].name != NULL
169+
&& strcasecmp (xcoff64_howto_table[i].name, r_name) == 0)
170+
return &xcoff64_howto_table[i];
171+
@@ -1574,6 +1574,14 @@ xcoff64_ppc_relocate_section (bfd *output_bfd,
172+
the csect including the symbol which it references. */
173+
if (rel->r_type == R_REF)
174+
continue;
175+
+ if (rel->r_type >= ARRAY_SIZE (xcoff64_howto_table))
176+
+ {
177+
+ /* xgettext:c-format */
178+
+ _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
179+
+ input_bfd, rel->r_type);
180+
+ bfd_set_error (bfd_error_bad_value);
181+
+ return false;
182+
+ }
183+
184+
/* Retrieve default value in HOWTO table and fix up according
185+
to r_size field, if it can be different.
186+
@@ -1595,7 +1603,7 @@ xcoff64_ppc_relocate_section (bfd *output_bfd,
187+
188+
default:
189+
_bfd_error_handler
190+
- (_("%pB: relocation (%d) at (0x%" PRIx64 ") has wrong"
191+
+ (_("%pB: relocation (%#x) at (0x%" PRIx64 ") has wrong"
192+
" r_rsize (0x%x)\n"),
193+
input_bfd, rel->r_type, rel->r_vaddr, rel->r_size);
194+
return false;
195+
@@ -1668,10 +1676,9 @@ xcoff64_ppc_relocate_section (bfd *output_bfd,
196+
}
197+
}
198+
199+
- if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION
200+
- || !((*xcoff64_calculate_relocation[rel->r_type])
201+
- (input_bfd, input_section, output_bfd, rel, sym, &howto, val,
202+
- addend, &relocation, contents, info)))
203+
+ if (!((*xcoff64_calculate_relocation[rel->r_type])
204+
+ (input_bfd, input_section, output_bfd, rel, sym, &howto, val,
205+
+ addend, &relocation, contents, info)))
206+
return false;
207+
208+
/* address */
209+
diff --git a/bfd/libxcoff.h b/bfd/libxcoff.h
210+
index c6ad6dc..01d8ce3 100644
211+
--- a/bfd/libxcoff.h
212+
+++ b/bfd/libxcoff.h
213+
@@ -215,9 +215,6 @@ struct xcoff_backend_data_rec
214+
#define bfd_xcoff_text_align_power(a) ((xcoff_data (a)->text_align_power))
215+
#define bfd_xcoff_data_align_power(a) ((xcoff_data (a)->data_align_power))
216+
217+
-/* xcoff*_ppc_relocate_section macros */
218+
-#define XCOFF_MAX_CALCULATE_RELOCATION (0x32)
219+
-#define XCOFF_MAX_COMPLAIN_OVERFLOW (4)
220+
/* N_ONES produces N one bits, without overflowing machine arithmetic. */
221+
#ifdef N_ONES
222+
#undef N_ONES
223+
--
224+
2.45.4
225+

SPECS/gdb/gdb.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: C debugger
22
Name: gdb
33
Version: 13.2
4-
Release: 6%{?dist}
4+
Release: 7%{?dist}
55
License: GPLv2+
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
@@ -13,6 +13,7 @@ Patch1: CVE-2023-39129.patch
1313
Patch2: CVE-2023-39130.patch
1414
Patch3: CVE-2025-7546.patch
1515
Patch4: CVE-2025-11082.patch
16+
Patch5: CVE-2026-4647.patch
1617
BuildRequires: expat-devel
1718
BuildRequires: gcc-c++
1819
BuildRequires: gcc-gfortran
@@ -106,6 +107,9 @@ make check TESTS='gdb.base/default.exp'
106107
%{_mandir}/*/*
107108

108109
%changelog
110+
* Thu Apr 02 2026 Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> - 13.2-7
111+
- Patch for CVE-2026-4647
112+
109113
* Fri Oct 03 2025 Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> - 13.2-6
110114
- Patch for CVE-2025-11082
111115

0 commit comments

Comments
 (0)