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

294 Коммитов

Автор SHA1 Сообщение Дата
Dave Thaler 8006f181e0
Libbpf API compatibility (#350)
* Libbpf API compatibility

Libbpf is incorporated as a submodule just for the header file.
As discussed in issue #84, we cannot currently use the implementation
since it is very Linux and GCC specific.

This PR also fixes a bug where the user-mode API was calling
CloseHandle directly instead of Platform::CloseHandle which is needed
to make tests work with the mock platform.

Addresses #84

Some code will be cleaner once issue #81 is done

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-07-30 15:34:21 -07:00
Alan Jowett 4bebd3aaa1
Verify that program type is supported by attach provider (#348)
* Verify that program type is supported by attach provider

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-07-27 16:33:58 -07:00
Dave Thaler 00fc46993d
Update PREVAIL verifier to latest (#347)
Includes support for marking a helper as doing packet reallocation

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

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-07-26 18:05:06 -07:00
Alan Jowett 91879afa7b
Set device type to something _open_osfhandle understands (#346)
* Set device type to something _open_osfhandle understands

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

* PR feedback

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-07-26 17:06:12 -06:00
Dave Thaler ba14644d21
Improve doxygen main page (#340)
This PR addresses two gaps:

https://microsoft.github.io/ebpf-for-windows mentioned the hooks but
didn't mention what header file to include.

And it talked about ebpf programs, but didn't mention the reference for
user-mode apps to interact with them.

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

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-07-26 09:17:54 -07:00
Shankar Seal 18456999b7
move map helper function prototypes to EC (#337)
* move map helper function prototypes to EC
* replace 'generic' by 'general'

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-07-22 15:31:01 -07:00
Dave Thaler 107e28b6e3
Fix doxygen warnings (#338)
Fixes #299

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-07-22 14:42:51 -07:00
Shankar Seal 266578ee63
test extension - Part 1 (#336)
* test extension
2021-07-14 14:40:34 -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
Dave Thaler 569da02a8f
Add main API reference page (#329)
Which will fill in content visible at https://microsoft.github.io/ebpf-for-windows/

Fixes #259

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-07-07 10:39:59 -07:00
Dave Thaler e4da7ee04a
Update hook prototypes to be usable by eBPF programs for sanity checking (#327)
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-07-01 17:21:33 -06:00
Dave Thaler 213620aead
Add doxygen docs on hooks (#326)
This PR is the second of three steps towards fully addressing #259

The doxygen \ref annotation tells doxygen to make the following word
be linked to the appropriate location in the generated docs.

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-07-01 15:27:24 -06:00
Dave Thaler 7d145ebbc5
Add doxygen documentation on ebpf helpers (#325)
Before this change, the API docs at
https://microsoft.github.io/ebpf-for-windows/ebpf__helpers_8h.html
just show the typedefs.  This PR updates the documentation so that the
helpers are documented just like normal public APIs would be.

This is the first step towards addressing #259

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2021-06-30 14:24:02 -06:00
Alan Jowett 9681a918ad
Fix issues flagged by CodeQL code scan (#324)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-30 11:11:27 -06:00
Dave Thaler e825caaa8e
Add doxygen documentation on enum values (#322)
* Make all enum values have a description in the generated API docs
* Also remove SAL annotation from the generated docs, since SAL
  breaks doxygen type detection

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

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-06-30 10:22:40 -06:00
Alan Jowett 959def19c8
Enable C6385 and C6386 rules (#323)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-30 09:54:21 -06:00
Shankar Seal f96522ecd4
fix sal on safeint functions (#321)
* fix sal on safeint functions

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-06-29 21:42:40 -07:00
Alan Jowett 0cf75fef7d
Fix C6386 warning in ebpf_epoch_initiate (#320)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-29 17:13:13 -06:00
Dave Thaler d8a26f2b6d
Revert C6011 override (#319)
Fixes #309

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

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-06-29 16:39:03 -06:00
Alan Jowett 7870921e02
Additional analysis fixes (#315)
* Fix C26110,C28023,C28193,C6001,C6031,C6054
* Fix C6101

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

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-06-29 15:51:41 -06:00
Alan Jowett 9f8b1e636e
Add scheduled CodeQL workflow (#318)
* Add scheduled CodeQL workflow
* Add msbuild to path

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-29 13:50:01 -07:00
Shankar Seal a93f4ba714
program information serialization (#302)
* program information serialization.

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-06-28 16:47:34 -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
Alan Jowett a7e7b69661
C6387 fixes (#311)
* C6387 fixes

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>
2021-06-25 16:02:05 -06:00
Alan Jowett 576ef7381c
Enable driver specific code-analysis rules (#310)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-25 11:11:29 -06:00
Alan Jowett 9d798031b4
Fix warnings due to C6011 - NULL pointer deref (#307)
* Switch from _Pre_maybenull_ to _In_opt_

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

* Fix C6011

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

* Fix C6011 in PreprocessCommand

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-25 10:24:03 -06:00
poornagmsft 84d4aca6e5
Update CONTRIBUTING.md to include notes on closure of bugs (#305)
* Update CONTRIBUTING.md

* Update CONTRIBUTING.md

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

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-06-25 08:31:22 -07:00
Alan Jowett 7101b164bd
Fix inconsistent annotation (#303)
* Fix inconsistent annotation

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

* Suppress mismatched annotation from ntintsafe.h

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

* Fix annotation

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

* Fix inconsistent annotation

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

* Suppress wrong annotation from ntintsafe.h

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

* Fix annotation

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>

* Revert incorrect SAL change

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-24 16:39:27 -06:00
Alan Jowett e8f91a5ffd
Add configuration option to run code analysis (#301)
* Add configuration option to run code analysis

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

* Add analysis to build matrix

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

* Fix typo

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

* Enable code analysis on all builds

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

* PR feedback

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

* Add default ruleset

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

* Enable all passing rules

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

* PR feedback

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

* Update Analyze.default.ruleset

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

* Update Analyze.default.ruleset

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

* Switch rules from prevail to warning

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

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-06-24 12:53:51 -06:00
Dave Thaler 5a5dbc63a7
Add additional netsh tests (#298)
Fix a couple bugs that the tests uncovered
Remove duplicate "error: error:" prefix in messages on verification

Fixes #240

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

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-06-23 19:12:20 -06:00
saxena-anurag b0bb08907b
add execution type to ebpf_program_load() (#297)
* add execution type to ebpf_program_load()

* cr comments
2021-06-23 18:54:03 -06:00
Dave Thaler 360aa224ea
Add some netsh tests (#295)
Adds tests for "show sections" and "show disassembly"

Addresses part of issue #240

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-23 09:54:36 -07:00
saxena-anurag c31547cff5
Add ebpf public APIs - #1 (#290)
* add ebpf_program_load(), few other APIs
2021-06-22 20:42:18 -07:00
Alan Jowett 3027b82df0
Unify unit tests (#294)
* Unify unit tests

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

* PR feedback

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-22 12:22:50 -06:00
Alan Jowett 562f5eda7a
end_to_end test should have a JIT version of bindmonitor.o (#243)
* Add test that JITs the bindmonitor.o eBPF program and runs it

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

* Refactor tests to allow common code between JIT and interpret

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

* PR feedback

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

* Fix test bug

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

* Fix rebase issue

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-22 09:51:14 -06:00
Dave Thaler 5510fd0571
Remove mention of PPL since there may be better candidates (#286)
Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-21 13:14:49 -07:00
poornagmsft f6120b0c03
Update README.md (#285)
* Update README.md

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-06-17 12:02:23 -07:00
Dave Thaler 25ba8c3306
Update uBPF to latest (#284)
Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-16 14:17:31 -07:00
Dave Thaler dc157726da
Add some more SAL annotations and clean up some code analysis warnings (#277)
* Make a couple of `_In_` arguments be const
* Add `_opt_` to a number of arguments that can be NULL
* Add SAL annotation to a few more APIs that were missing it
* Remove annotations like
  `_Pre_readable_byte_size_(hash_table->key_size)` since they just give
  code analysis warnings such as:
  ```
  c:\git\dthaler\ebpf-for-windows\libs\platform\ebpf_platform.h(445):
  warning C28230: The type of '_Param_(1)' has no member 'key_size'.
  c:\git\dthaler\ebpf-for-windows\libs\platform\ebpf_platform.h(445):
  warning C28285: For function 'ebpf_hash_table_delete' '_Param_(2)'
  syntax error in
  'SAL_readableTo(byteCount(__formal(0,hash_table)->key_size))' near
  'key_size))'.
  ```

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-16 13:27:22 -07:00
Dave Thaler 2200ab915f
Merge eBPF types with the types in ebpf-verifier (#282)
Remove duplicate types:
* ebpf_helper_return_type_t
* ebpf_helper_argument_type_t
* ebpf_context_descriptor_t

https://github.com/vbpf/ebpf-verifier/pull/238 already made the
necessary changes in the PREVAIL project, which got rid of the
issue with VOID and so the 'undef VOID' workarounds are removed
in the present PR.

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-16 11:53:21 -07:00
Dave Thaler 6ad00a1449
Annotate IDL GUID so clang-format will not interfere (#280)
Without the annotation, clang-format would convert
`uuid(6bef171d-7205-4b63-a1e5-d00f01e6a0c1)`
to
`uuid(6bef171d - 7205 - 4b63 - a1e5 - d00f01e6a0c1)`
which would be invalid.

Fixes #269

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-15 11:24:58 -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
Alan Jowett 3a73482d66
Abstract hook registration and handle passive and dispatch (#265)
* Abstract hook registration and handle passive and dispatch

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

* Switch to new license header format

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

* Clarify memory barrier

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

* Add SAL annotation

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

* PR feedback

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

* Switch to approved license header format (#268)

* Switch to approved license header format

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

* PR feedback

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

* Add comments to clarify how the code works

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

* PR feedback

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

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-06-10 15:18:29 -06:00
Alan Jowett 9e8b88a41a
Switch to approved license header format (#268)
* Switch to approved license header format

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-10 12:02:00 -07:00
Alan Jowett f779bea333
Switch to SynchronizationEvent (#264)
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-10 11:15:47 -06:00
Alan Jowett 877cb22ec0
First pass of adding SAL annotations (#253)
* First pass of adding SAL annotations

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

* Finish annotating platform

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

* Cleanup annotation to get lock tracking work correctly

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

* PR feedback and fix static analysis issues

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>

* Fix build break from merge

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
2021-06-10 10:45:23 -06:00
Shankar Seal 613ee57092
Core review comments from PR 246 (#261)
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2021-06-09 20:28:23 -07:00
Dave Thaler 6be20d7aad
Simplify names of some ebpf_result codes (#256)
* Simplify names of some ebpf_result codes

* Remove _ERROR_ for consistency
* Combine EBPF_INVALID_HANDLE and EBPF_INVALID_OBJECT
* Rename EBPF_ERROR_NOT_FOUND to EBPF_KEY_NOT_FOUND for consistency with the associated description.
* Change code that returned EBPF_ERROR_NOT_FOUND for a case other than a
key, to use a different appropriate result, so the description stays correct.

Fixes #212

Signed-off-by: Dave Thaler <dthaler@ntdev.microsoft.com>
2021-06-09 19:32:57 -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