Commit Graph

249 Commits (61e0aef8b6aafeafa80981dd962ffaa4392bc950)

Author SHA1 Message Date
Friday Ortiz 61e0aef8b6
.github,aya,test: clean up interface and script per review comments
- .github: Ensure we only download the debug package that matches the kernel we
  downloaded.
- aya: Constrain the breakpoint interface to only valid combinations of
  options.
- test: Document what the test is actually doing for future readers who might
  be unfamiliar with modprobe_path.
3 weeks ago
Friday Ortiz 38e3f7fce2
Merge branch 'main' into feature/breakpoint-support 3 weeks ago
Tamir Duberstein 08cf90881f
integration-test: extract run_pin_program_lifecycle_test 3 weeks ago
Tamir Duberstein fe43f776c3
integration-test: extract from_pin 3 weeks ago
Tamir Duberstein 0840faf6b1
integration-test: extract pin paths 3 weeks ago
Tamir Duberstein 0f1c975632
integration-test: extract run_unload_program_test 3 weeks ago
Tamir Duberstein a6458804fc
integration-test: extract types 3 weeks ago
Tamir Duberstein a2f4951cce
integration-test: remove errant semicolons 3 weeks ago
Tamir Duberstein 89d746ad1b
integration-test: extract attach fns 3 weeks ago
Tamir Duberstein 48300b6498
integration-test: extract program names 3 weeks ago
Tamir Duberstein 4041fe9293
integration-test: move memmove out of pin tests 3 weeks ago
Christian A. Jacobsen a98b638fa9 feat(log): add support for logging raw pointer types
* Requires the usage of `:p` display hint.
* Will, like stdlib, log with `0x` prefix.
3 weeks ago
Friday Ortiz 4545feec9a
aya,test,xtask: add breakpoint support to enforced perf_event config combo branch
* aya: enforce valid perf_event type & config combos

Add guardrails for when setting event type and config for perf_event
programs. The `PerfEventConfig` enum now defines the event `type` and
`config` of interest.

Remove public re-exports, and add idiomatic Rust types for:
- perf_hw_id => HardwareEvent
- perf_sw_ids => SoftwareEvent
- perf_hw_cache_id => HwCacheEvent
- perf_hw_cache_op_id => HwCacheOp
- perf_hw_cache_op_result_id => HwCacheResult

The motivation behind this is mainly for the `type` and `config` fields
of `bpf_link_info.perf_event.event`. The newly added enums are planned
to also be used in the `bpf_link_info` metadata.

Although `Breakpoint`/`PERF_TYPE_BREAKPOINT` variant exists, it is not
fully implemented. It's only usage at the moment is in link info.

* add breakpoint support to perf_event config interface

---------

Co-authored-by: Tyrone Wu <wudevelops@gmail.com>
4 weeks ago
Friday Ortiz 22d6f58e9b
test: use gunzip symbol to determine kaslr offset
This symbol should appear in both kallsyms and System.map, whereas
the _text symbol does not.
4 weeks ago
Friday Ortiz 51d97a4303
test,xtask: include debug symbols for attaching breakpoints in tests
For some reason, the aarch64 6.1 debian kernel was not compiled with
CONFIG_KALLSYMS_ALL=y, and the locations of globals are not available in
kallsyms. To attach breakpoints to these symbols in the test pipeline, we need
to read them from System.map and apply the kaslr offset to get their real
address. The System.map file is not provided in the kernel package by default,
so we need to extract it from the corresponding debug package.

- .github: pull the corresponding debug packages down as well as regular
  kernels
- test: attach the perf_event_bp test breakpoint to the modprobe_path address
  in kallsyms if present, or by applying the kaslr offset to the System.map
  address if not found
- xtask: preferentially extract the System.map file from the debug package, if
  available
