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

Add Fault Injection in WFP OS APIs #2380

Merged
merged 3 commits into from
Apr 28, 2023
Merged

Conversation

shpalani
Copy link
Collaborator

@shpalani shpalani commented Apr 26, 2023

Description

  • Added fault injection condition in the following WFP OS APIs:
  1. FwpmFilterDeleteById0
  2. FwpmTransactionBegin0
  3. FwpmFilterAdd0
  4. FwpmTransactionAbort0
  5. FwpsCalloutRegister3
  6. FwpmCalloutAdd0
  7. FwpsCalloutUnregisterById0
  8. FwpmEngineOpen0
  9. FwpmProviderAdd0
  10. FwpmSubLayerAdd0
  11. FwpmEngineClose0
  12. FwpsInjectionHandleCreate0
  13. FwpsInjectionHandleDestroy0
  • In net_ebpf_extension_initialize_wfp_components(), added a call to close the session and to unregister the callouts for the failure paths.

  • Fixed an issue in net_ebpf_extension_initialize_wfp_components(), where the failure status was overwritten with FwpmTransactionAbort() return value and returned as success to the caller. This led the code flow to continue with the assumption that the initialization of wfp components (ie, registering callouts and adding callouts) was successful... This caused assert failure during NmrClientAttachProvider flow.

Exit:
   if (!NT_SUCCESS(status)) {  <<< original failed status
        if (is_in_transaction) {
            status = FwpmTransactionAbort(_fwp_engine_handle);   <<<< overwritten
       ...
   }
   NET_EBPF_EXT_RETURN_NTSTATUS(status);   <<<<< return with overwritten value
  • Added traces for some failures.

Note: This is an incremental commit. There are 11 more WFP APIs pending in fwp_um.cpp. Please see #2101 for details.

Testing

_Do any existing tests cover this change? Yes
Are new tests needed? No

Existing test cases with fault injection call stack of 4:
unit_tests.exe: PASSED
netebpfext_unit.exe: PASSED

Documentation

_Is there any documentation impact for this change? No

dthaler
dthaler previously approved these changes Apr 26, 2023
@dthaler
Copy link
Collaborator

dthaler commented Apr 26, 2023

@shpalani rebase to pick up scorecards fix

dthaler
dthaler previously approved these changes Apr 26, 2023
dthaler
dthaler previously approved these changes Apr 27, 2023
@dthaler dthaler enabled auto-merge April 27, 2023 04:09
@dthaler dthaler added the bug Something isn't working label Apr 28, 2023
@dthaler dthaler added this pull request to the merge queue Apr 28, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 28, 2023
@shpalani shpalani added this pull request to the merge queue Apr 28, 2023
Merged via the queue into microsoft:main with commit 45bf2da Apr 28, 2023
63 checks passed
@shpalani shpalani deleted the shpalan/os-fwp branch April 28, 2023 18:49
@shpalani shpalani linked an issue Apr 29, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simulate FWP OS API failures in fwp_um.cpp Simulate NMR and OS API failures
4 participants