diff options
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.patch | 84 |
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 @@ | |||
1 | From 146456c537de5ac7c80608f88babbba026cca03b Mon Sep 17 00:00:00 2001 | ||
2 | From: Mark Wielaard <mark@klomp.org> | ||
3 | Date: Sat, 18 Aug 2018 19:51:27 +0200 | ||
4 | Subject: [PATCH 1/2] libdw: Check end of attributes list consistently. | ||
5 | |||
6 | dwarf_child (__libdw_find_attr), dwarf_getabbrevattr[_data] and | ||
7 | dwarf_getattrs all assume the end of the attribute list is when | ||
8 | both the name (code) and form of the attribute are zero. | ||
9 | |||
10 | dwarf_getabbrev (__libdw_getabbrev) and dwarf_hasattr assume the | ||
11 | end of the attribute list is when either the name (code) or the | ||
12 | form of the attribute is zero. | ||
13 | |||
14 | The DWARF spec says: "The series of attribute specifications ends | ||
15 | with an entry containing 0 for the name and 0 for the form." So | ||
16 | the first check is correct. | ||
17 | |||
18 | Make sure dwarf_getabbrev and dwarf_hasattr use the same check. | ||
19 | This is important since all other functions expect dwarf_getabbrev | ||
20 | (__libdw_getabbrev) to have done a data sanity check of the attribute. | ||
21 | So if the ending condition is different it could cause a crash. | ||
22 | |||
23 | https://sourceware.org/bugzilla/show_bug.cgi?id=23529 | ||
24 | |||
25 | Signed-off-by: Mark Wielaard <mark@klomp.org> | ||
26 | |||
27 | Upstream-Status: Backport [https://sourceware.org/git/?p=elfutils.git;a=commit;h=6983e59b727458a6c64d9659c85f08218bc4fcda] | ||
28 | CVE: CVE-2018-16403 | ||
29 | |||
30 | Signed-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 | |||
37 | diff --git a/libdw/ChangeLog b/libdw/ChangeLog | ||
38 | index 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 | |||
54 | diff --git a/libdw/dwarf_getabbrev.c b/libdw/dwarf_getabbrev.c | ||
55 | index 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) | ||
67 | diff --git a/libdw/dwarf_hasattr.c b/libdw/dwarf_hasattr.c | ||
68 | index 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 | -- | ||
83 | 2.7.4 | ||
84 | |||