4 weeks ago
Friday Ortiz 8b58fc13fc
test: add a perf_event breakpoint test
Test perf_event breakpoints by attaching a RW breakpoint to
modprobe_path and triggering a read from procfs, asserting that the tgid
of the program triggering the breakpoint matches the test program.
4 weeks ago
Altug Bozkurt fc5387c806
lsm: cgroup attachment type support 1 month ago
Tamir Duberstein 66ed37c8a9
integration-test: add LSM 1 month ago
Tamir Duberstein 8e75214815
feature_probe: properly check for LSM support
Turns out this is not supported in aarch64 until 6.4.
1 month ago
Tamir Duberstein 9ba87c661b
xtask: copy kernel config into the initramfs image
When preparing the VM initramfs detect the `config-*` file that ships alongside
the vmlinuz/modules in each kernel archive and install it under `/boot` (both
as `/boot/config` and `/boot/config-<version>`). This makes the running
kernel’s configuration available inside the guest for the integration tests.
1 month ago
Tamir Duberstein de42b80c74
aya,ebpf: add BPF_MAP_TYPE_SK_STORAGE
This map type requires BTF, and we can finally do it!
1 month ago
Tamir Duberstein c9b5f119a3
feature_probe: clarify composite logic 1 month ago
Tamir Duberstein 75edc3d294
*: downcase log strings 1 month ago
Tamir Duberstein 5f5305c2a8
lint all crates; enable strict pointer lints 1 month ago
Michal R 0b2a544ddd aya-ebpf: Add BTF array definition
Before this change, Aya supported only legacy BPF map definitions, which
are instances of the `bpf_map_def` struct and end up in the `maps` ELF
section.

This change introduces a BTF map definition for arrays, with custom
structs indicating the metadata of the map, which end up in the `.maps`
section.

Co-authored-by: Tamir Duberstein <tamird@gmail.com>
2 months ago
Adam Schreck 263e864cd9 aya: add Map::from_map_data() for pinned map access
Enables creation of Map enum variants directly from MapData instances,
allowing user-space handles to pinned BPF maps without requiring the
original BPF object.

Supports multiple BPF map types.

Motivation:
- Simplifies accessing pinned maps from user space applications.
- Avoids full BPF reloads and potential deadlocks.
- Matches existing ergonomic APIs like LruHashMap::try_from.
- Keeps user code safe and idiomatic.

Closes https://github.com/aya-rs/aya/issues/1305.

