summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Fix-segfault-when-btf__type_by_id-returns-NULL.patch131
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb1
2 files changed, 132 insertions, 0 deletions
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Fix-segfault-when-btf__type_by_id-returns-NULL.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Fix-segfault-when-btf__type_by_id-returns-NULL.patch
new file mode 100644
index 0000000..0d91c6e
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Fix-segfault-when-btf__type_by_id-returns-NULL.patch
@@ -0,0 +1,131 @@
1From 38c099dff9100bafeaaa7cee865f4dfda58134ac Mon Sep 17 00:00:00 2001
2From: Youlin Feng <fengyoulin@live.com>
3Date: Sat, 7 May 2022 18:50:25 +0800
4Subject: [PATCH] Fix segfault when btf__type_by_id returns NULL
5
6Upstream-Status: Backport [https://github.com/iovisor/bpftrace/commit/38c099dff9100bafeaaa7cee865f4dfda58134ac]
7
8Signed-off-by: Michal Wojcik <michal.wojcik@linaro.org>
9---
10 src/btf.cpp | 28 ++++++++++++++++++++++++----
11 1 file changed, 24 insertions(+), 4 deletions(-)
12
13diff --git a/src/btf.cpp b/src/btf.cpp
14index 33bbb7ba..20ee6598 100644
15--- a/src/btf.cpp
16+++ b/src/btf.cpp
17@@ -263,6 +263,9 @@ std::string BTF::c_def(const std::unordered_set<std::string> &set) const
18 for (id = 1; id <= max && myset.size(); id++)
19 {
20 const struct btf_type *t = btf__type_by_id(btf, id);
21+ if (!t)
22+ continue;
23+
24 // Allow users to reference enum values by name to pull in entire enum defs
25 if (btf_is_enum(t))
26 {
27@@ -306,6 +309,8 @@ std::string BTF::type_of(const std::string& name, const std::string& field)
28 return std::string("");
29
30 const struct btf_type *type = btf__type_by_id(btf, type_id);
31+ if (!type)
32+ return std::string("");
33 return type_of(type, field);
34 }
35
36@@ -334,6 +339,8 @@ std::string BTF::type_of(const btf_type *type, const std::string &field)
37 if (m_name == "")
38 {
39 const struct btf_type *type = btf__type_by_id(btf, m[i].type);
40+ if (!type)
41+ return std::string("");
42 std::string type_name = type_of(type, field);
43 if (!type_name.empty())
44 return type_name;
45@@ -354,6 +361,8 @@ std::string BTF::type_of(const btf_type *type, const std::string &field)
46 BTF_INFO_KIND(f->info) == BTF_KIND_RESTRICT)
47 {
48 f = btf__type_by_id(btf, f->type);
49+ if (!f)
50+ return std::string("");
51 }
52
53 return full_type_str(btf, f);
54@@ -387,7 +396,7 @@ static bool btf_type_is_modifier(const struct btf_type *t)
55
56 const struct btf_type *BTF::btf_type_skip_modifiers(const struct btf_type *t)
57 {
58- while (btf_type_is_modifier(t))
59+ while (t && btf_type_is_modifier(t))
60 {
61 t = btf__type_by_id(btf, t->type);
62 }
63@@ -445,6 +454,9 @@ int BTF::resolve_args(const std::string &func,
64 {
65 const struct btf_type *t = btf__type_by_id(btf, id);
66
67+ if (!t)
68+ continue;
69+
70 if (!btf_is_func(t))
71 continue;
72
73@@ -454,7 +466,7 @@ int BTF::resolve_args(const std::string &func,
74 continue;
75
76 t = btf__type_by_id(btf, t->type);
77- if (!btf_is_func_proto(t))
78+ if (!t || !btf_is_func_proto(t))
79 {
80 throw std::runtime_error("not a function");
81 }
82@@ -529,6 +541,9 @@ std::unique_ptr<std::istream> BTF::get_all_funcs() const
83 {
84 const struct btf_type *t = btf__type_by_id(btf, id);
85
86+ if (!t)
87+ continue;
88+
89 if (!btf_is_func(t))
90 continue;
91
92@@ -536,7 +551,7 @@ std::unique_ptr<std::istream> BTF::get_all_funcs() const
93 std::string func_name = str;
94
95 t = btf__type_by_id(btf, t->type);
96- if (!btf_is_func_proto(t))
97+ if (!t || !btf_is_func_proto(t))
98 {
99 /* bad.. */
100 if (!bt_verbose)
101@@ -585,6 +600,9 @@ std::map<std::string, std::vector<std::string>> BTF::get_params(
102 {
103 const struct btf_type *t = btf__type_by_id(btf, id);
104
105+ if (!t)
106+ continue;
107+
108 if (!btf_is_func(t))
109 continue;
110
111@@ -595,6 +613,8 @@ std::map<std::string, std::vector<std::string>> BTF::get_params(
112 continue;
113
114 t = btf__type_by_id(btf, t->type);
115+ if (!t)
116+ continue;
117
118 _Pragma("GCC diagnostic push")
119 _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"")
120@@ -675,7 +695,7 @@ std::set<std::string> BTF::get_all_structs() const
121 {
122 const struct btf_type *t = btf__type_by_id(btf, id);
123
124- if (!(btf_is_struct(t) || btf_is_union(t) || btf_is_enum(t)))
125+ if (!t || !(btf_is_struct(t) || btf_is_union(t) || btf_is_enum(t)))
126 continue;
127
128 const std::string name = full_type_str(btf, t);
129--
1302.34.1
131
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb
index 937c61f..8767115 100644
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb
@@ -18,6 +18,7 @@ RDEPENDS:${PN} += "bash python3 xz"
18 18
19SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \ 19SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \
20 file://0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch \ 20 file://0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch \
21 file://0001-Fix-segfault-when-btf__type_by_id-returns-NULL.patch \
21" 22"
22SRCREV = "0a318e53343aa51f811183534916a4be65a1871e" 23SRCREV = "0a318e53343aa51f811183534916a4be65a1871e"
23 24