Skip to content

Commit

Permalink
Merge branch 'main' into verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
dthaler authored Mar 4, 2024
2 parents 85315d9 + dccf443 commit ffd0e85
Show file tree
Hide file tree
Showing 24 changed files with 3,406 additions and 10,496 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
egress-policy: audit

- name: 'Checkout Repository'
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: 'Dependency Review'
uses: actions/dependency-review-action@0efb1d1d84fc9633afcdaad14c485cbbc90ef46c # v2.5.1
4 changes: 2 additions & 2 deletions .github/workflows/nuget_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:


- name: Cache nuget packages
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
env:
cache-name: cache-nuget-modules
with:
Expand All @@ -61,7 +61,7 @@ jobs:
nuget update -noninteractive -verbosity detailed ${{env.SOLUTION_FILE_PATH}}
- name: Create Pull Request
uses: peter-evans/create-pull-request@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50
uses: peter-evans/create-pull-request@a4f52f8033a6168103c2538976c07b467e8163bc
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update NuGet packages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ossar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

- name: Download build artifact
if: (steps.skip_check.outputs.should_skip != 'true') && success()
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427
id: download_artifact
with:
name: ${{inputs.build_artifact}}-${{matrix.configurations}}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
# Add cache entry for any choco packages that are installed.
# The cache key is based on the hash of this file so if any choco packages are added or removed, the cache will be invalidated.
if: steps.skip_check.outputs.should_skip != 'true'
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
env:
cache-name: cache-choco-packages
with:
Expand All @@ -138,7 +138,7 @@ jobs:
- name: Cache nuget packages
if: steps.skip_check.outputs.should_skip != 'true'
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
env:
cache-name: cache-nuget-modules
with:
Expand All @@ -148,7 +148,7 @@ jobs:
- name: Cache verifier project
# The hash is based on the HEAD of the ebpf-verifier submodule, the Directory.Build.props file, and the build variant.
if: steps.skip_check.outputs.should_skip != 'true'
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
env:
cache-name: cache-verifier-project
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/reusable-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
- name: Download build artifact
if: (steps.skip_check.outputs.should_skip != 'true') && success()
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427
id: download_artifact
with:
name: ${{inputs.build_artifact}}-${{matrix.configurations}}
Expand Down Expand Up @@ -280,7 +280,7 @@ jobs:

- name: Upload Report to Codecov attempt 1
if: (steps.skip_check.outputs.should_skip != 'true') && (steps.check_coverage.outputs.files_exists == 'true')
uses: codecov/codecov-action@0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab
id: upload_code_coverage_report_1
continue-on-error: true
with:
Expand All @@ -295,7 +295,7 @@ jobs:

- name: Upload Report to Codecov attempt 2
if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_1.outcome == 'failure')
uses: codecov/codecov-action@0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab
id: upload_code_coverage_report_2
continue-on-error: true
with:
Expand All @@ -310,7 +310,7 @@ jobs:

- name: Upload Report to Codecov attempt 3
if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_2.outcome == 'failure')
uses: codecov/codecov-action@0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab
id: upload_code_coverage_report_3
continue-on-error: true
with:
Expand All @@ -325,7 +325,7 @@ jobs:

- name: Upload Report to Codecov attempt 4
if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_3.outcome == 'failure')
uses: codecov/codecov-action@0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab
id: upload_code_coverage_report_4
continue-on-error: true
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload-perf-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
egress-policy: audit

