Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulate NMR API failures: Fix SIGSEGV crashes #2268

Merged
merged 3 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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