diff options
Diffstat (limited to 'meta/recipes-devtools/binutils/binutils/CVE-2023-25588.patch')
-rw-r--r-- | meta/recipes-devtools/binutils/binutils/CVE-2023-25588.patch | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils/CVE-2023-25588.patch b/meta/recipes-devtools/binutils/binutils/CVE-2023-25588.patch new file mode 100644 index 0000000000..aa5ce5f3ff --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/CVE-2023-25588.patch | |||
@@ -0,0 +1,149 @@ | |||
1 | From d12f8998d2d086f0a6606589e5aedb7147e6f2f1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alan Modra <amodra@gmail.com> | ||
3 | Date: Fri, 14 Oct 2022 10:30:21 +1030 | ||
4 | Subject: [PATCH] PR29677, Field `the_bfd` of `asymbol` is uninitialised | ||
5 | |||
6 | Besides not initialising the_bfd of synthetic symbols, counting | ||
7 | symbols when sizing didn't match symbols created if there were any | ||
8 | dynsyms named "". We don't want synthetic symbols without names | ||
9 | anyway, so get rid of them. Also, simplify and correct sanity checks. | ||
10 | |||
11 | PR 29677 | ||
12 | * mach-o.c (bfd_mach_o_get_synthetic_symtab): Rewrite. | ||
13 | --- | ||
14 | Upstream-Status: Backport from [https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=d12f8998d2d086f0a6606589e5aedb7147e6f2f1] | ||
15 | CVE: CVE-2023-25588 | ||
16 | CVE: CVE-2022-47696 | ||
17 | |||
18 | Signed-off-by: Ashish Sharma <asharma@mvista.com> | ||
19 | Signed-off-by: poojitha adireddy <pooadire@cisco.com> | ||
20 | |||
21 | bfd/mach-o.c | 72 ++++++++++++++++++++++------------------------------ | ||
22 | 1 file changed, 31 insertions(+), 41 deletions(-) | ||
23 | |||
24 | diff --git a/bfd/mach-o.c b/bfd/mach-o.c | ||
25 | index acb35e7f0c6..5279343768c 100644 | ||
26 | --- a/bfd/mach-o.c | ||
27 | +++ b/bfd/mach-o.c | ||
28 | @@ -938,11 +938,9 @@ bfd_mach_o_get_synthetic_symtab (bfd *abfd, | ||
29 | bfd_mach_o_symtab_command *symtab = mdata->symtab; | ||
30 | asymbol *s; | ||
31 | char * s_start; | ||
32 | - char * s_end; | ||
33 | unsigned long count, i, j, n; | ||
34 | size_t size; | ||
35 | char *names; | ||
36 | - char *nul_name; | ||
37 | const char stub [] = "$stub"; | ||
38 | |||
39 | *ret = NULL; | ||
40 | @@ -955,27 +953,27 @@ bfd_mach_o_get_synthetic_symtab (bfd *abfd, | ||
41 | /* We need to allocate a bfd symbol for every indirect symbol and to | ||
42 | allocate the memory for its name. */ | ||
43 | count = dysymtab->nindirectsyms; | ||
44 | - size = count * sizeof (asymbol) + 1; | ||
45 | - | ||
46 | + size = 0; | ||
47 | for (j = 0; j < count; j++) | ||
48 | { | ||
49 | - const char * strng; | ||
50 | unsigned int isym = dysymtab->indirect_syms[j]; | ||
51 | + const char *str; | ||
52 | |||
53 | /* Some indirect symbols are anonymous. */ | ||
54 | - if (isym < symtab->nsyms && (strng = symtab->symbols[isym].symbol.name)) | ||
55 | - /* PR 17512: file: f5b8eeba. */ | ||
56 | - size += strnlen (strng, symtab->strsize - (strng - symtab->strtab)) + sizeof (stub); | ||
57 | + if (isym < symtab->nsyms | ||
58 | + && (str = symtab->symbols[isym].symbol.name) != NULL) | ||
59 | + { | ||
60 | + /* PR 17512: file: f5b8eeba. */ | ||
61 | + size += strnlen (str, symtab->strsize - (str - symtab->strtab)); | ||
62 | + size += sizeof (stub); | ||
63 | + } | ||
64 | } | ||
65 | |||
66 | - s_start = bfd_malloc (size); | ||
67 | + s_start = bfd_malloc (size + count * sizeof (asymbol)); | ||
68 | s = *ret = (asymbol *) s_start; | ||
69 | if (s == NULL) | ||
70 | return -1; | ||
71 | names = (char *) (s + count); | ||
72 | - nul_name = names; | ||
73 | - *names++ = 0; | ||
74 | - s_end = s_start + size; | ||
75 | |||
76 | n = 0; | ||
77 | for (i = 0; i < mdata->nsects; i++) | ||
78 | @@ -997,47 +995,39 @@ bfd_mach_o_get_synthetic_symtab (bfd *abfd, | ||
79 | entry_size = bfd_mach_o_section_get_entry_size (abfd, sec); | ||
80 | |||
81 | /* PR 17512: file: 08e15eec. */ | ||
82 | - if (first >= count || last >= count || first > last) | ||
83 | + if (first >= count || last > count || first > last) | ||
84 | goto fail; | ||
85 | |||
86 | for (j = first; j < last; j++) | ||
87 | { | ||
88 | unsigned int isym = dysymtab->indirect_syms[j]; | ||
89 | - | ||
90 | - /* PR 17512: file: 04d64d9b. */ | ||
91 | - if (((char *) s) + sizeof (* s) > s_end) | ||
92 | - goto fail; | ||
93 | - | ||
94 | - s->flags = BSF_GLOBAL | BSF_SYNTHETIC; | ||
95 | - s->section = sec->bfdsection; | ||
96 | - s->value = addr - sec->addr; | ||
97 | - s->udata.p = NULL; | ||
98 | + const char *str; | ||
99 | + size_t len; | ||
100 | |||
101 | if (isym < symtab->nsyms | ||
102 | - && symtab->symbols[isym].symbol.name) | ||
103 | + && (str = symtab->symbols[isym].symbol.name) != NULL) | ||
104 | { | ||
105 | - const char *sym = symtab->symbols[isym].symbol.name; | ||
106 | - size_t len; | ||
107 | - | ||
108 | - s->name = names; | ||
109 | - len = strlen (sym); | ||
110 | - /* PR 17512: file: 47dfd4d2. */ | ||
111 | - if (names + len >= s_end) | ||
112 | + /* PR 17512: file: 04d64d9b. */ | ||
113 | + if (n >= count) | ||
114 | goto fail; | ||
115 | - memcpy (names, sym, len); | ||
116 | - names += len; | ||
117 | - /* PR 17512: file: 18f340a4. */ | ||
118 | - if (names + sizeof (stub) >= s_end) | ||
119 | + len = strnlen (str, symtab->strsize - (str - symtab->strtab)); | ||
120 | + /* PR 17512: file: 47dfd4d2, 18f340a4. */ | ||
121 | + if (size < len + sizeof (stub)) | ||
122 | goto fail; | ||
123 | - memcpy (names, stub, sizeof (stub)); | ||
124 | - names += sizeof (stub); | ||
125 | + memcpy (names, str, len); | ||
126 | + memcpy (names + len, stub, sizeof (stub)); | ||
127 | + s->name = names; | ||
128 | + names += len + sizeof (stub); | ||
129 | + size -= len + sizeof (stub); | ||
130 | + s->the_bfd = symtab->symbols[isym].symbol.the_bfd; | ||
131 | + s->flags = BSF_GLOBAL | BSF_SYNTHETIC; | ||
132 | + s->section = sec->bfdsection; | ||
133 | + s->value = addr - sec->addr; | ||
134 | + s->udata.p = NULL; | ||
135 | + s++; | ||
136 | + n++; | ||
137 | } | ||
138 | - else | ||
139 | - s->name = nul_name; | ||
140 | - | ||
141 | addr += entry_size; | ||
142 | - s++; | ||
143 | - n++; | ||
144 | } | ||
145 | break; | ||
146 | default: | ||
147 | -- | ||
148 | 2.39.3 | ||
149 | |||