eBPF implementation that runs on top of Windows
Перейти к файлу
Sharmi 8adab0de10
stress test for tail calls (#2518)
* Add stress test for tail calls

* Added the code generated bindmonitor_mt_tailcall files

* Added the test case description to readme.md

* Update tests/stress/km/stress_tests_km.cpp

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

* Update tests/stress/km/stress_tests_km.cpp

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

* Addressed PR comments and Fixed merge conflicts with latest

* Fixed function name

* Regenerated the expected files, after the macro MAX TAIL CNT change done yesterday

* Update tests/stress/readme.md

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

* Removed clean_up tail call

* Add bind in loop

* updated the readme

* Addressed PR comments

* Changed LOG_VERBOSE to LOG_ERROR

* Updated readme and addressed PR comment

---------

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-06-07 05:21:47 +00:00
.github fix CICD failure (#2548) 2023-06-06 17:01:22 +00:00
cmake Provide option to version info in generated .sys file (#2401) 2023-05-02 00:39:42 +00:00
docs Add script for automating release version update. (#2418) 2023-05-02 08:47:59 +00:00
ebpfapi Refactor eBPFCore tracing to use less stack space. (#2501) 2023-05-31 17:26:09 +00:00
ebpfcore Refactor eBPFCore tracing to use less stack space. (#2501) 2023-05-31 17:26:09 +00:00
ebpfsvc Refactor eBPFCore tracing to use less stack space. (#2501) 2023-05-31 17:26:09 +00:00
external Bump external/ebpf-verifier from `10eaee3` to `09a3349` (#2549) 2023-06-06 20:31:26 +00:00
images Bump windows/nanoserver in /images (#2212) 2023-03-19 04:15:36 +00:00
include Remove NMR extension wrapper code. (#2434) 2023-05-15 18:49:55 +00:00
installer stress test for tail calls (#2518) 2023-06-07 05:21:47 +00:00
libs Add comments re. epoch awareness in code paths lacking the epoch sandwich. (#2523) 2023-06-02 17:19:04 +00:00
manifests/Kubernetes Added support for host-process container installation (#1099) 2022-05-31 09:42:53 -07:00
netebpfext Refactor eBPFCore tracing to use less stack space. (#2501) 2023-05-31 17:26:09 +00:00
resource Release v0.9.0 (#2425) 2023-05-03 03:17:59 +00:00
rpc_interface Add option to generate .spd files for sample driven PGO (#1931) 2023-01-20 23:10:24 +00:00
scripts stress test for tail calls (#2518) 2023-06-07 05:21:47 +00:00
tests stress test for tail calls (#2518) 2023-06-07 05:21:47 +00:00
tools Refactor eBPFCore tracing to use less stack space. (#2501) 2023-05-31 17:26:09 +00:00
.clang-format Clean up order of includes (#2015) 2023-02-07 18:32:19 +00:00
.gitattributes Regenerate and checkin corpus files (#1872) 2023-01-24 18:29:10 +00:00
.gitignore Clean up order of includes (#2015) 2023-02-07 18:32:19 +00:00
.gitmodules Remove bpf_conformance submodule (#1816) 2023-01-04 09:07:43 -08:00
Analyze.default.ruleset Lower C.63 to warning. (#2219) 2023-03-21 20:44:25 +00:00
CMakeLists.txt Fix sanitizer build of fuzzer (#2201) 2023-04-13 15:00:49 +00:00
CONTRIBUTING.md Add a project governance doc (#1912) 2023-01-18 19:14:59 -08:00
Directory.Build.props Remove unneeded nuget package (#2507) 2023-05-24 14:38:32 +00:00
Doxyfile Add main API reference page (#329) 2021-07-07 10:39:59 -07:00
LICENSE.rtf Added Wix installer native project. (#1960) 2023-01-26 21:25:23 -08:00
LICENSE.txt Add prereqs to readme file 2021-02-12 16:18:45 -08:00
README.md Fix CI/CD Badge (#2300) 2023-04-10 17:53:50 +00:00
ebpf-for-windows.sln Move km stress test app proj to correct location (#2397) 2023-04-28 15:54:13 +00:00
mainpage.dox Fix doc link (#1338) 2022-08-23 12:46:50 -07:00

README.md

eBPF for Windows

CI/CD CII Best Practices codecov

eBPF is a well-known technology for providing programmability and agility, especially for extending an OS kernel, for use cases such as DoS protection and observability. This project is a work-in-progress that allows existing eBPF toolchains and APIs familiar in the Linux ecosystem to be used on top of Windows. That is, this project takes existing eBPF projects as submodules and adds the layer in between to make them run on top of Windows.

New to eBPF?

See our basic eBPF tutorial and our tutorial on debugging eBPF verification failures.

Architectural Overview

The following diagram shows the basic architecture of this project and related components:

Architectural Overview

As shown in the diagram, existing eBPF toolchains (clang, etc.) can be used to generate eBPF bytecode from source code in various languages. Bytecode can be consumed by any application, or via bpftool or the Netsh command line tool, which use a shared library that exposes Libbpf APIs, though this is still in progress.

The eBPF bytecode is sent to a static verifier (the PREVAIL verifier) that is hosted in a secure user-mode environment such as a system service (which is the case at present), enclave, or trusted VM. If the eBPF program passes all the verifier checks, it can be loaded into the kernel-mode execution context. Typically this is done by being JIT compiled (via the uBPF JIT compiler) into native code that is passed to the execution context. In a debug build, the byte code can instead be directly loaded into an interpreter (from uBPF in the kernel-mode execution context) though the interpreter is not present in a release build as it is considered less secure. See also the HVCI FAQ answer below.

eBPF programs installed into the kernel-mode execution context can attach to various hooks and call various helper APIs exposed by the eBPF shim, which internally wraps public Windows kernel APIs, allowing the use of eBPF on existing versions of Windows. Many helpers already exist, and more hooks and helpers will be added over time.

Getting Started

This project supports eBPF on Windows 10 or later, and on Windows Server 2019 or later. To try out this project, see our Getting Started Guide.

Want to help? We welcome contributions! See our Contributing guidelines. Feel free to take a look at our Good First Issues list if you're looking for somewhere to start.

Want to chat with us? We have a:

For tracking Q&A and general discussion, we use Discussions in github. This can also function similar to a mailing list if you subscribe to discussion notifications by clicking "Watch" (or "Unwatch") and selecting "Custom" -> "Discussions" (or by selecting "All Activity" if you want to receive notifications about everything else too).

Frequently Asked Questions

1. Is this a fork of eBPF?

No.

The eBPF for Windows project leverages existing projects, including the IOVisor uBPF project and the PREVAIL verifier, running them on top of Windows by adding the Windows-specific hosting environment for that code.

2. Does this provide app compatibility with eBPF programs written for Linux?

The intent is to provide source code compatibility for code that uses common hooks and helpers that apply across OS ecosystems.

Linux provides many hooks and helpers, some of which are very Linux specific (e.g., using Linux internal data structs) that would not be applicable to other platforms. Other hooks and helpers are generically applicable and the intent is to support them for eBPF programs.

Similarly, the eBPF for Windows project exposes Libbpf APIs to provide source code compatibility for applications that interact with eBPF programs.

3. Will eBPF work with HyperVisor-enforced Code Integrity (HVCI)?

Yes. With HVCI enabled, eBPF programs cannot be JIT compiled, but can be run either natively or in interpreted mode (but the interpreter is disabled in release builds and is only supported in debug builds). To understand why JIT compiled mode does not work, we must first understand what HVCI does.

HyperVisor-enforced Code Integrity (HVCI) is a mechanism whereby a hypervisor, such as Hyper-V, uses hardware virtualization to protect kernel-mode processes against the injection and execution of malicious or unverified code. Code integrity validation is performed in a secure environment that is resistant to attack from malicious software, and page permissions for kernel mode are set and maintained by the hypervisor.

Since a hypervisor doing such code integrity checks will refuse to accept code pages that aren't signed by a key that the hypervisor trusts, this does impact eBPF programs running natively. As such, when HVCI is enabled, eBPF programs work fine in interpreted mode, but not when using JIT compilation because the JIT compiler does not have a key that the hypervisor trusts. And since interpreted mode is absent in release builds, neither mode will work on an HVCI-enabled production system.

Instead, a third mode is also supported by eBPF for Windows, in addition to JIT compiled and interpreted modes. This third mode entails compiling eBPF programs into regular Windows drivers that can be accepted by HVCI. For more discussion, see the Native Code Generation documentation.