- name: Download performance result artifacts
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427
with:
name: Test-Logs-${{inputs.result_artifact}}
path: ${{github.workspace}}/results_artifact
Expand Down
2 changes: 1 addition & 1 deletion external/Catch2
Submodule Catch2 updated 66 files
+81 −0 .clang-tidy
+49 −0 .github/workflows/linux-other-builds.yml
+1 −1 CMakeLists.txt
+26 −0 docs/release-notes.md
+1 −2 examples/210-Evt-EventListeners.cpp
+1 −1 examples/231-Cfg-OutputStreams.cpp
+1 −1 examples/232-Cfg-CustomMain.cpp
+1 −1 examples/300-Gen-OwnGenerator.cpp
+9 −8 examples/301-Gen-MapTypeConversion.cpp
+56 −37 extras/catch_amalgamated.cpp
+173 −59 extras/catch_amalgamated.hpp
+1 −1 meson.build
+1 −0 src/catch2/catch_message.cpp
+0 −1 src/catch2/catch_registry_hub.cpp
+1 −1 src/catch2/catch_test_case_info.hpp
+5 −5 src/catch2/catch_tostring.cpp
+2 −2 src/catch2/catch_tostring.hpp
+1 −1 src/catch2/catch_version.cpp
+1 −1 src/catch2/catch_version_macros.hpp
+1 −1 src/catch2/internal/catch_commandline.cpp
+6 −6 src/catch2/internal/catch_console_colour.cpp
+1 −1 src/catch2/internal/catch_enum_values_registry.hpp
+2 −2 src/catch2/internal/catch_jsonwriter.cpp
+2 −2 src/catch2/internal/catch_jsonwriter.hpp
+1 −1 src/catch2/internal/catch_reporter_spec_parser.cpp
+7 −3 src/catch2/internal/catch_section.hpp
+20 −7 src/catch2/internal/catch_string_manip.cpp
+2 −2 src/catch2/internal/catch_stringref.hpp
+4 −4 src/catch2/internal/catch_test_registry.hpp
+2 −2 src/catch2/reporters/catch_reporter_console.cpp
+1 −2 src/catch2/reporters/catch_reporter_cumulative_base.cpp
+2 −2 src/catch2/reporters/catch_reporter_json.cpp
+1 −1 src/catch2/reporters/catch_reporter_junit.cpp
+1 −1 src/catch2/reporters/catch_reporter_multi.hpp
+1 −1 src/catch2/reporters/catch_reporter_sonarqube.hpp
+2 −2 src/catch2/reporters/catch_reporter_teamcity.hpp
+1 −1 tests/ExtraTests/X22-BenchmarksInCumulativeReporter.cpp
+1 −0 tests/ExtraTests/X29-CustomArgumentsForReporters.cpp
+2 −2 tests/ExtraTests/X91-AmalgamatedCatch.cpp
+21 −21 tests/SelfTest/Baselines/compact.sw.approved.txt
+21 −21 tests/SelfTest/Baselines/compact.sw.multi.approved.txt
+70 −54 tests/SelfTest/Baselines/console.sw.approved.txt
+70 −54 tests/SelfTest/Baselines/console.sw.multi.approved.txt
+2 −0 tests/SelfTest/Baselines/junit.sw.approved.txt
+2 −0 tests/SelfTest/Baselines/junit.sw.multi.approved.txt
+2 −0 tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+2 −0 tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
+25 −25 tests/SelfTest/Baselines/tap.sw.approved.txt
+25 −25 tests/SelfTest/Baselines/tap.sw.multi.approved.txt
+84 −72 tests/SelfTest/Baselines/xml.sw.approved.txt
+84 −72 tests/SelfTest/Baselines/xml.sw.multi.approved.txt
+2 −2 tests/SelfTest/IntrospectiveTests/Details.tests.cpp
+0 −1 tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp
+1 −1 tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp
+11 −0 tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp
+1 −1 tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp
+1 −1 tests/SelfTest/IntrospectiveTests/TextFlow.tests.cpp
+7 −7 tests/SelfTest/UsageTests/Benchmark.tests.cpp
+1 −1 tests/SelfTest/UsageTests/Class.tests.cpp
+2 −2 tests/SelfTest/UsageTests/Exception.tests.cpp
+7 −7 tests/SelfTest/UsageTests/Matchers.tests.cpp
+5 −5 tests/SelfTest/UsageTests/Message.tests.cpp
+6 −6 tests/SelfTest/UsageTests/Misc.tests.cpp
+10 −21 tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp
+2 −2 tests/SelfTest/UsageTests/Tricky.tests.cpp
+1 −1 tools/scripts/releaseCommon.py
75 changes: 75 additions & 0 deletions include/bpf_helper_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,78 @@ EBPF_HELPER(int32_t, bpf_is_current_admin, (const void* ctx));
#ifndef __doxygen
#define bpf_is_current_admin ((bpf_is_current_admin_t)BPF_FUNC_is_current_admin)
#endif

/**
* @brief Copy memory from one location to another.
*
* @param[in] destination Destination buffer.
* @param[in] destination_size Size of the destination buffer.
* @param[in] source Source buffer.
* @param[in] source_size Size of the source buffer.
*
* @retval 0 The operation was successful.
* @retval -EINVAL One or more parameters are invalid.
*/
EBPF_HELPER(long, bpf_memcpy, (void* destination, uint32_t destination_size, const void* source, uint32_t source_size));
#ifndef __doxygen
#define bpf_memcpy ((bpf_memcpy_t)BPF_FUNC_memcpy)
#endif

