Skip to content

Commit

Permalink
Pickup latest ebpf-verifier (#1197)
Browse files Browse the repository at this point in the history
* Pickup latest ebpf-verifier

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Fix expected error message from failure to parse

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Pickup latest ELFIO fixes

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
  • Loading branch information
Alan-Jowett and Alan Jowett committed Jun 14, 2022
1 parent 83e52b9 commit 8bf0c2b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion external/ebpf-verifier
15 changes: 10 additions & 5 deletions tests/end_to_end/end_to_end.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ TEST_CASE("verify section", "[end_to_end]")
}

void
verify_bad_section(const char* path)
verify_bad_section(const char* path, const std::string& expected_error_message)
{
_test_helper_end_to_end test_helper;
const char* error_message = nullptr;
Expand All @@ -923,13 +923,18 @@ verify_bad_section(const char* path)
result = ebpf_api_elf_verify_section_from_file(path, "xdp", false, &report, &error_message, &stats);
REQUIRE(result != 0);
REQUIRE(report == nullptr);
std::string expected_error_message = "error: No symbol section found in ELF file " + std::string(path);
REQUIRE(strcmp(error_message, expected_error_message.c_str()) == 0);
REQUIRE(std::string(error_message) == expected_error_message);
ebpf_free_string(report);
ebpf_free_string(error_message);
}
TEST_CASE("verify bad1.o", "[end_to_end][fuzzed]") { verify_bad_section(SAMPLE_PATH "bad\\bad1.o"); }
TEST_CASE("verify bad2.o", "[end_to_end][fuzzed]") { verify_bad_section(SAMPLE_PATH "bad\\bad2.o"); }
TEST_CASE("verify bad1.o", "[end_to_end][fuzzed]")
{
verify_bad_section(SAMPLE_PATH "bad\\bad1.o", "error: No symbol section found in ELF file bad\\bad1.o");
}
TEST_CASE("verify bad2.o", "[end_to_end][fuzzed]")
{
verify_bad_section(SAMPLE_PATH "bad\\bad2.o", "error: Can't process ELF file bad\\bad2.o");
}

static void
_cgroup_load_test(
Expand Down
2 changes: 1 addition & 1 deletion tools/bpf2c/bpf_code_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ bpf_code_generator::extract_relocations_and_maps(const std::string& section_name
for (ELFIO::Elf_Xword index = 0; index < relocation_count; index++) {
ELFIO::Elf64_Addr offset{};
ELFIO::Elf_Word symbol{};
unsigned char type{};
unsigned int type{};
ELFIO::Elf_Sxword addend{};
relocation_reader.get_entry(index, offset, symbol, type, addend);
{
Expand Down

0 comments on commit 8bf0c2b

Please sign in to comment.