Includes test coverage to validate the new API.
2 months ago
Tamir Duberstein 353b83383d
aya-log-ebpf: zero copy! 2 months ago
Tamir Duberstein 8e2632921f
aya-log: add DST test 2 months ago
Xiaobo Liu 53ec616411 ebpf: add peak() method to Queue and Stack
Add integration tests covering push,pop,peek for both types.

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
2 months ago
Addison Crump f6606473af
aya-log: properly hint log level to verifier
The log level implementation in b36cbc3eb8
was incomplete as the verifier could reject programs which exceeded
their instruction limits within logging statements. This commit
addresses this issue by making the log level static variable immutable
(s.t. the compiler puts it in a read-only section) and adds an
additional test which the verifier will reject as an infinite loop iff
it is unable to detect that the static variable would otherwise allow
the logging.
2 months ago
Tamir Duberstein b36cbc3eb8
implement load-time log level mask 2 months ago
Tamir Duberstein a3aa387a2e
remove superfluous commas 3 months ago
Tamir Duberstein 0b1fbe1cd3
integration-test: add missing `test_log` decorator
Use the fully qualified macro name which composes better with
`test_case` and makes it easier to spot cases where it is missing.
4 months ago
Tamir Duberstein 61376c4608
aya-log: Remove tokio dep
Require the caller to provide their own executor.
4 months ago
Tamir Duberstein 44b26b3b50 integration-test: use only readable interest 4 months ago
Tamir Duberstein 5fa52ac5c1 integration-test: remove an allocation 4 months ago
dependabot[bot] a7e3e6d4d9
build(deps): bump the cargo-crates group with 2 updates
Updates the requirements on [cargo_metadata](https://github.com/oli-obk/cargo_metadata) and [object](https://github.com/gimli-rs/object) to permit the latest version.

Updates `cargo_metadata` to 0.19.2
- [Release notes](https://github.com/oli-obk/cargo_metadata/releases)
- [Changelog](https://github.com/oli-obk/cargo_metadata/blob/main/CHANGELOG.md)
- [Commits](https://github.com/oli-obk/cargo_metadata/compare/0.19.0...0.19.2)

Updates `object` to 0.36.7
- [Changelog](https://github.com/gimli-rs/object/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gimli-rs/object/compare/0.36.0...0.36.7)

---
updated-dependencies:
- dependency-name: cargo_metadata
  dependency-version: 0.19.2
  dependency-type: direct:production
  dependency-group: cargo-crates
- dependency-name: object
  dependency-version: 0.36.7
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
5 months ago
Tamir Duberstein 630a767117 Split relocation tests into multiple files
This avoids requiring kernel support for all types of relocations when
testing a specific type.
6 months ago
Tamir Duberstein c8e9037ca6 Avoid uncontrolled stdout into cargo
This fixes rebuild on change of C sources by black-holing:
- Output of `make` (harmless).
- Output of `llmv-objcopy` (harmful: binary data).
6 months ago
Tamir Duberstein 025b6eaa0d Use a macro to reduce boilerplate 6 months ago
Tyrone Wu 23bc5b5836 aya,aya-obj: cache feat probed info fields
Cached probed for ProgramInfo fields instead of exposing it through
global FEATURE. Probing occurs on cache miss, which happens when first
accessing the field, *and* if the field is 0.
6 months ago
Tyrone Wu bd492860f5 aya: add feature probing for map type
Add API that probes whether kernel supports a map type.
6 months ago
Tyrone Wu ab77decd9a aya,aya-obj: add feature probing program type
Adds API that probes whether kernel supports a program type.
6 months ago
Dave Tucker 7dba5a41ad feat(aya): Make LinkInfo and loaded_links public
We have had loaded_links in the API as `#[doc(hidden)]` for a while.
I've been using it in bpfman and it's been fine. This commit does the
minimal work required to make the API stable.

We expose a `LinkInfo` type - similar to `ProgInfo` - which wraps the
generated type. In this case, `bpf_link_info`.

A few accessor functions have been added for `id`, `link_type` and
`program_id`. There are many more fields that could be (eventually)
made public.

As a convenience, `LinkInfo` can be retrieved from an existing FdLink
by using `FdLink::info()`.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
6 months ago
Tamir Duberstein 583709f6a0 appease `clippy::uninlined-format-args` 7 months ago
Michal Rostecki e229231d88 xtask: Move libbpf header installation logic to a helper function
Before that, the same code was repeated twice in different places.
7 months ago
Thomas Eizinger 6d36fe13d3 aya-build: Allow setting Rust nightly version
At present, `aya_build` will always use `+nightly` to build the
eBPF kernel. This is problematic in environments such as CI, where
tools always need to be installed first. Installing the current
nightly Rust toolchain gives you a new toolchain every day. This
poisones caches and makes CI jobs non-deterministic.

Resolves: #1226
8 months ago
Dave Tucker 2b0dcfbd09 feat: Allow conversions to Program from ProgramInfo
Allow for a ProgramInfo to be converted into one of the program types
that we support. This allows for a user of Aya access to reattach,
pin or unload a program that was either, previously loaded, or was
loaded by another process.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
8 months ago
Dave Tucker 9eecbe9d0e
Merge pull request #1224 from dave-tucker/unused_trait_names
chore(*): set clippy unused_trait_names = warn
8 months ago
Tamir Duberstein 77b1c6194c Add support for Flow Dissector programs
Closes #216.

Co-authored-by: Zenna Allwein <zrallwein@gmail.com>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
8 months ago