diff --git a/ebpfsvc/rpc_api.cpp b/ebpfsvc/rpc_api.cpp index f55b4d1e61..a4972149de 100644 --- a/ebpfsvc/rpc_api.cpp +++ b/ebpfsvc/rpc_api.cpp @@ -23,14 +23,10 @@ ebpf_server_verify_and_load_program( if (info->instruction_count == 0) { return EBPF_INVALID_ARGUMENT; } - *logs = nullptr; - *logs_size = 0; // Set the handle of program being verified in thread-local storage. set_program_under_verification(reinterpret_cast(info->program_handle)); - const char* ebpf_logs = nullptr; - uint32_t ebpf_logs_size = 0; result = ebpf_verify_and_load_program( &info->program_type, reinterpret_cast(info->program_handle), @@ -40,19 +36,8 @@ ebpf_server_verify_and_load_program( info->handle_map, info->instruction_count, reinterpret_cast(info->instructions), - &ebpf_logs, - &ebpf_logs_size); - - if (ebpf_logs) { - // The ebpf_logs buffer was allocated by the ebpf allocator whereas we - // must return a string allocated by the MIDL allocator. - *logs = (char*)MIDL_user_allocate(ebpf_logs_size); - if (*logs) { - memcpy(*logs, ebpf_logs, ebpf_logs_size); - ebpf_free((void*)ebpf_logs); - *logs_size = ebpf_logs_size; - } - } + const_cast(logs), + logs_size); ebpf_clear_thread_local_storage(); return result; diff --git a/ebpfsvc/rpc_util.cpp b/ebpfsvc/rpc_util.cpp index e0b887ed36..12b33f3691 100644 --- a/ebpfsvc/rpc_util.cpp +++ b/ebpfsvc/rpc_util.cpp @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation // SPDX-License-Identifier: MIT +#include "ebpf_platform.h" #include "svc_common.h" #include @@ -117,11 +118,11 @@ shutdown_rpc_server() _Must_inspect_result_ _Ret_maybenull_ _Post_writable_byte_size_(size) void* __RPC_USER MIDL_user_allocate(_In_ size_t size) { - return malloc(size); + return ebpf_allocate(size); } void __RPC_USER MIDL_user_free(_Pre_maybenull_ _Post_invalid_ void* p) { - free(p); + ebpf_free(p); }