1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
commit 7eacd66b086cabb1daab20890d5481894d4f56b2
Author: Alan Modra <amodra@gmail.com>
Date: Sun Apr 23 15:21:11 2017 +0930
PR 21414, null pointer deref of _bfd_elf_large_com_section sym
PR 21414
* section.c (GLOBAL_SYM_INIT): Make available in bfd.h.
* elf.c (lcomm_sym): New.
(_bfd_elf_large_com_section): Use lcomm_sym section symbol.
* bfd-in2.h: Regenerate.
Upstream-Status: Backport
CVE: CVE-2017-8394
Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com>
Index: git/bfd/bfd-in2.h
===================================================================
--- git.orig/bfd/bfd-in2.h 2017-09-20 12:54:44.847475928 +0530
+++ git/bfd/bfd-in2.h 2017-09-20 12:54:44.903476171 +0530
@@ -1805,6 +1805,18 @@
{ NULL }, { NULL } \
}
+/* We use a macro to initialize the static asymbol structures because
+ traditional C does not permit us to initialize a union member while
+ gcc warns if we don't initialize it.
+ the_bfd, name, value, attr, section [, udata] */
+#ifdef __STDC__
+#define GLOBAL_SYM_INIT(NAME, SECTION) \
+ { 0, NAME, 0, BSF_SECTION_SYM, SECTION, { 0 }}
+#else
+#define GLOBAL_SYM_INIT(NAME, SECTION) \
+ { 0, NAME, 0, BSF_SECTION_SYM, SECTION }
+#endif
+
void bfd_section_list_clear (bfd *);
asection *bfd_get_section_by_name (bfd *abfd, const char *name);
Index: git/bfd/section.c
===================================================================
--- git.orig/bfd/section.c 2017-09-20 12:54:44.847475928 +0530
+++ git/bfd/section.c 2017-09-20 12:54:44.903476171 +0530
@@ -738,20 +738,20 @@
. { NULL }, { NULL } \
. }
.
+.{* We use a macro to initialize the static asymbol structures because
+. traditional C does not permit us to initialize a union member while
+. gcc warns if we don't initialize it.
+. the_bfd, name, value, attr, section [, udata] *}
+.#ifdef __STDC__
+.#define GLOBAL_SYM_INIT(NAME, SECTION) \
+. { 0, NAME, 0, BSF_SECTION_SYM, SECTION, { 0 }}
+.#else
+.#define GLOBAL_SYM_INIT(NAME, SECTION) \
+. { 0, NAME, 0, BSF_SECTION_SYM, SECTION }
+.#endif
+.
*/
-/* We use a macro to initialize the static asymbol structures because
- traditional C does not permit us to initialize a union member while
- gcc warns if we don't initialize it. */
- /* the_bfd, name, value, attr, section [, udata] */
-#ifdef __STDC__
-#define GLOBAL_SYM_INIT(NAME, SECTION) \
- { 0, NAME, 0, BSF_SECTION_SYM, SECTION, { 0 }}
-#else
-#define GLOBAL_SYM_INIT(NAME, SECTION) \
- { 0, NAME, 0, BSF_SECTION_SYM, SECTION }
-#endif
-
/* These symbols are global, not specific to any BFD. Therefore, anything
that tries to change them is broken, and should be repaired. */
Index: git/bfd/ChangeLog
===================================================================
--- git.orig/bfd/ChangeLog 2017-09-20 12:54:44.735475444 +0530
+++ git/bfd/ChangeLog 2017-09-20 12:54:44.903476171 +0530
@@ -102,6 +102,14 @@
* readelf.c (process_mips_specific): Remove null GOT data check.
2017-04-23 Alan Modra <amodra@gmail.com>
+
+ PR 21414
+ * section.c (GLOBAL_SYM_INIT): Make available in bfd.h.
+ * elf.c (lcomm_sym): New.
+ (_bfd_elf_large_com_section): Use lcomm_sym section symbol.
+ * bfd-in2.h: Regenerate.
+
+2017-04-23 Alan Modra <amodra@gmail.com>
PR 21412
* elf-bfd.h (struct elf_backend_data <get_reloc_section>): Change
Index: git/bfd/elf.c
===================================================================
--- git.orig/bfd/elf.c 2017-09-20 12:54:44.847475928 +0530
+++ git/bfd/elf.c 2017-09-20 13:00:22.636091768 +0530
@@ -10986,9 +10986,11 @@
/* It is only used by x86-64 so far.
??? This repeats *COM* id of zero. sec->id is supposed to be unique,
- but current usage would allow all of _bfd_std_section to be zero. t*/
+ but current usage would allow all of _bfd_std_section to be zero. */
+static const asymbol lcomm_sym
+ = GLOBAL_SYM_INIT ("LARGE_COMMON", &_bfd_elf_large_com_section);
asection _bfd_elf_large_com_section
- = BFD_FAKE_SECTION (_bfd_elf_large_com_section, NULL,
+ = BFD_FAKE_SECTION (_bfd_elf_large_com_section, &lcomm_sym,
"LARGE_COMMON", 0, SEC_IS_COMMON);
void
|