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

44 Коммитов

Автор SHA1 Сообщение Дата
Alan Jowett c95a90219e
Emulate driver verifier systematic low memory mode (#1512)
* Emulate driver verifier systematic low memory mode

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
2022-11-09 15:28:09 -07: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
saxena-anurag e7d14cafd5
fix (#1548) 2022-11-01 14:31:35 -07:00
Alan Jowett 9e29725ef0
Gather dumps on STATUS_STACK_BUFFER_OVERRUN exception (#1199)
* Gather dumps on fatal exceptions

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

* PR feedback

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

Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2022-06-17 13:52:17 -06:00
Alan Jowett 9fdd90adb3
Adding negative tests for ebpf_core.c (#1132)
* Adding negative tests for ebpf_core.c
Fixed bugs in ebpf_core.c around handling bad data.
Fixed incorrect helper function numbering for bpf_ktime_get_ns.
Canonacalizes names of protocol structs and handlers.
Simply protocol dispatch table and remove redundancy.
Add the ability to unregister for async notification (for failure path).
Remove redundant checks (internal calls with SAL annotations).

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

* PR feedback

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

Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: saxena-anurag <43585259+saxena-anurag@users.noreply.github.com>
2022-05-26 14:06:02 -07:00
Dave Thaler 4718bf7a73
Support bpf_object__load() with native programs (#1133)
* Make bpf_object__open_file work with native files

* Update bpf_object__open_file()
* Add bpf_object__open()
* Rename ebpf_enumerate_sections() to ebpf_enumerate_program_sections()

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

* Remove ebpf_program_load

And add a couple of windows-specific libbpf related APIs

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

* Fix bug in enumerate sections hit by tail_call_multiple_um.dll

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

* Fix program_name field in object_open

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

* Cleanup

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

* Fix order of PE sections returned

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

* Bug fix

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

* Bug fix

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

* Bug fix and revert enumerate_sections rename

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

* Updated expected bpf2c output

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

* Fix analysis warning

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

* Updated issue number in TODO comments

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

* Address Anurag's feedback

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-05-24 14:53:04 -07:00
Alan Jowett cd017611cf
Add coverage in bitmap, epoch, and ringbuffer. (#1007)
* Add coverage in bitmap, epoch, and ringbuffer.

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

* PR feedback

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

Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2022-05-02 12:39:58 -06:00
saxena-anurag dafd950314
Add negative native module tests (#1039)
* add tests, bugfix

* mark tests for Debug only

* fix build failure

* update cmake file

* Apply suggestions from code review

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

* fix cmakelists

* fix build break

* fix typo

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2022-05-01 16:26:41 -07:00
Alan Jowett 74973a92df
Enable capturing triage dump on test crash (#1009)
* Enable capturing triage dump on test crash

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

* PR feedback

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

Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2022-04-26 19:42:15 -07:00
Alessandro Gario 6a54714ec2
cmake: Add base targets (#882)
Signed-off-by: Alessandro Gario <alessandro.gario@gmail.com>
2022-04-26 05:39:37 -07:00
Dave Thaler 086b80149d
Nuget package (#999)
* WIP: Developer nuget package

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

* Add bpf2c utility

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

* Build nupkg from within VisualStudio

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

* Don't use relative path to externals

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

* Update props file in nuget package

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

* Fix include and library paths

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

* Fix debug build

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

Co-authored-by: saxena-anurag <43585259+saxena-anurag@users.noreply.github.com>
2022-04-25 10:26:56 -07:00
Dave Thaler 69adefb137
More bpftool tests (#986)
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-04-21 10:41:44 -07:00
Shankar Seal ec26f5d273
WFP ALE Flow established callout, tests etc. (#978)
* WFP ALE Flow established callout, tests etc.

* PR Feedback.

* bug fixes.

* PR feedback 2.
2022-04-20 16:48:20 -07:00
saxena-anurag 81a855e88f
Enable unit tests for native driver (#953)
* add native tests, bugfixes

* cr comments, fix test failures, fix bad merge

* fix analysis build break

* test failure
2022-04-15 18:26:41 -07:00
Shankar Seal a1a2c6ad92
Sockops 1 (#952)
* remove dependabot from the fork.

* Revert "remove dependabot from the fork."

This reverts commit c542c6cd44.

* add sock_ops program and attach types.

* PR Feedback.
2022-04-14 15:09:54 -07:00
Shankar Seal 745bac282e
Sock addr hook callout test (#922)
* remove dependabot from the fork.

* Revert "remove dependabot from the fork."

This reverts commit c542c6cd44.

* Program info and hook NPI providers for sock_addr.

* PR Feedback.

* PR Feedback 2.

* sock_addr hook tests.

* PR feedback.

* PR Feedback 2.

* fix.
2022-04-12 11:37:44 -07:00
Dave Thaler d00377f074
Make map definition more cross-platform compatible (#904)
Fixes #903

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-04-07 18:53:21 -07:00
saxena-anurag 9c0ca81d95
clean up printf statements from service_install_helper (#872)
* clean up printf statements

* fix an older failing test

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2022-04-01 17:14:44 -07:00
saxena-anurag 3470d6d7b7
EC and API changes to load generated BPF driver (#811)
* initial_commit

* fix build

* fix build

* fix build break due to merge

* debug build

* api changes, other changes

* bpf2c change to enmit program type, other fixes

* hydrate UM ebpf_object, other fixes

* remove logic to disable programs

* fixes

* fix sal

* build break

* build break

* fix sal errors

* fixes

* fix bpf2c_tests failure

* unload driver when program ref count becomes 0, other minor fixes

* fixes

* tail_call fixes, add test cases, other fixes

* build break

* build break

* code cleanup

* fix bad merge

* code cleanup

* code cleanup

* cleanup

* Apply suggestions from code review

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

* cr comments

* Apply suggestions from code review

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

* cr comments

* Apply suggestions from code review

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

* cr comments

* cr comments

* Apply suggestions from code review

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

* address cr comments

* Apply suggestions from code review

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

* add tracing in ebpfcore, other fixes

* tracing

* add section for each map in sample

* do not delete the native service

* fix bad merge

* remove code to delete service, other fixes

* cr comments

* bpf2c should read and populate all the maps in ELF file

* add test case for creating map-in-map from native driver

* Apply suggestions from code review

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

* cr comments

* add tracing for api code changes

* rename epbf_native_t to ebpf_native_module_t

* fix bad merge

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2022-04-01 12:52:04 -07:00
Alan Jowett fd94c807a5
Centralize compiler options (#823)
* Centralize all compiler options

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2022-03-29 10:41:09 -06:00
Shankar Seal ecea57b4d8
Change extensions npiid (#841)
* remove dependabot from the fork.

* change extension provider NPI IDs.

* PR feedback.

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2022-03-28 11:26:19 -07:00
Alan Jowett 5e468b8857
Switch to current catch2 release (#809)
* Switch to current catch2 release

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2022-03-18 17:39:21 -06:00
Shankar Seal d5cf5e8622
support interface parameter for loading XDP program in netsh ebpf con… (#790)
* support interface parameter for loading XDP program in netsh ebpf context.

* PR Feedback.

* PR Feedback.
2022-03-09 16:15:58 -08:00
saxena-anurag 2384d6c123
rename ebpf_object to ebpf_core_object (#793) 2022-03-07 09:07:10 -08:00
Alan Jowett bd2aa504e1
Refactor ebpf_provider_load/ebpf_extension_load and move generation of module_id to caller (#773)
* Move generation of module_id into caller of ebpf platform NMR wrapper

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2022-02-28 09:09:33 -07:00
Alan Jowett 1dafb123d6
Emit function name if found (#771)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2022-02-22 18:01:54 -07:00
Alan Jowett 430e575f1a
Add tool to generate C code from eBPF byte code in ELF file (#757)
Add bpf2, a tool to generate C programs from eBPF instructions in an ELF file.

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2022-02-15 17:44:23 -07:00
Dave Thaler 59c0b4e185
Allow attaching an XDP program to a specific ifindex (#755)
* Allow attaching an XDP program to a specific ifindex
* Update tests since droppacket.o changed
* Add ifindex use back to droppacket.c for testing purposes
* Verify xdp program to unlink is actually an XDP program
* Add comment re moving xdp fd replace logic to execution context
* Add libbpf test and add support for bpf_xdp_query_id

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-02-14 16:40:56 -08:00
saxena-anurag 6b4dda75a1
remove ebpf_api_initiate, ebpf_api_terminate from sources (#738)
* remove ebpf_api_initiate, ebpf_api_terminate from sources

* cleaup traces

* cleanup traces
2022-01-31 08:32:28 -08:00
Dave Thaler 6fb17c819e
Disable color output to avoid appverif problem (#708)
* Disable color output to avoid appverif problem

There does not appear to be any simple way to use a custom color
class with CATCH2 so we just disable color as is done for a UWP.

Fixes #679

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

* Add reference to catch2 issue

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2022-01-04 10:23:24 -08:00
saxena-anurag 1bbbc41233
add auto-pinning option for maps. (#612)
* add auto-pinning option

* Apply suggestions from code review

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

* Configure custom pin_root_path using bpf_object_open_opts

* use new api for map-in-map, remove pinning restriction for inner map, remove workaround for inner map id

* code cleanup

* cr comments

* Apply suggestions from code review

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

* fix bad merge

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-10-01 09:01:39 -06:00
Dave Thaler 20d7a6565e
Add more libbpf APIs needed by bpftool (#576)
* Add more libbpf APIs needed by bpftool

* Add missing export for existing bpf_map__name API
* Add bpf_object__load
* Add bpf_object__load_xattr
* Add bpf_object__open_file
* Add bpf_object__unload() API
* Add bpf_program__get_type
* Add bpf_program__set_type
* Add bpf_program__unload() API
* Add libbpf_get_error
* Add libbpf_num_possible_cpus
* Rename BPF_MAP_TYPE_UNSPECIFIED to BPF_MAP_TYPE_UNSPEC for libbpf
  compat
* Rename BPF_PROG_TYPE_UNKNOWN to BPF_PROG_TYPE_UNSPEC for libbpf compat
* Add attach_type to bpf_link_info
* Add map_flags to bpf_map_info (but currently always 0)

Fixes #575

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-09-23 19:32:09 -07:00
Shankar Seal 9d01eb45c1
Fix EbpfProgramType for sample extension. (#569)
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-09-20 13:00:21 -07:00
Alan Jowett 967990f700
Disable /ZI and incremental linking (#546)
* Disable /ZI and incremental linking

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-16 16:49:02 -06:00
Alan Jowett e553150b1b
Switch from MultiThreadedDebug to MultiThreadedDebugDll (#528)
* Switch from MultiThreadedDebug to MultiThreadedDebugDll
* Pull in latest ebpf-verifier

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-09-14 08:46:01 -06:00
Shankar Seal e84efdf092
Xdp adjust head part1 (#522)
xdp_adjust_head : Part 1
2021-09-13 17:46:23 -07:00
saxena-anurag cec8bd0014
Fix bpf_link__destroy(), add bpf_link__disconnect() (#485)
* api changes

* fix

* Apply suggestions from code review

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

* changes

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-09-03 12:21:04 -07:00
Shankar Seal ec68058a36
Test utility helper functions. (#480)
* Test utility helper functions.

* fix build break.

* PR feedback.

* PR feedback.
2021-09-02 17:23:16 -07:00
saxena-anurag 014ee34392
Add eBPF UM APIs (#368)
* parse map names from elf file
* add apis, change test code

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-08-10 17:04:07 -07:00
Dave Thaler 4d0ac1bd4d
Replace "information" with "info" for consistency (#331)
Previously some places had "info" and some had "information".
Both appear in dictionaries, so guidance to avoid abbreviations does not apply.

Fixes #314

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-07-07 11:16:35 -07:00
Alan Jowett a0801d410c
Suppress C26451 (#312)
* Suppress C26451 and related errors

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-28 16:13:29 -07:00
Dave Thaler a46b00c2e3
Add VM setup scripts and docs (#281)
* Create an install script rather than having to manually do lots
  of steps
* Make Debug build use vcruntime as static libs to avoid adding
  another prerequisite on a machine before installing eBPF.  This
  isn't required for Release builds as vcruntime release DLLs
  are part of Windows, unlike vcruntime debug DLLs

Fixes #248

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-15 08:44:43 -07:00
saxena-anurag 6fde4777e5
Change ebpfsvc to LocalService (#272)
* ebpfsvc should be localservice

* cr comments, change sidtype to restricted

* pr comments
2021-06-14 15:38:42 -07:00
Shankar Seal 27f8d49888
API to create map and enumerate all pinned maps. (#246)
* API to create map and enumerate all pinned maps.

* Apply suggestions from code review

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

* Address code review comments

* Address code review comments #2

* Address code review comments #3

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-06-09 09:44:24 -06:00