Граф коммитов

160 Коммитов

Автор SHA1 Сообщение Дата
Matthew Ige 8fb3a7e307
[netebpfext] Add per-provider WFP handles to avoid improper use from parallel invocations (#3866)
* add locking

* fix build error

* move to per-provider handle

* move to per provider handle, move to static handle, add cleanup, add error resilience

* remove version

* temporarily move to branch submodule for testing

* update submodule

* reset gitmodules

* PR part 1: Code cleanup, nits

* move engine handle into filter context

* CR - move filter unregister to after filter delete, replace null checks with asserts, remove unneded helper function

* CR
2024-10-10 04:17:31 +00:00
Sharmi f23ab7def5
Support TraceLoggingBinary for map find, update and delete. (#3781)
* Initial commit

* Initial commit

* Added _DEBUG around tail call display

* Renamed key to data

* Removed _DEBUG

* Added SAL annotation, as per the comments

* Added SAL annotation, as per the comments

* Fix crash

* make data non-optional

* Added the check for .key_size != 0

* Removed additional tracing in EBPF_LOG_MESSAGE_BINARY macro

* Merged with main

* Trying 16KB of stack size

* Addressed PR comment

* Added macro with combined traces

* Increased stack size to 32K for DEBUG image

* Fix the string concatenation in macro

* Increase the stack size to 64, and added some logs to check the crashdumps during hangs

* Added retry when the dump file cannot be compressed because it is used by another process

* Expanded stack size for all netebpf wfp callouts

* Addressed PR comments

* Added _DEBUG back

* Increased stack size to 20K for DEBUG

* Add optimatization

* With 4K stack expansion size

* Final commit
2024-10-04 20:20:47 +00:00
Alan Jowett 735ec5277f
Refactor common platform and config into Directory.Build.props (#3891)
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-10-02 19:14:14 +00:00
Anurag Saxena 2d20b264d2
Stack expansion in netebpfext (#3817)
* expand stack

* update usersim submodule

* fix analysis build

* cr comments

* fix analysis failure

* cr comments

* Update netebpfext/net_ebpf_ext_hook_provider.h

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

---------

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2024-09-09 18:11:59 +00:00
Sharmi e4d425cb00
XDP declarations are moved from ebpf_nethooks.h. (#3793)
* Initial commit

* Merge with main

* Removed ebpf_xdp_test_hooks.h in net_ebpf_ext.h

* Removed header not needed

* Addressed PR comments

* Addressed PR comments

* Addressed PR comments

* Keeping the change with SEC(xdp)

* Generated sample files

* Added the generated tests/bpf2c_tests/expected files

* Fixed the output expectation

* Generated expected files after main merge

* Re-push all the generated file
2024-09-06 22:04:43 +00:00
Anurag Saxena c73a0864dd
Multi-attach support for SOCK_ADDR programs (#3751)
* initial commit

* second commit

* third commit

* update lock logic

* fix analysis errors

* backup

* Add tests

* fix

* fix

* fix

* code refactor

* update test

* Revert "update test"

This reverts commit 6770269907.

* Revert "code refactor"

This reverts commit fae36a7d0e.

* Revert "Revert "code refactor""

This reverts commit 3b8e762d33.

* Revert "Revert "update test""

This reverts commit 11610f06ce.

* fix capability in xdp

* add tests, remove filter weight

* invoke wildcard programs, update tests

* fix wildcard invocation logic

* fix wildcard invocation logic, remove sleep from concurrency tests

* move invocation out of the lock, fix tests

* code cleanup, update test

* code cleanup

* remove trace

* cleanup

* update wildcard invocation logic

* code cleanup

* code cleanup

* code cleanup, CR comments

* cr comments, code cleanup

* Update netebpfext/net_ebpf_ext_hook_provider.h

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

* cr comments

* add tests

* cr comments

* code cleanup

* tracing changes

* fix sal

* code cleanup

* code cleanup

* Update netebpfext/net_ebpf_ext.h

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

---------

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2024-09-05 00:32:40 +00:00
Alan Jowett 8c838d1ab5
Stamp all tools with version information. (#3792)
* Stamp all tools with version information.

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Add commit id to nuget package

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Move versioning to Directory.Build.props

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Set correct project type in sample.vcxproj

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Add version info to fuzz tests

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Update tests/socket/resource.h

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

* Revert editor change

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2024-08-27 16:30:12 +00:00
Shankar Seal bde5a20dca
Override `bpf_get_current_pid_tgid` for sock_ops hook. (#3765)
* initial changes.

* sock_addr.

* fixes.

* Update include/ebpf_nethooks.h

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

---------

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2024-08-22 23:27:51 +00:00
Anurag Saxena 03e8c109ce
Fix AV in netebpfext (#3769)
* fix

* fix

* fix
2024-08-14 20:07:32 +00:00
Anurag Saxena 00c9138876
Use `context_header` for tail call perf improvement (#3698)
* fix

* fix

* fix

* fix tests

* fix tests

* change to capabilities, add check for prog_array map

* fix analysis build, add tests

* update documentation

* add context_header_support callback for maps

* CR comment

* change capabilities to bitfield

* Apply suggestions from code review

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

* cr comments

* cr comments

* Apply suggestions from code review

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

* CR comments

---------

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2024-07-15 16:23:51 +00:00
Matthew Ige 366fd7ce1c
Add connection contexts to hash table (#3036)
* add contexts to hash table

* address build failure

* fix build

* fix crash with initialize

* fix test failure issue - incorrect usage of hash_table_find which required double pointer return

* fix initialization and cleanup

* reduce test timeout to 1100

* remove unnecessary epoch/random init in tests

* add contexts to hash table

* address build failure

* fix build

* fix crash with initialize

* fix test failure issue - incorrect usage of hash_table_find which required double pointer return

* fix initialization and cleanup

* reduce test timeout to 1100

* remove unnecessary epoch/random init in tests

* add epoch enter/exit

* remove epoch usage from hash table for connection context

* upadte get followed by delete usage

* use low memory pre allocation

* remove incorrect annotation

* remove incorrect annotation

* move pragma

* add contexts to hash table

* address build failure

* fix build

* fix crash with initialize

* fix test failure issue - incorrect usage of hash_table_find which required double pointer return

* fix initialization and cleanup

* reduce test timeout to 1100

* remove unnecessary epoch/random init in tests

* add contexts to hash table

* address build failure

* fix build

* fix crash with initialize

* fix test failure issue - incorrect usage of hash_table_find which required double pointer return

* fix initialization and cleanup

* reduce test timeout to 1100

* remove unnecessary epoch/random init in tests

* add epoch enter/exit

* remove epoch usage from hash table for connection context

* upadte get followed by delete usage

* use low memory pre allocation

* remove incorrect annotation

* remove incorrect annotation

* move pragma

* CR: move cleanup to a new function, add extra counters for low memory, update comment syntax

* undo spin lock init to 0

* tmp

* tmp

* revert helper changes

* minor cleanup, make test timeout shorter to collect dump

* remove macro

* re queue CICD

* revert test timeout

* reduce test timeout to collect fuzzer logs

* update

* CR: condense multiple globals into a single struct

* use RTL table

* temporarily update submodule for testing

* add annotations

* initialize memory

* remove assert

* memset check

* fix

* fix

* fix case where context may be re-inserted

* remove lru usage, just enumerate the table

* compiler fix

* reset submodule

* add annotation

* add in lru logic

* add back in pragmas

* fix

* CR

* CR

---------

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
Co-authored-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>
2024-05-28 18:50:38 +00:00
Anurag Saxena f7ec168340
Add `total_size` to extension header. (#3573)
* change ebpf_extension_header_t to ebpf_version_header_t

* revert to ebpf_version_header_t

* revert to ebpf_version_header_t

* update header

* update doc

* update doc

* use total_size to get the actual struct size

* Apply suggestions from code review

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

---------

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2024-05-24 01:05:36 +00:00
Dave Thaler d096b21ac5
Update copyright to be eBPF for Windows contributors (#3508)
* Update copyright to be eBPF for Windows contributors

Fixes #3507

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Undo gratuitous formatting changes in expected files

---------

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
2024-05-04 19:55:56 +00:00
Anurag Saxena cf05004d7b
Implement `bpf_get_socket_cookie()` (#3464)
* implement bpf_get_socket_cookie

* fix tests

* fix more tests

* fix tests

* cleanup

* Apply suggestions from code review

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

* fix regression tests

---------

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2024-04-24 23:39:57 +00:00
Shankar Seal 73647f801b
Reallocate packet (#3344)
* reallocate_packet.

* PR Feedback.
2024-04-04 00:49:27 +00:00
Shankar Seal e9fdc9ed84
fixes. (#3422) 2024-04-03 15:44:59 +00:00
Shankar Seal fc973542c9
extension_header (#3326)
* extension_header

* fix logic error.

* Re-purposing the size field to act as the "minor version". Additional validation checks are added.

* PR Feedback.

* fix break due to bad merge with PR #3372
2024-03-30 17:27:09 +00:00
Dhiren Vispute d0b5c6242e
move filter delete auditing to delete notify callback (#3372)
Co-authored-by: Dhiren Vispute <Dhiren.Vispute@microsoft.com>
2024-03-22 07:24:36 +00:00
Shankar Seal 99a4bbd2d9
fix tracing. (#3336) 2024-03-09 22:46:09 +00:00
Dhiren Vispute 125c884ac4
Defer filter list deletion to when deleting filter context, add debugging info and traces (#3300)
Co-authored-by: Dhiren Vispute <Dhiren.Vispute@microsoft.com>
2024-03-08 16:38:54 +00:00
Shankar Seal 66087c57c8
Revert "Helper reallocate packet (#3110)" (#3263)
This reverts commit 13eed744fe.
2024-02-15 02:06:29 +00:00
Dhiren Vispute a2ece4ba26
Bail if we can't enter rundown (not a fatal error in some instances) (#3148)
Co-authored-by: Dhiren Vispute <Dhiren.Vispute@microsoft.com>
2024-01-09 05:53:21 +00:00
Alan Jowett 3c9c72ac26
Set required_irql in sockops and sockaddr program information (#3159)
* Set required_irql in sockops and sockaddr program information

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Update docs/eBpfExtensions.md

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2024-01-05 21:18:21 +00:00
Matthew Ige decc2542a1
Add connected UDP tests to cgroup/sock_addr_connect (#3041)
* add connected UDP Tests

* ensure we do not issue two connect calls

* minor updates

* add debug traces

* temporarily remove connected udp tests

* add connected UDP tests for non-dual stack sockets

* enable v4 tests only

* only test redirect temporarily

* temporarily remove TCP tests

* fix connected udp issue by removing stale contexts

* remove debug tracing, add if check for free

* skip setting redirect context for connected udp

* update ebpf program

* update ebpf program for v6

* remove debug logs

* fix compiler error with incorrect enum

* update to use connection instead of protocol

* update to use connection instead of protocol

* update tests with CR feedback

* update expected

* update to using different key and value types to allow for proper usage of protocol vs connection type
2023-12-12 23:03:15 +00:00
Anurag Saxena f6a478842a
Remove store km lib and code (#3109)
* remove store km lib and code

* fix

* more cleanup

* Apply suggestions from code review

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

---------

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2023-12-12 13:53:04 +00:00
Shankar Seal 13eed744fe
Helper reallocate packet (#3110)
* add reallocate_packet flag to helper prototype struct.

* PR Feedback.

* fix.

* export reallocate_packet flag.
2023-12-11 17:54:34 +00:00
Anurag Saxena 3f5e0ba1ba
Separate out undocked components. (#3055)
* remove not-needed includes

* fix

* fix

* update sample extension

* change include path

* export store APIs from ebpfapi.dll

* fix analyze build

* update dependencies

* add undocked projects

* undock sample_ext driver

* fix build

* more undocking

* fix build

* remove undocked projects from fuzzerdebug

* fix nuget

* remove usersim from export_program_info

* fix configuration manager

* fix tests

* skip building undocked samples for FuzzerDebug builds

* fix build

* try cicd changes

* fix cicd yml

* update export_program_info to not clean up all entries

* code cleanup

* delete global helpers from the store

* code cleanup

* export *delete* store APIs from ebpfapi

* code cleanup

* CR comments

* cr comments

* remove ansi APIs

* CR comments

* cr comments

* fix CI failure

* fix rebase build issues

* change default custom type to bind

* some more fixes

* fix tests

* fix tests

* update expected files

* fix bpf2c tests

* run export_program_info

* fix headers

* CR comments
2023-12-07 21:10:19 +00:00
Matthew Ige 2000dafc4e
Remove XDP hook support from netebpfext.sys (#3040)
* replace XDP guids with XDP_TEST guids

* updated missde instance

* update bpf2c

* leave xdp_hook as is

* remove extra files

* update with new XDP_TEST guid, update other tests to use sample_ext

* update some tests, update test_helper

* update fuzzer

* temporarily remove bpftool tests

* update execution context test

* replace XDP guids with XDP_TEST guids

* updated missde instance

* update bpf2c

* leave xdp_hook as is

* remove extra files

* update with new XDP_TEST guid, update other tests to use sample_ext

* update some tests, update test_helper

* update fuzzer

* temporarily remove bpftool tests

* update execution context test

* build failures

* update sample ext with context_allocate and destroy

* update vm script to use xdp_test

* switch api tests to use sample program

* rename to xdp_Test

* update sample ext

* update incorrect SAL, update netsh tests

* update sample, update tests to use sample where applicable

* update tests

* fix up tests

* fix libbpf tets

* revert unnecessary changes

* remove extra prints

* add back in bpftool tests

* update to use xdp instead of xdp_test for bpftool test

* update atomic_instructions_others.o

* extra debug logs

* updated expected, update bpftool tests

* correct bpftool tests

* more debug logs

* add reg debug

* clear program info

* Attempt fix of buffer overrun

* remove debug logs, minor cleanup, set XDP guids back to their original names

* update docs with xdp_test

* fix guid usage

* CR: remove program, update comments, fix commented out tests, update bpf_program__attach_xdp

* revert changes in libbpf, as they need to use the actual XDP guids

* update comment

* update some XDP tests to use sample ext, comment out some expected failing tests

* update bpftool tests

* fix up bpf prog test run expected output, move to #if instead of comments

* fix up return code issue

* fix bpftool testes

* add some failed xdp tests, set some params to null for sample tests

* update comment

* tmp commit - move to xdp mock

* update unit tests to use mock XDP where possible

* made some samples back to XDP type

* netebpfext unit tests should use xdp_test

* CR
2023-12-06 17:12:17 +00:00
Dhiren Vispute aa07ff485f
Add rundown protection for filter_context (#3017)
Co-authored-by: Dhiren Vispute <Dhiren.Vispute@microsoft.com>
2023-11-30 00:07:44 +00:00
Alan Jowett 66588bdc27
Remove check that prevents fuzzing below minimum size (#2849)
* Remove check that prevents fuzzing below minimum size

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* WIP

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Cleanup handling of request lengths in _ebpf_core_protocol_program_test_run

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Update libs/execution_context/ebpf_core.c

Co-authored-by: Dave Thaler <dthaler@microsoft.com>

* Fix break

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Enable warning 4062

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Remove overactive assert

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-09-20 19:31:54 +00:00
Dave Thaler 83de72512b
Update to use latest usersim (#2858)
* Update to use latest usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update to latest usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Use NonPagedPoolNx instead of NonPagedPool for netebpfext state

NonPagedPool is executable, which we don't want

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-09-20 01:07:46 +00:00
Matthew Ige 7a2b41b479
Add helper function to set redirect context (#2823)
* add new helper function to set redirect context

* WIP

* update typo

* build failure fix

* update expected programs, update tcp_udp_listener to initialize to null terminated

* update expected program with proper clang version

* disable expected failing test

* update comments with periods

* address comment regarding potentially leaked memory

* Add checks for invalid parameters

* update comment

* add tracing for errors

* address CR
2023-09-11 22:40:33 +00:00
Alan Jowett cf0ff81a0f
Disable reference history on release builds (#2819)
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2023-09-06 19:45:51 +00:00
Dave Thaler c947ca63b9
Make runtime binaries not depend on usersim (#2783)
* build ebpfcore under usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Work around analysis warnings

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix installer project

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Temporarily use ubpf branch with memory fix

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* WIP

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* WIP

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Create project for files shared between ebpfapi and the ebpf runtime

Move existing files from libs/platform either to:
* libs/shared, if meant to be common between user-mode and ebpf runtime
* libs/runtime, if meant to be used by the ebpf runtime only (whether in
  user or kernel mode)

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Move ebpf_tracelog.c to shared

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Create shared_user and shared_kernel projects

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* WIP

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* WIP

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Remove usersim from ebpfsvc

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update to cxplat branch of usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Use cxplat_utf8_string

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Cleanup

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix build errors

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix ebpf_allocate_with_tag

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fixes

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Bug fixes

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix use of ebpf_reallocate to not pass a null pointer

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix printf tests

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix memory leaks

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Temporary change to help debug double-free in test

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update to latest usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix analysis warnings

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update to latest usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update usersim to latest

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Change native module to use latest usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update nuget package

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Only call cxplat_cleanup if cxplat_initialize succeeds

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Revert setup_build.vcxproj change

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update usersim to latest

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2023-09-05 17:57:21 +00:00
Dhiren Vispute 2ce05511f0
Add missing traces, some drive-by clean-up (#2750)
Co-authored-by: Dhiren Vispute <dhiren.vispute@microsoft.com>
2023-08-29 19:26:03 +00:00
Dave Thaler b7f82b66c5
Remove cmake build (#2764)
Other projects can now consume ebpf-for-windows in binary form,
using either nuget or MSI install.  We no longer need to build
ebpf-for-windows both ways, so removing the cmake build to free
up build resources and reduce the development cost of maintaining
both msbuild and cmake builds.

Fixes #2743

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-08-18 00:48:10 +00:00
Gianni Trevisiol 4cb79e547d
Isolate eBPF store APIs into atomic km & um libraries. (#2690)
* draft

* wip

* wip

* wip

* wip

* wip - km & um compile

* fix

* fix include order

* wip

* wip

* wip

* wip - api_common

* wip - updated projects

* wip

* wip

* fix merge issues

* wip

* fix C28196/C6387

* wip

* wip

* fix SAL

* cleanup

* fix SAL bugs

* wip - cmake

* add cmake files

* wip

* wip

* update msi artifacts

* wip

* cleanup

* collapse null-checks

* clean-up headers

* refactor return types to ebpf_result_t

* replace ebpf_registry_result_t with ebpf_result_t

* update header

* remove cpp wrapper, misc cleanup.

* rename um/km registry helpers

* cleanup

* cleanup

* update

* nit

* fix

* Added KERNEL_MODE var, so to default to USER_MODE.

* fix cmake

* align result var names with ebpf_result_t

* pr feedback

* add project refs

* Add NativeOnly* cfgs to ebpf_store_helper_km

* Update docs, API reordering in source.

* pr feedback

* Rename types to abstract use of registry

* Normalize all registry API names.

* rename

* merge sln

* fix var typo

* refactor store root keys

* feedback

* doc/comments

* remove KERNEL_MODE

* Force ignore format on all preprocessor code paths.
2023-08-07 19:53:24 +00:00
Dhiren Vispute 021c4d9100
Misc clean-up, added some tracing (#2584)
Co-authored-by: Dhiren Vispute <dhiren.vispute@microsoft.com>
2023-07-31 21:25:30 +00:00
Dave Thaler afab46c2e8
Update usersim to latest (#2717)
Temporarily add usersim/src to paths.
This will get cleaned up in 2308 as part of issue #2677

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-07-31 18:32:05 +00:00
Dave Thaler 792d41cd2f
Update use of usersim library to use Ke* DPC APIs (#2662)
* Update usersim library for DPC API support

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Flush queued DPCs before terminating usersim platform

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix fault injection test

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix test bugs found by fault injection

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Use usersim Ke*Timer apis

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix bad uses of REQUIRE in netebpfext_unit constructors/destructors

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix mismatched initiate/terminate calls

Move Test-FaultInjection.ps1 to the usersim repo

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Use REQUIRE instead of throwing exceptions from unit tests

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Don't use REQUIRE in constructors

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix memory leak bug in netebpf_ext_helper destructor

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix reference count leak in net_ebpf_extension_sock_ops_flow_established_classify

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-07-18 06:47:46 +00:00
Dave Thaler a90097517e
More usersim library cleanup (#2636)
* More usersim library cleanup

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix analyze warning

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Use TraceLogging for printk

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix analysis warnings

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix deadlock in core_helper_fuzzer

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update usersim library

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix call to RpcStringFreeA

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-07-06 23:41:58 +00:00
Dave Thaler ec27659adf
Move usersim code into a separate repo (#2596)
* Use usersim repo

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Remove DISPATCH test code from _preprocess_load_native_module

Per Anurag: the code was added earlier to execute the 2 paths in
native module, and it is not needed anmore IIRC, as the "DISPATCH"
code has been removed now from the native module

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Bug fixes

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Unify some APIs

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix warnings and clean up code

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* updated

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-06-27 15:26:46 +00:00
Anurag Saxena 3e7767032b
Fix redirected_by_self check for dual stack sockets (#2562)
* fix

* cleanup

* fix typo

* redirect_handle per socket_context

* update mock api to catch redirect handle leak

* fix analysis build
2023-06-13 16:30:37 +00:00
Dave Thaler 87b6520c34
Remove JIT and interpreter code from NativeOnly builds (#2475)
* Remove JIT and interpreter code from NativeOnly builds

Fixes #2030
Fixes #2488

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Try conditional project references

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Various test fixes

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Native-only fixes to deploy-ebpf.ps1

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Native-only support for setup-ebpf.ps1

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Native-only support for api_test.exe

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Add connect_redirect_tests to deploy-ebpf.ps1

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* PR feedback from Anurag

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-06-07 15:49:03 +00:00
Gianni Trevisiol d6bcf1958c
Refactor eBPFCore tracing to use less stack space. (#2501)
* refactor ebpfcore tracing

* feedback
2023-05-31 17:26:09 +00:00
Anurag Saxena 3d8f1adfa7
fix (#2532) 2023-05-30 20:59:19 +00:00
Sharmi 67665591aa
Add Fault Injection in Kernel OS APIs in kernel_um.cpp (#2424)
* Add Fault Injection in Kernel OS APIs in kernel_um.cpp

* Removed fault injection from RtlCreateAcl and RtlULongAdd

* Removed fault injection from RtlCreateSecurityDescriptor and RtlSetDaclSecurityDescriptor

* Fixed codecov coverage

* fix SeAccessCheckFromState for the reported Code coverage warnings

* Addressed PR comment
2023-05-09 22:40:27 +00:00
Sharmi b45dff28a3
Part-2: Add Fault injection to FWP OS APIs (#2403)
* To get AddressSanitizer build

* Removed fault injection from FwpmFilterDeleteById0

* Added fault injection to fwp OS APIs

* Analyze fix

* Removed FI from Commit api

* Removed fault injection in  FwpsFlowRemoveContext0
2023-05-06 07:07:09 +00:00
Shankar Seal 2ef233b09f
trace_refactor. (#2371)
* trace_refactor.

* Fix.
2023-05-02 06:24:46 +00:00
Sharmi 45bf2da1cf
Add Fault Injection in WFP OS APIs (#2380)
* Add Fault injection for OS APIs in fwp_um.cpp

* Removed fault injection in FwpmTransactionAbort0

* Changed is_engine_opened typo
2023-04-28 17:52:38 +00:00