summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/files/0001-libdw-Check-end-of-attributes-list-consistently.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/elfutils/files/0001-libdw-Check-end-of-attributes-list-consistently.patch')
-rw-r--r--meta/recipes-devtools/elfutils/files/0001-libdw-Check-end-of-attributes-list-consistently.patch84
1 files changed, 84 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/files/0001-libdw-Check-end-of-attributes-list-consistently.patch b/meta/recipes-devtools/elfutils/files/0001-libdw-Check-end-of-attributes-list-consistently.patch
new file mode 100644
index 0000000000..fb7f8b1780
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/0001-libdw-Check-end-of-attributes-list-consistently.patch
@@ -0,0 +1,84 @@
1From 146456c537de5ac7c80608f88babbba026cca03b Mon Sep 17 00:00:00 2001
2From: Mark Wielaard <mark@klomp.org>
3Date: Sat, 18 Aug 2018 19:51:27 +0200
4Subject: [PATCH 1/2] libdw: Check end of attributes list consistently.
5
6dwarf_child (__libdw_find_attr), dwarf_getabbrevattr[_data] and
7dwarf_getattrs all assume the end of the attribute list is when
8both the name (code) and form of the attribute are zero.
9
10dwarf_getabbrev (__libdw_getabbrev) and dwarf_hasattr assume the
11end of the attribute list is when either the name (code) or the
12form of the attribute is zero.
13
14The DWARF spec says: "The series of attribute specifications ends
15with an entry containing 0 for the name and 0 for the form." So
16the first check is correct.
17
18Make sure dwarf_getabbrev and dwarf_hasattr use the same check.
19This is important since all other functions expect dwarf_getabbrev
20(__libdw_getabbrev) to have done a data sanity check of the attribute.
21So if the ending condition is different it could cause a crash.
22
23https://sourceware.org/bugzilla/show_bug.cgi?id=23529
24
25Signed-off-by: Mark Wielaard <mark@klomp.org>
26
27Upstream-Status: Backport [https://sourceware.org/git/?p=elfutils.git;a=commit;h=6983e59b727458a6c64d9659c85f08218bc4fcda]
28CVE: CVE-2018-16403
29
30Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
31---
32 libdw/ChangeLog | 7 +++++++
33 libdw/dwarf_getabbrev.c | 2 +-
34 libdw/dwarf_hasattr.c | 4 ++--
35 3 files changed, 10 insertions(+), 3 deletions(-)
36
37diff --git a/libdw/ChangeLog b/libdw/ChangeLog
38index 9e43ea9..f3cf5d3 100644
39--- a/libdw/ChangeLog
40+++ b/libdw/ChangeLog
41@@ -1,5 +1,12 @@
42 2018-08-18 Mark Wielaard <mark@klomp.org>
43
44+ * dwarf_getabbrev.c (__libdw_getabbrev): Continue until both name
45+ and form are zero.
46+ * dwarf_hasattr.c (dwarf_hasattr): Stop when both name and form
47+ are zero.
48+
49+2018-08-18 Mark Wielaard <mark@klomp.org>
50+
51 * dwarf_getaranges.c (dwarf_getaranges.c): Make sure there is enough
52 data to read the address and segment size.
53
54diff --git a/libdw/dwarf_getabbrev.c b/libdw/dwarf_getabbrev.c
55index 988d12c..6a7e981 100644
56--- a/libdw/dwarf_getabbrev.c
57+++ b/libdw/dwarf_getabbrev.c
58@@ -140,7 +140,7 @@ __libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu, Dwarf_Off offset,
59 get_sleb128 (formval, abbrevp, end);
60 }
61 }
62- while (attrname != 0 && attrform != 0);
63+ while (attrname != 0 || attrform != 0);
64
65 /* Return the length to the caller if she asked for it. */
66 if (lengthp != NULL)
67diff --git a/libdw/dwarf_hasattr.c b/libdw/dwarf_hasattr.c
68index 90053b1..eca0839 100644
69--- a/libdw/dwarf_hasattr.c
70+++ b/libdw/dwarf_hasattr.c
71@@ -60,8 +60,8 @@ dwarf_hasattr (Dwarf_Die *die, unsigned int search_name)
72 unsigned int attr_form;
73 get_uleb128_unchecked (attr_form, attrp);
74
75- /* We can stop if we found the attribute with value zero. */
76- if (attr_name == 0 || attr_form == 0)
77+ /* We can stop if we found the end of the attribute list. */
78+ if (attr_name == 0 && attr_form == 0)
79 return 0;
80
81 if (attr_name == search_name)
82--
832.7.4
84