Skip to content

Commit a564171

Browse files
mikeagunMichael Agun
andcommitted
Bump PREVAIL verifier from e68a347b to b24faf5ea and handle breaking changes (microsoft#5078)
* Bump PREVAIL verifier to b9010eee and handle breaking changes Bump external/ebpf-verifier from e68a347b to b9010eee (main), which includes the fix for the verifier_fuzzer CI timeout (issue microsoft#5055). Handle breaking API changes: - Include io/elf_reader.hpp (header split in microsoft#1026) - Re-implement _instype()/collect_stats() locally (removed in microsoft#1042 but needed for ebpf_stat_t public API) - Add resolve_ksym_btf_id nullptr to platform structs - Patch load_elf stream-size fallback for in-memory ELF loading (vbpf/prevail#1048) * bump submodule * Pass Instruction by const ref in _instype * Update DLL dependency baselines for PREVAIL verifier bump --------- Co-authored-by: Michael Agun <danielagun@microsoft.com>
1 parent 7e20f7a commit a564171

7 files changed

Lines changed: 123 additions & 1 deletion

external/ebpf-verifier

libs/api/Verifier.cpp

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
#include "ebpf_tracelog.h"
1111
#include "ebpf_verifier_wrapper.hpp"
1212
#include "elfio_wrapper.hpp"
13+
#pragma warning(push)
14+
#pragma warning(disable : 4100) // unreferenced formal parameter
15+
#pragma warning(disable : 4244) // conversion, possible loss of data
16+
#pragma warning(disable : 4267) // conversion from 'size_t' to 'int'
17+
#pragma warning(disable : 26495) // Always initialize a member variable
18+
#include "io/elf_reader.hpp"
19+
#pragma warning(pop)
1320
#define ebpf_inst ebpf_inst_btf
1421
#include "libbtf/btf_map.h"
1522
#include "libbtf/btf_type_data.h"
@@ -42,6 +49,110 @@ elf_everparse_error(_In_ const char* struct_name, _In_ const char* field_name, _
4249

4350
using namespace std;
4451

52+
// Provide collect_stats locally — it was removed from the verifier public API in a69e70a
53+
// (commit "Human-friendly CLI output for bin/prevail"), but we still need it for the
54+
// verbose program-info stats reported by ebpf_api_elf_enumerate_programs.
55+
static std::string
56+
_instype(const prevail::Instruction& ins)
57+
{
58+
if (const auto pcall = std::get_if<prevail::Call>(&ins)) {
59+
if (pcall->is_map_lookup) {
60+
return "call_1";
61+
}
62+
if (pcall->pairs.empty()) {
63+
if (std::ranges::all_of(pcall->singles, [](const prevail::ArgSingle arg) {
64+
return arg.kind == prevail::ArgSingle::Kind::ANYTHING;
65+
})) {
66+
return "call_nomem";
67+
}
68+
}
69+
return "call_mem";
70+
} else if (std::holds_alternative<prevail::Callx>(ins)) {
71+
return "callx";
72+
} else if (std::holds_alternative<prevail::CallBtf>(ins)) {
73+
return "call_btf";
74+
} else if (const auto pimm = std::get_if<prevail::Mem>(&ins)) {
75+
return pimm->is_load ? "load" : "store";
76+
} else if (std::holds_alternative<prevail::Atomic>(ins)) {
77+
return "load_store";
78+
} else if (std::holds_alternative<prevail::Packet>(ins)) {
79+
return "packet_access";
80+
} else if (const auto pins = std::get_if<prevail::Bin>(&ins)) {
81+
switch (pins->op) {
82+
case prevail::Bin::Op::MOV:
83+
case prevail::Bin::Op::MOVSX8:
84+
case prevail::Bin::Op::MOVSX16:
85+
case prevail::Bin::Op::MOVSX32:
86+
return "assign";
87+
default:
88+
return "arith";
89+
}
90+
} else if (std::holds_alternative<prevail::Un>(ins)) {
91+
return "arith";
92+
} else if (std::holds_alternative<prevail::LoadMapFd>(ins)) {
93+
return "assign";
94+
} else if (std::holds_alternative<prevail::LoadMapAddress>(ins)) {
95+
return "assign";
96+
} else if (std::holds_alternative<prevail::LoadPseudo>(ins)) {
97+
return "assign";
98+
} else if (std::holds_alternative<prevail::Assume>(ins)) {
99+
return "assume";
100+
} else {
101+
return "other";
102+
}
103+
}
104+
105+
static std::map<std::string, int>
106+
collect_stats(const prevail::Program& prog)
107+
{
108+
std::map<std::string, int> res;
109+
for (const char* stat_name :
110+
{"instructions",
111+
"joins",
112+
"other",
113+
"jumps",
114+
"assign",
115+
"arith",
116+
"load",
117+
"store",
118+
"load_store",
119+
"packet_access",
120+
"call_1",
121+
"call_mem",
122+
"call_nomem",
123+
"reallocate",
124+
"map_in_map",
125+
"arith64",
126+
"arith32"}) {
127+
res[stat_name] = 0;
128+
}
129+
for (const prevail::Label& label : prog.labels()) {
130+
res["instructions"]++;
131+
const prevail::Instruction& cmd = prog.instruction_at(label);
132+
if (const auto pins = std::get_if<prevail::LoadMapFd>(&cmd)) {
133+
if (pins->mapfd == -1) {
134+
res["map_in_map"] = 1;
135+
}
136+
}
137+
if (const auto pins = std::get_if<prevail::Call>(&cmd)) {
138+
if (pins->reallocate_packet) {
139+
res["reallocate"] = 1;
140+
}
141+
}
142+
if (const auto pins = std::get_if<prevail::Bin>(&cmd)) {
143+
res[pins->is64 ? "arith64" : "arith32"]++;
144+
}
145+
res[_instype(cmd)]++;
146+
if (prog.cfg().in_degree(label) > 1) {
147+
res["joins"]++;
148+
}
149+
if (prog.cfg().out_degree(label) > 1) {
150+
res["jumps"]++;
151+
}
152+
}
153+
return res;
154+
}
155+
45156
typedef struct _section_program_map
46157
{
47158
string section_name;
@@ -359,6 +470,7 @@ load_byte_code(
359470
}
360471

361472
std::stringstream elf_stream(std::string(elf_data.begin(), elf_data.end()));
473+
362474
raw_programs = read_elf(elf_stream, object_name, section_name_string, "", verifier_options, platform);
363475

364476
if (raw_programs.size() == 0) {

libs/api/windows_platform.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ const prevail::ebpf_platform_t g_ebpf_platform_windows = {
9797
get_helper_prototype_windows,
9898
is_helper_usable_windows,
9999
nullptr, // resolve_builtin_call_windows,
100+
nullptr, // resolve_ksym_btf_id_windows,
100101
nullptr, // get_builtin_call_windows,
101102
nullptr, // resolve_kfunc_call_windows,
102103
sizeof(ebpf_map_definition_in_file_t),

libs/service/windows_platform_service.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const prevail::ebpf_platform_t g_ebpf_platform_windows_service = {
1717
get_helper_prototype_windows,
1818
is_helper_usable_windows,
1919
nullptr, // resolve_builtin_call_windows,
20+
nullptr, // resolve_ksym_btf_id_windows,
2021
nullptr, // get_builtin_call_windows,
2122
nullptr, // resolve_kfunc_call_windows,
2223
sizeof(ebpf_map_definition_in_memory_t),

scripts/check_binary_dependencies_ebpfapi_dll_nativeonly_release.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ ADVAPI32.dll
22
api-ms-win-core-debug-l1-1-0.dll
33
api-ms-win-core-errorhandling-l1-1-0.dll
44
api-ms-win-core-file-l1-1-0.dll
5+
api-ms-win-core-file-l1-2-2.dll
6+
api-ms-win-core-file-l2-1-0.dll
57
api-ms-win-core-handle-l1-1-0.dll
68
api-ms-win-core-heap-l2-1-0.dll
79
api-ms-win-core-interlocked-l1-1-0.dll

scripts/check_binary_dependencies_ebpfapi_dll_regular_debug.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ api-ms-win-core-debug-l1-1-0.dll
33
api-ms-win-core-errorhandling-l1-1-0.dll
44
api-ms-win-core-file-l1-1-0.dll
55
api-ms-win-core-file-l1-2-0.dll
6+
api-ms-win-core-file-l1-2-2.dll
67
api-ms-win-core-file-l2-1-0.dll
8+
api-ms-win-core-file-l2-1-2.dll
79
api-ms-win-core-handle-l1-1-0.dll
810
api-ms-win-core-heap-l1-1-0.dll
911
api-ms-win-core-heap-l2-1-0.dll
@@ -12,6 +14,7 @@ api-ms-win-core-io-l1-1-0.dll
1214
api-ms-win-core-libraryloader-l1-2-0.dll
1315
api-ms-win-core-localization-l1-2-0.dll
1416
api-ms-win-core-memory-l1-1-0.dll
17+
api-ms-win-core-processenvironment-l1-1-0.dll
1518
api-ms-win-core-processthreads-l1-1-0.dll
1619
api-ms-win-core-processthreads-l1-1-1.dll
1720
api-ms-win-core-profile-l1-1-0.dll

scripts/check_binary_dependencies_ebpfsvc_exe_regular_debug.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ api-ms-win-core-debug-l1-1-0.dll
33
api-ms-win-core-errorhandling-l1-1-0.dll
44
api-ms-win-core-file-l1-1-0.dll
55
api-ms-win-core-file-l1-2-0.dll
6+
api-ms-win-core-file-l1-2-2.dll
67
api-ms-win-core-file-l2-1-0.dll
8+
api-ms-win-core-file-l2-1-2.dll
79
api-ms-win-core-handle-l1-1-0.dll
810
api-ms-win-core-heap-l1-1-0.dll
911
api-ms-win-core-heap-l2-1-0.dll
@@ -12,6 +14,7 @@ api-ms-win-core-io-l1-1-0.dll
1214
api-ms-win-core-libraryloader-l1-2-0.dll
1315
api-ms-win-core-localization-l1-2-0.dll
1416
api-ms-win-core-memory-l1-1-0.dll
17+
api-ms-win-core-processenvironment-l1-1-0.dll
1518
api-ms-win-core-processthreads-l1-1-0.dll
1619
api-ms-win-core-processthreads-l1-1-1.dll
1720
api-ms-win-core-profile-l1-1-0.dll

0 commit comments

Comments
 (0)