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

104 Коммитов

Автор SHA1 Сообщение Дата
Dave Thaler 93b7634d23
Fix sanitizer build of fuzzer (#2201)
* Fix sanitizer build of fuzzer

Fixes #1817

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

* Fixes

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

* More fixes

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

* Disable some build steps for FuzzerDebug

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

* Update github workflows

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

* Update verifier to latest

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

* Fix execution_context_fuzzer build

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

* Fix bpf2c and samples

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

* Fix samples compilation

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

* Fix custom program type sample

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

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-04-13 15:00:49 +00:00
Dave Thaler 35f909deb9
Allow various structs to be const (#2306)
Fixes #2145

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-04-12 17:47:39 +00:00
Shankar Seal 5d32a5b032
Add a WFP provider object. (#2282)
* Add a WFP provider object.

* Apply suggestions from code review

Co-authored-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>

---------

Co-authored-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>
2023-04-07 22:16:45 +00:00
Alan Jowett 46abd1b374
Check program state before permitting linking (#2250)
* Check program state before permitting linking

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

* PR feedback

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

* Don't return pointer to mutable state

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

* Fix code analysis failure

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

* Update libs/execution_context/ebpf_program.h

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

* PR feedback

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

* mend

---------

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-04-05 21:22:45 +00:00
Alan Jowett 240fbb16d8
Convert single line if to if with braces (#2224)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-03-27 15:01:21 +00:00
Shankar Seal b7429c9b50
Redirect list (#2074)
* Simplify connect-redirect classify function.

* PR Feedback.

* Refactor tests.
2023-03-23 02:12:00 +00:00
Anurag Saxena 98893ec15b
Fix memory leaks in netebpfext (#2190)
* fix

* fix memory leaks

* cr comments

* fix analyze failure

* fix sal
2023-03-17 15:53:23 +00:00
Anurag Saxena caa05287b1
Enable low memory simulation for netebpfext unit tests. (#2170)
* add test

* bugfix

* bugfix

* add low_memory_full test

* cr comments

* fix cicd.yml error

* fix, cr comments

* fix build break

* cr comments

* update environment
2023-03-13 18:38:41 +00:00
Alan Jowett 4cf0391526
Refactor low memory test into generic fault injection (#2173)
* Refactor low memory test into generic fault injection

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

* Update number of frames to skip

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

* PR feedback

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

---------

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-03-11 02:42:28 +00:00
Delaram Amiri 82bc565571
Add a connection reauth test in sock_add tests (#2159)
* add test cases for reauth flags

* Update netebpfext/user/fwp_um.cpp

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

* address PR comment

* update the test for reauth

* create one test

* change the comment

* change flag name

* change flag name

* Update netebpfext_unit.cpp

* Update fwp_um.cpp

---------

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-03-09 06:21:33 +00:00
Gianni Trevisiol 1f6d85c999
Wrap registry APIs behind store APIs. (#2114)
* Wrap registry APIs

* pr feedback

* PR feedback: revert splitting implementation from .

* nit

* nit

* nit

* rev

* fix unicode size calc

* remove redundant success check

* revert string length calculation, var rename

* var rename for clarity

* revise store api location, reorg externals

* add error trace, fix cmake

* convert error codes
2023-03-06 23:10:51 +00:00
Anurag Saxena 30f96a64aa
Add netebpfext user mode tests (#2124)
* fix

* add more tests, address cr comments

* fix cicd

* fix cicd

* fix analyze build

* switch to read / write lock

* fix fuzzer

* add concurrent test

* fix

* cr comments

* add sock_addr concurrency tests

* add tests

* add tests

* fix, cleanup

* cr comments

* bugfix
2023-02-28 05:30:38 +00:00
Dhiren Vispute bebb9a14cd
Export new sock_addr specific helper function (windows only) (#2091)
* Export new sock_addr specific helper function (windows only)

* Revert PR 1827, export new sock_addr specific helper function (windows only)

This reverts commit 80bc1cb737.

* add step re. adding standard user credentials as well

* incorporate PR feedback

* documentation fix from PR feedback
2023-02-22 20:43:23 +00:00
Shankar Seal 8e3b180d98
Handle re-auth case. (#2067)
* Handle re-auth case.

* Fix bug.

* check for previous local redirection.

* PR Feedback.

---------

Co-authored-by: Gianni Trevisiol <gtrevi@users.noreply.github.com>
2023-02-22 01:34:21 +00:00
Anurag Saxena 3d92031a29
Query and delete connection context atomically (#2060)
* fix

* cr comments

---------

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-02-21 16:06:12 +00:00
Michael Friesen 2d5d3175b5
XDP: complete TX clones upon injection failure (#2013)
* complete TX clones upon inject failure

* satisfy static analyzer

* fix dispatch input parameter, and ignore output

---------

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>
2023-02-17 18:59:13 +00:00
Delaram Amiri 4283733f25
Replace Windows style type names with types names that match the coding guidelines (#2019)
* clean up code

* fixing the build

* Update libs/ebpfnetsh/elf.cpp

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

* fixing the build

* fixing the build

* fixing the build

* fixing the build

* fixing the build

* fixing the build

* revert HRESULT

* change BOOL type

* change BOOL type

* change BOOL type

* change BOOL type

* change BOOL type

* change BOOL type

* revert LPSERVICE_MAIN_FUNCTION

* revert SERVICE_MAIN_FUNCTION*

* SAL annotation for svcmain.cpp

* revert some SAL annotation

* remove some extra spaces

* fix tests

* change to bool type

* Update map_dll.c

* fix according to dll_main prototype

* fix BOOL

* fix according to dll_main prototype

* BOOl type

* BOOl type

* modify doc for self host runner setup

* modify doc for self host runner setup

* update tests with bool

* Update tests/unit/wer_report_test_wrapper.cpp

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

* Update libs/platform/user/ebpf_platform_user.cpp

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

* Update libs/ebpfnetsh/programs.cpp

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

* change _Null_terminated_ to _Field_z_

* address PR comment

---------

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Gianni Trevisiol <gtrevi@users.noreply.github.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2023-02-16 11:56:32 -08:00
Michael Friesen 5150f2ec55
disable hook extension rundown until NMR binding is complete (#2011)
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-02-14 11:57:47 -08:00
Dave Thaler cb43d4235d
Add test case for XDP_TX (#2029)
* Add test case for XDP_TX

This tests a failure path since FwpsInjectMacSendAsync0 is not implemented
in fwp_um.cpp.  However the CI/CD run ought to repro a leak.

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

* Fix analysis warning

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

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>
2023-02-08 00:57:29 +00:00
Dave Thaler 3d626ff9c1
Clean up order of includes (#2015)
* Clean up order of includes

Fixes #1963

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

* Update clang-format

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

* Clean up headers

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

* Update sort

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

* FIx various build errors

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

* Fix ordering if including a .c file

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

* Fix cmake build

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

* More header cleanup

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

* Update expected bpf2c output

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

* More header fixes

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

* Update expected bpf2c output for custom bpf.c

The generate script does not handle this file.

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

* Fix tests

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

* Fix more expected bpf2c output

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

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2023-02-07 18:32:19 +00:00
Anurag Saxena 0cf88e4ecd
Remove PASSIVE IRQL check for SOCK_ADDR implementation of bpf_is_current_admin() (#2023)
* allow dispatch

* fix

* fix build

* fix

* code cleanup

* code cleanup
2023-02-06 12:39:15 -07:00
Michael Friesen 096f10f7b1
perform a default action if the XDP program fails (#2003)
* perform a default action if the XDP program fails

* drop instead of pass upon program failure
2023-02-03 21:13:36 +00:00
Anurag Saxena 319ba6dc6b
Implement sock_addr specific global helper functions (#1847)
* fix

* add native test

* cleanup

* CR comments

* update expected files

* fix

* cr comments

* add 2 helper

* fix proj

* add admin helper

* fix expected files

* test fix

* fix log

* fix

* fix

* fix

* fix test

* implement global helper, add tests

* fix cmake build

* fix analysis failure, update expected files

* update expected fileS

* reuse bpf_get_current_pid_tgid

* fix tests

* fix helper

* fix tests

* update expected files

* backup

* formatting

* fix bad merge

* cleanup

* cleanup

* update issue number

* add header file

* add standard user test

* update helper definition

* fix

* code cleanup

* code cleanup

* fix kernel test

* add check for API calls

* fix test, PR comments

* pr comments

* add debug logs

* add debug logs, fix netebpfext test

* fix netebpfext test

* comment out log

* add traces to debug

* CR comments

* fix netebpfext_unit sock_addr test

* cr comments
2023-01-30 23:44:30 +00:00
Alan Jowett eced450508
Regenerate and checkin corpus files (#1872)
* Regenerate and checkin corpus files

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

* PR feedback

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

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-01-24 18:29:10 +00:00
Alan Jowett 5bd706092b
Add option to generate .spd files for sample driven PGO (#1931)
* Add option to generate .spd files for sample driven PGO

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

* Fix test failure

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

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-01-20 23:10:24 +00:00
Dave Thaler fcce18ecb9
Add unit tests for BIND, CGROUP_SOCK_ADDR, and SOCK_OPS (#1895)
* Move hook NMR registration into netebpext helper class

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

* Unit test bind hook

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

* Add cgroup sock addr unit test

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

* Add unit tests for rest of cgroup sock addr attach types

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

* Partial sock_ops unit test support

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

* Cleanup

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

* Add sock_ops unit test

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

* Fix code analysis warning

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

* Fix code analysis warning

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

* Fix crash

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

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-01-19 00:03:48 +00:00
Alan Jowett 8c8c2ffa41
Remove dependency on trampoline table for interpret and native. (#1876)
* Remove dependency on trampoline table for interpret and native
Fix for provider attach before wfp initialized

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

* Fix code analysis failure

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

* PR feedback

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

* PR feedback

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

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-01-18 21:04:19 +00:00
Dave Thaler 9020751748
Fix netebpfext verifier bug with prog types other than xdp (#1870)
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2023-01-17 15:05:13 +00:00
Alan Jowett 24c8240a82
Protect use of data retuned by NMR program information provider (#1853)
* Protect use of data returned by NMR program information provider

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-01-10 19:08:15 -08:00
Alan Jowett 9f46c2ad90
Implement context handling for netebpfext (#1840)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2023-01-10 19:22:20 +00:00
Anurag Saxena 80bc1cb737
Support for extension to get the program context (#1827)
* fix

* update doc

* cleanup

* Apply suggestions from code review

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

* fix build break

* cr comments

* fix netebpfext um

* Update netebpfext/net_ebpf_ext_prog_info_provider.c

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

* fix break

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-01-09 20:38:16 +00:00
Alan Jowett 0b293ad804
Fix code analysis annotations for In and In_opt parameters by adding const where appropriate or changing to Inout where appropriate. (#1749)
* Fix code analysis annotations for _In_ and _In_opt_ parameters,
add const where appropriate or change to _Inout_ where appropriate.

The following regex expressions were used to find the problems:
Find _In_ or _In_opt_ that are not const and are not followed by _Post_invalid_ or _Frees_ptr_ or _Post_ptr_invalid_:
```_In_[ ]+(?!.*(const|_Post_invalid_|_Frees_ptr_|_Post_ptr_invalid_))```
```_In_opt_[ ]+(?!.*(const|_Post_invalid_|_Frees_ptr_|_Post_ptr_invalid_))```

Some of the _In_ and _In_opt_ parameters are not const due to required compatibility with the Windows API.
Pointers to functions are const by definition, so the const qualifier is not required.

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

* PR feedback

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

* Fix code analysis failure

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

* PR feedback

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

* PR feedback

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

* PR feedback

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

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2022-12-15 15:58:33 -08:00
Gianni Trevisiol 99b7ece81f
Visual Studio 2022 porting (#1521)
* Draft

* wip - full build

* wip

* Docs & scripts update

* revert test

* Updates to overall GettingStarted.md guide.

* Updated CI/CD scripts

* Update ebpf-verifier cache key

* Fix #1513. Next action forwarded to #1563.

* Bump up epbfverifier to 05bca47

* Fix CRT path.

* Disable sanitizing

* fix cmake build

* Removed unsupported x86 and ARM configurations.

* Test address sanitizer off

* wip -full build w/asan

* asan enabled on ci/cd

* update wdk version to 22621

* wip - full build

* add mock asan

* Update CL param

* wip - proj sync

* wip - ltcg

* wip - driver settings

* wip-build props

* wip - asan opts

* wip-plat asan

* wip-asan

* wip

* wip

* wip-debug

* Branch resync

* Mitigate compiler OOM.

* remove asan mock

* doc update

* doc update

* Removed commented code.

* Added comments for pragma-s
2022-12-08 20:06:57 -07:00
Anurag Saxena 8fd3acf528
Connect redirect implementation (#1651)
* draft fix

* fix

* demo

* fix initial ref counts

* fix

* cleanup

* backup

* checkpoint

* backup

* tests working

* fix analyze errors

* fix netebpfext build / bad merge

* sln file update

* v6 tests

* fix netebpfext user build

* refactor connect_redirect tests

* netebpfext changes

* fix tests

* fix netebpfext user tests

* fix sal

* add sublayer, remove filter_instance

* fix

* fix

* driver_tests

* fix bad merge

* fix scripts

* fix driver tests script

* driver tests script

* script fix

* add trace to debug failure

* fix driver test script

* create context only on allow, and create 2 contexts

* fix script

* netsh fix

* fix scripts

* add tests for pure v4 and v6 sockets

* fix test

* v6 test vm addresses

* remove commented code

* code cleanup

* cleanup

* remove bad_map_name files

* cleanup

* fix tests print statements

* Apply suggestions from code review

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

* CR comments, fixes

* update connection context key, address CR comments

* fix build break, cr comments

* cr comments

* cr comments

* rename

* fix test script

* CR comments

* cleanup

* Apply suggestions from code review

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

* fix

* cr comments

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2022-11-29 20:49:42 +00:00
Alan Jowett 0a9be2779e
Annotate remaining code with _Must_inspect_result_ (#1570)
* Annotate remaining code with _Must_inspect_result_

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

* Fix build

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

* PR feedback

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

* Fix merge failure

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

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>
2022-11-18 13:36:24 -08:00
Dave Thaler bdd4df8c58
Fuzz test netebpfext helper(s) (#1467)
* Use netebpfext_user in fuzz testing

Address the helper function part of #1325

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

* Fix winsock inclusion issues

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

* Fix nmr implementation

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

* Update WDK path for more projects

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

* Disable ubpf warnings

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

* Cleanup

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

* Fix unit tests

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

* Make build install execution context fuzzer corpus

Filed #1505 to improve this

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

* Fix libfuzz harness

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

* Fix MBL use by core helper fuzzer

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

* Fix cmake build

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

* Fix user-mode NMR locking issue

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

* Extra debug statements

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

* More fixes

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

* Cleanup

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

* Fix bad merge

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

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: saxena-anurag <43585259+saxena-anurag@users.noreply.github.com>
2022-11-08 09:31:04 +00:00
Dhiren Vispute a96025afd4
Replace KdPrintEx calls (n NetEbpfExt) with Trace logging calls (#1466) (#1536)
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2022-10-31 16:47:32 -07:00
Dave Thaler 0543c810a7
Refactor netebpfext in preparation for fuzz testing (#1464)
* Refactor netebpfext (#1351)

* refactor netebpfext to allow unit and fuzzing

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

* Normalize parameter casing

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

* Normalize types

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

* Fix release build

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

* Fix CMake build

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

* Fix NetEbpfExt_headers CMake target

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

* Rename unit to user

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

* Switch netebpfext_unit -> netebpfext_user

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

* Flesh out kernel thunk

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

* More canonical naming and W4 clean

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

* Fix prefast issue

* Fix CMake

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

* Fix code analysis

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

* PR feedback

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

* PR feedback

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>

* Clean up fw_thunk.h (#1369)

* Clean up fw_thunk.h

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

* Fix SAL annotations

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

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

* Netebpf ext unit test (#1365)

* Add netebfpext start/stop unit tests

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

* Update NMR thunk and expand netebpf_ext helper

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

* PR feedback

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

* Fix code-analysis issues

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>

* Remove duplicate NMR includes (#1370)

* Remove duplicate NMR includes

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

* PR feedback

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

* PR feedback and more header cleanup

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>

* Refactor NMR user mode to be thread safe (#1371)

* Refactor NMR user mode to be thread safe

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

* PR feedback

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

* PR feedback

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

* PR feedback

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

* PR feedback

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

* PR feedback

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>

* Add a unit test that tests classify_packet in user mode (#1379)

* Add packet test scaffolding

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

* Add test

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

* More of test

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

* Add dummy packet to test

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

* Add dummy program

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

* Cleanup

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

* Fix mock NMR bug

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

* Temporarily add printfs

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

* Incorporate fix for 1378

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

* Fix test bug

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

* Add a packet-drop case to the test

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

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

* Try fixing include path

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

* Fix double free of workitem

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

* Revert unrelated changes in ebpfcore and ebpfapi

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

* PR feedback

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

* PR feedback

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

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2022-10-18 13:21:54 -06:00
Shankar Seal d60725f04e
Fix to issue #1272. (#1402)
Co-authored-by: saxena-anurag <43585259+saxena-anurag@users.noreply.github.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2022-09-19 13:12:30 -06:00
Shankar Seal e4ccdc8b1c
Implement `bpf_prog_detach` and `bpf_prog_detach2` APIs. (#1311)
* Implement bpf_prog_detach and bpf_prog_detach2 APIs.

* fix SAL break.

* PR feedback.

* PR feedback and test changes.

* PR feedback.
2022-08-07 17:21:23 -07:00
saxena-anurag 02f4bf016f
Clean up hard coded program type in EC (#1294)
* fix

* update documentation

* add bpf_obj_get_info_by_fd tests for cgroup_sock_addr

* fix

* cr comment
2022-07-15 13:48:45 -07:00
saxena-anurag 1160f7914e
Registry changes for program and section data. (#1192)
* fix

* backup

* fix backup

* msbuild compiling

* fix release build

* fixes

* cmake build fix

* fix cmake build

* fix analyse build

* fix

Signed-off-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>

* fix expected output

* add pre step for tests

* add pre step for tests

* add -s option, revert this later

* Revert "add -s option, revert this later"

This reverts commit 1f42d100e4.

* code cleanup

Signed-off-by: Anurag Saxena <anusa@microsoft.com>

* rename driver_registry_helper.h

* delete bpf_structs.h

* fix

* hardcode HKLM

* code cleanup

* fix

* backup

* fix backup

* msbuild compiling

* fix release build

* fixes

* cmake build fix

* fix cmake build

* fix analyse build

* fix

Signed-off-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com>

* add pre step for tests

* add pre step for tests

* add -s option, revert this later

* Revert "add -s option, revert this later"

This reverts commit 1f42d100e4.

* code cleanup

Signed-off-by: Anurag Saxena <anusa@microsoft.com>

* rename driver_registry_helper.h

* delete bpf_structs.h

* fix

* hardcode HKLM

* code cleanup

* fix build break

* fix build break, enable warning

* fix bad merge

* cleanup

* fix

* fix tests

* add tests, make ebpf_store_helper platform agnostic

* fixes, cleanup, common code for store APIs

* fix cmake build, driver tests

* cleanup

* code cleanup

* cr comments

* code cleanup

* cleanup

* bugfix

* Apply suggestions from code review

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

* cr comments

* fix build break

* move UM read store APIs to a different file

* cr comments

* cr comments

* cr comments

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2022-06-30 16:53:03 -07:00
Shankar Seal 26624388ea
Add tracelog to netebpfext. (#1247)
* Add tracelog to netebpfext.

* Apply suggestions from code review

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

* PR feedback.

* Fix.

* PR feedback.

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2022-06-30 15:08:02 -07:00
Shankar Seal 025639ba33
Use EX_RUNDOWN_REF for netebpfext rundown. (#1251)
* fix

* fix

* fix.

* fix.

* fix.
2022-06-28 17:52:54 -07:00
Dave Thaler 90eee8717e
Expose interface luid and compartment id to sock_ops and sock_addr hooks (#1222)
* Add interface luid to bpf_sock_addr and bpf_sock_ops

And also add compartment id to bpf_sock_ops for consistency with
bpf_sock_addr, so that it is available to eBPF programs.

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

* Expose interface luid and compartment id to sock_ops and sock_addr hooks

* compartment_id was exposed to sock_addr but not sock_ops
* interface_luid was not exposed to either

Exposing the interface_luid should be a performant way to compensate for
lack of scope_id in the hooks, since the interface luid is available
in the WFP callout, and is more specific than a scope id (so a scope id
can always be looked up from the interface luid in the future if
needed).

Fixes #1129

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

* Update expected bpf2c output

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-06-17 09:31:48 -07:00
Dave Thaler e213b5c963
Add bpf_get_current_pid_tgid() helper (#1107)
* Add bpf_get_current_pid_tgid() helper

Fixes #1106

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

* Fix test

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

* Add KM test

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-05-18 20:12:31 -06:00
Alan Jowett 67baea13b5
Always deref filter context on flow-delete (#1093)
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2022-05-12 14:42:20 -07:00
Alan Jowett 80dd532e1f
Save pointer to IO_WORKITEM before completing detach (#1088)
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2022-05-11 13:41:54 -06:00
saxena-anurag 3b3a06ee3a
fix regression (#1084) 2022-05-11 10:02:25 -07:00
saxena-anurag 377fa0db94
EX_PUSH_LOCK fix (#1078)
* bugfix

* address PR comments, build break
2022-05-10 19:56:31 -06:00