/**
* @brief Compare two memory regions.
*
* @param[in] memory1 First memory region.
* @param[in] memory1_size Size of the first memory region.
* @param[in] memory2 Second memory region.
* @param[in] memory2_size Size of the second memory region.
*
* @returns 0 if the contents of memory regions are equal, a negative value if the contents of memory1 is less than the
* contents memory2, or a positive value if the contents memory1 is greater than the contents memory2.
*/

EBPF_HELPER(int, bpf_memcmp, (const void* memory1, uint32_t memory1_size, const void* memory2, uint32_t memory2_size));
#ifndef __doxygen
#define bpf_memcmp ((bpf_memcmp_t)BPF_FUNC_memcmp)
#endif

/**
* @brief Set memory to a specific value.
*
* @param[in] memory Memory region to set.
* @param[in] size Size of the memory region.
* @param[in] value Value to set the memory region to.
*
* @returns Pointer to the memory region, or a negative error in case of failure.
*/

EBPF_HELPER(long, bpf_memset, (void* memory, uint32_t size, int value));
#ifndef __doxygen
#define bpf_memset ((bpf_memset_t)BPF_FUNC_memset)
#endif

/**
* @brief Copy memory from one location to another, handling overlapping regions.
*
* @param[in] destination Destination buffer.
* @param[in] destination_size Size of the destination buffer.
* @param[in] source Source buffer.
* @param[in] source_size Size of the source buffer.
*
* @retval 0 The operation was successful.
* @retval -EINVAL One or more parameters are invalid.
*/

EBPF_HELPER(
long, bpf_memmove, (void* destination, uint32_t destination_size, const void* source, uint32_t source_size));
#ifndef __doxygen
#define bpf_memmove ((bpf_memmove_t)BPF_FUNC_memmove)
#endif

#if __clang__
#define memcpy(dest, src, dest_size) bpf_memcpy(dest, dest_size, src, dest_size)
#define memcmp(mem1, mem2, mem1_size) bpf_memcmp(mem1, mem1_size, mem2, mem1_size)
#define memset(mem, mem_size, value) bpf_memset(mem, mem_size, value)
#define memmove(dest, src, dest_size) bpf_memmove(dest, dest_size, src, dest_size)
#define memcpy_s bpf_memcpy
#define memmove_s bpf_memmove
#endif
4 changes: 4 additions & 0 deletions include/ebpf_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ typedef enum
BPF_FUNC_get_current_pid_tgid = 19, ///< \ref bpf_get_current_pid_tgid
BPF_FUNC_get_current_logon_id = 20, ///< \ref bpf_get_current_logon_id
BPF_FUNC_is_current_admin = 21, ///< \ref bpf_is_current_admin
BPF_FUNC_memcpy = 22, ///< \ref bpf_memcpy
BPF_FUNC_memcmp = 23, ///< \ref bpf_memcmp
BPF_FUNC_memset = 24, ///< \ref bpf_memset
BPF_FUNC_memmove = 25, ///< \ref bpf_memmove
} ebpf_helper_id_t;

// Cross-platform BPF program types.
Expand Down
80 changes: 80 additions & 0 deletions libs/execution_context/ebpf_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,29 @@ static uint64_t
_ebpf_core_get_current_logon_id(_In_ const void* ctx);
static int32_t
_ebpf_core_is_current_admin(_In_ const void* ctx);
static int32_t
_ebpf_core_memcpy(
_Out_writes_(destination_size) void* destination,
size_t destination_size,
_In_reads_(source_size) const void* source,
size_t source_size);

static int32_t
_ebpf_core_memcmp(
_In_reads_(buffer1_length) const void* buffer1,
size_t buffer1_length,
_In_reads_(buffer2_length) const void* buffer2,
size_t buffer2_length);

static uintptr_t
_ebpf_core_memset(_Out_writes_(length) void* buffer, size_t length, int value);

static int32_t
_ebpf_core_memmove(
_Out_writes_(destination_length) void* destination,
size_t destination_length,
_In_reads_(source_length) const void* source,
size_t source_length);

#define EBPF_CORE_GLOBAL_HELPER_EXTENSION_VERSION 0

Expand Down Expand Up @@ -107,6 +130,10 @@ static const void* _ebpf_general_helpers[] = {
(void*)&_ebpf_core_get_pid_tgid,
(void*)&_ebpf_core_get_current_logon_id,
(void*)&_ebpf_core_is_current_admin,
(void*)&_ebpf_core_memcpy,
(void*)&_ebpf_core_memcmp,
(void*)&_ebpf_core_memset,
(void*)&_ebpf_core_memmove,
};

