Skip to content

Commit

Permalink
Simulate NMR API failures: Fix SIGSEGV crashes (#2268)
Browse files Browse the repository at this point in the history
* Fix SIGSEGV crashes

* Revert changes in ebpf_cryptographic_hash_append

* Add new line
  • Loading branch information
shpalani authored Apr 4, 2023
1 parent dcc2e64 commit 7502790
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/execution_context/ebpf_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ _ebpf_native_provider_attach_client_callback(
goto Done;
}
table = (metadata_table_t*)client_registration_instance->NpiSpecificCharacteristics;
if (!table->programs || !table->maps) {
if (!table || !table->programs || !table->maps) {
result = EBPF_INVALID_ARGUMENT;
goto Done;
}
Expand Down
3 changes: 2 additions & 1 deletion libs/execution_context/ebpf_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ ebpf_program_load_providers(_Inout_ ebpf_program_t* program)
}

general_helper_program_data = (ebpf_program_data_t*)program->general_helper_provider_data->data;
if (general_helper_program_data->program_type_specific_helper_function_addresses == NULL) {
if (!general_helper_program_data ||
general_helper_program_data->program_type_specific_helper_function_addresses == NULL) {
EBPF_LOG_MESSAGE_GUID(
EBPF_TRACELOG_LEVEL_ERROR,
EBPF_TRACELOG_KEYWORD_PROGRAM,
Expand Down
6 changes: 4 additions & 2 deletions libs/platform/user/nmr_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,11 @@ _nmr::client_attach_provider(
std::optional<_nmr::pending_action_t>
_nmr::bind(_Inout_ client_registration& client, _Inout_ provider_registration& provider)
{
PNPIID client_pnpi = client.characteristics.ClientRegistrationInstance.NpiId;
PNPIID provider_pnpi = provider.characteristics.ProviderRegistrationInstance.NpiId;

// Match on NPI ID.
if (*client.characteristics.ClientRegistrationInstance.NpiId !=
*provider.characteristics.ProviderRegistrationInstance.NpiId) {
if (!client_pnpi || !provider_pnpi || *client_pnpi != *provider_pnpi) {
return std::nullopt;
}

Expand Down

0 comments on commit 7502790

Please sign in to comment.