summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/files/CVE-2019-7665.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/elfutils/files/CVE-2019-7665.patch')
-rw-r--r--meta/recipes-devtools/elfutils/files/CVE-2019-7665.patch154
1 files changed, 154 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/files/CVE-2019-7665.patch b/meta/recipes-devtools/elfutils/files/CVE-2019-7665.patch
new file mode 100644
index 0000000000..a1bb30979d
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/CVE-2019-7665.patch
@@ -0,0 +1,154 @@
1From 4323d46c4a369b614aa1f574805860b3434552df Mon Sep 17 00:00:00 2001
2From: Mark Wielaard <mark@klomp.org>
3Date: Wed, 16 Jan 2019 15:41:31 +0100
4Subject: [PATCH] CVE: CVE-2019-7665
5
6Upstream-Status: Backport
7
8Sign off: Shubham Agrawal <shuagr@microsoft.com>
9
10libebl: Check NT_PLATFORM core notes contain a zero terminated string.
11
12Most strings in core notes are fixed size. But NT_PLATFORM contains just
13a variable length string. Check that it is actually zero terminated
14before passing to readelf to print.
15
16https://sourceware.org/bugzilla/show_bug.cgi?id=24089
17
18Signed-off-by: Mark Wielaard <mark@klomp.org>
19Signed-off-by: Ubuntu <lisa@shuagr-yocto-build.mdn4q2lr1oauhmizmzsslly3ad.xx.internal.cloudapp.net>
20---
21 libdwfl/linux-core-attach.c | 9 +++++----
22 libebl/eblcorenote.c | 39 +++++++++++++++++++--------------------
23 libebl/libebl.h | 3 ++-
24 src/readelf.c | 2 +-
25 4 files changed, 27 insertions(+), 26 deletions(-)
26
27diff --git a/libdwfl/linux-core-attach.c b/libdwfl/linux-core-attach.c
28index 6c99b9e..c0f1b0d 100644
29--- a/libdwfl/linux-core-attach.c
30+++ b/libdwfl/linux-core-attach.c
31@@ -137,7 +137,7 @@ core_next_thread (Dwfl *dwfl __attribute__ ((unused)), void *dwfl_arg,
32 const Ebl_Register_Location *reglocs;
33 size_t nitems;
34 const Ebl_Core_Item *items;
35- if (! ebl_core_note (core_arg->ebl, &nhdr, name,
36+ if (! ebl_core_note (core_arg->ebl, &nhdr, name, desc,
37 &regs_offset, &nregloc, &reglocs, &nitems, &items))
38 {
39 /* This note may be just not recognized, skip it. */
40@@ -191,8 +191,9 @@ core_set_initial_registers (Dwfl_Thread *thread, void *thread_arg_voidp)
41 const Ebl_Register_Location *reglocs;
42 size_t nitems;
43 const Ebl_Core_Item *items;
44- int core_note_err = ebl_core_note (core_arg->ebl, &nhdr, name, &regs_offset,
45- &nregloc, &reglocs, &nitems, &items);
46+ int core_note_err = ebl_core_note (core_arg->ebl, &nhdr, name, desc,
47+ &regs_offset, &nregloc, &reglocs,
48+ &nitems, &items);
49 /* __libdwfl_attach_state_for_core already verified the note is there. */
50 assert (core_note_err != 0);
51 assert (nhdr.n_type == NT_PRSTATUS);
52@@ -383,7 +384,7 @@ dwfl_core_file_attach (Dwfl *dwfl, Elf *core)
53 const Ebl_Register_Location *reglocs;
54 size_t nitems;
55 const Ebl_Core_Item *items;
56- if (! ebl_core_note (ebl, &nhdr, name,
57+ if (! ebl_core_note (ebl, &nhdr, name, desc,
58 &regs_offset, &nregloc, &reglocs, &nitems, &items))
59 {
60 /* This note may be just not recognized, skip it. */
61diff --git a/libebl/eblcorenote.c b/libebl/eblcorenote.c
62index 783f981..7fab397 100644
63--- a/libebl/eblcorenote.c
64+++ b/libebl/eblcorenote.c
65@@ -36,11 +36,13 @@
66 #include <inttypes.h>
67 #include <stdio.h>
68 #include <stddef.h>
69+#include <string.h>
70 #include <libeblP.h>
71
72
73 int
74 ebl_core_note (Ebl *ebl, const GElf_Nhdr *nhdr, const char *name,
75+ const char *desc,
76 GElf_Word *regs_offset, size_t *nregloc,
77 const Ebl_Register_Location **reglocs, size_t *nitems,
78 const Ebl_Core_Item **items)
79@@ -51,28 +53,25 @@ ebl_core_note (Ebl *ebl, const GElf_Nhdr *nhdr, const char *name,
80 {
81 /* The machine specific function did not know this type. */
82
83- *regs_offset = 0;
84- *nregloc = 0;
85- *reglocs = NULL;
86- switch (nhdr->n_type)
87+ /* NT_PLATFORM is kind of special since it needs a zero terminated
88+ string (other notes often have a fixed size string). */
89+ static const Ebl_Core_Item platform[] =
90 {
91-#define ITEMS(type, table) \
92- case type: \
93- *items = table; \
94- *nitems = sizeof table / sizeof table[0]; \
95- result = 1; \
96- break
97+ {
98+ .name = "Platform",
99+ .type = ELF_T_BYTE, .count = 0, .format = 's'
100+ }
101+ };
102
103- static const Ebl_Core_Item platform[] =
104- {
105- {
106- .name = "Platform",
107- .type = ELF_T_BYTE, .count = 0, .format = 's'
108- }
109- };
110- ITEMS (NT_PLATFORM, platform);
111-
112-#undef ITEMS
113+ if (nhdr->n_type == NT_PLATFORM
114+ && memchr (desc, '\0', nhdr->n_descsz) != NULL)
115+ {
116+ *regs_offset = 0;
117+ *nregloc = 0;
118+ *reglocs = NULL;
119+ *items = platform;
120+ *nitems = 1;
121+ result = 1;
122 }
123 }
124
125diff --git a/libebl/libebl.h b/libebl/libebl.h
126index ca9b9fe..24922eb 100644
127--- a/libebl/libebl.h
128+++ b/libebl/libebl.h
129@@ -319,7 +319,8 @@ typedef struct
130
131 /* Describe the format of a core file note with the given header and NAME.
132 NAME is not guaranteed terminated, it's NHDR->n_namesz raw bytes. */
133-extern int ebl_core_note (Ebl *ebl, const GElf_Nhdr *nhdr, const char *name,
134+extern int ebl_core_note (Ebl *ebl, const GElf_Nhdr *nhdr,
135+ const char *name, const char *desc,
136 GElf_Word *regs_offset, size_t *nregloc,
137 const Ebl_Register_Location **reglocs,
138 size_t *nitems, const Ebl_Core_Item **items)
139diff --git a/src/readelf.c b/src/readelf.c
140index 3a73710..71651e0 100644
141--- a/src/readelf.c
142+++ b/src/readelf.c
143@@ -12153,7 +12153,7 @@ handle_core_note (Ebl *ebl, const GElf_Nhdr *nhdr,
144 size_t nitems;
145 const Ebl_Core_Item *items;
146
147- if (! ebl_core_note (ebl, nhdr, name,
148+ if (! ebl_core_note (ebl, nhdr, name, desc,
149 &regs_offset, &nregloc, &reglocs, &nitems, &items))
150 return;
151
152--
1532.7.4
154