static const ebpf_helper_function_addresses_t _ebpf_global_helper_function_dispatch_table = {
Expand Down Expand Up @@ -2340,6 +2367,59 @@ _ebpf_core_map_peek_elem(_Inout_ ebpf_map_t* map, _Out_ uint8_t* value)
return -ebpf_map_peek_entry(map, 0, value, EBPF_MAP_FLAG_HELPER);
}

static int32_t
_ebpf_core_memcpy(
_Out_writes_(destination_size) void* destination,
size_t destination_size,
_In_reads_(source_size) const void* source,
size_t source_size)
{
if (source_size > destination_size) {
return -EINVAL;
}
return memcpy_s(destination, destination_size, source, source_size);
}

static uintptr_t
_ebpf_core_memset(_Out_writes_(length) void* buffer, size_t length, int value)
{
return (uintptr_t)memset(buffer, value, length);
}

static int32_t
_ebpf_core_memcmp(
_In_reads_(buffer1_length) const void* buffer1,
size_t buffer1_length,
_In_reads_(buffer2_length) const void* buffer2,
size_t buffer2_length)
{
int32_t result = memcmp(buffer1, buffer2, buffer1_length < buffer2_length ? buffer1_length : buffer2_length);

if (result == 0) {
if (buffer1_length < buffer2_length) {
result = -1;
} else if (buffer1_length > buffer2_length) {
result = 1;
}
} else {
result = result < 0 ? -1 : 1;
}
return result;
}

static int32_t
_ebpf_core_memmove(
_Out_writes_(destination_length) void* destination,
size_t destination_length,
_In_reads_(source_length) const void* source,
size_t source_length)
{
if (source_length > destination_length) {
return -EINVAL;
}
return memmove_s(destination, destination_length, source, source_length);
}

typedef enum _ebpf_protocol_call_type
{
EBPF_PROTOCOL_FIXED_REQUEST_NO_REPLY,
Expand Down
31 changes: 31 additions & 0 deletions libs/execution_context/ebpf_general_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,37 @@ ebpf_helper_function_prototype_t ebpf_core_helper_function_prototype_array[] = {
EBPF_RETURN_TYPE_INTEGER,
{EBPF_ARGUMENT_TYPE_PTR_TO_CTX}},
{BPF_FUNC_is_current_admin, "bpf_is_current_admin", EBPF_RETURN_TYPE_INTEGER, {EBPF_ARGUMENT_TYPE_PTR_TO_CTX}},
{BPF_FUNC_memcpy,
"bpf_memcpy",
EBPF_RETURN_TYPE_INTEGER,
{
EBPF_ARGUMENT_TYPE_PTR_TO_WRITABLE_MEM,
EBPF_ARGUMENT_TYPE_CONST_SIZE_OR_ZERO,
EBPF_ARGUMENT_TYPE_PTR_TO_READABLE_MEM,
EBPF_ARGUMENT_TYPE_CONST_SIZE_OR_ZERO,
}},
{BPF_FUNC_memcmp,
"bpf_memcmp",
EBPF_RETURN_TYPE_INTEGER,
{
EBPF_ARGUMENT_TYPE_PTR_TO_READABLE_MEM,
EBPF_ARGUMENT_TYPE_CONST_SIZE_OR_ZERO,
EBPF_ARGUMENT_TYPE_PTR_TO_READABLE_MEM,
EBPF_ARGUMENT_TYPE_CONST_SIZE_OR_ZERO,
}},
{BPF_FUNC_memset,
"bpf_memset",
EBPF_RETURN_TYPE_INTEGER,
{EBPF_ARGUMENT_TYPE_PTR_TO_WRITABLE_MEM, EBPF_ARGUMENT_TYPE_CONST_SIZE_OR_ZERO, EBPF_ARGUMENT_TYPE_ANYTHING}},
{BPF_FUNC_memmove,
"bpf_memmove",
EBPF_RETURN_TYPE_INTEGER,
{
EBPF_ARGUMENT_TYPE_PTR_TO_WRITABLE_MEM,
EBPF_ARGUMENT_TYPE_CONST_SIZE_OR_ZERO,
EBPF_ARGUMENT_TYPE_PTR_TO_READABLE_MEM,
EBPF_ARGUMENT_TYPE_CONST_SIZE_OR_ZERO,
}},
};

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit ffd0e85

Please sign in to comment.