Implement kernel BPF enforcement hooks#199
Merged
seanwevans merged 2 commits intoMay 13, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
hardenedthe documented production posture and provide compatibility for test environments that lack full BPF toolchain.Description
pyisolate/bpf/syscall_filter.bpf.cwith LSM-based programs that consult pinned maps keyed bybpf_get_current_cgroup_id()and emit denial events to a ring buffer when a decision returns deny.pyisolate/bpf/resource_guard.bpf.cplaceholders with a real design usingBPF_MAP_TYPE_RINGBUFforresource_events, per-cgroup accounting maps (cgroup_accounting,cgroup_quotas,task_cpu_start), and tracepoint/cgroup hooks to update CPU/RSS/net and emit quota-breach events.pyisolate/bpf/manager.py::BPFManager.loadto: compile objects, pin under/sys/fs/bpf/pyisolate, usebpftool prog loadall ... autoattachfor LSM/tracepoint programs, and run an explicitbpftool cgroup attach ... egress pinnedstep for kernels/tools that require a concrete cgroup attach.hardenedas the production default inREADME.mdand clarifieddev/compatibilityas caller-acknowledged weaker modes.tests/test_bpf_kernel_enforcement.pyand adjusted unit tests to expect the newbpftoolinvocation patterns and pinning layout.BPFManager.load(strict=...)call sites in the supervisor constructor and avoid leaking test module stubs (restorepyisolate.bpf.managerafter metrics test stub).Testing
pytest -q tests/test_bpf_manager.py tests/test_bpf_manager_extra.py tests/test_bpf_kernel_enforcement.py, which passed in the CI/test environment.python -m py_compileon modified modules which succeeded.clang -target bpf -O2 -c ...but the environment clang lacks a BPF backend (No available targets are compatible with triple "bpf"), so native object builds were not performed here.Codex Task