Commit Graph

2160 Commits (4545feec9a7742e9d181fb1e1553c3968005d288)
 

Author SHA1 Message Date
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 c6718e7882
Merge branch 'main' into feature/breakpoint-support 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
Tamir Duberstein 29dc775535
test-distro: appease unreachable code check
See https://github.com/rust-lang/rust/commit/ff6dc928c5e33ce8e65c6911a7.
4 weeks ago
Friday Ortiz f7a9d73d42
aya-obj,aya,ebpf,xtask: support perf_event hardware breakpoints
- aya-obj: Generate userspace bindings for HW_BREAKPOINT_* options
- aya: Support PERF_TYPE_BREAKPOINT by adding an optional hardware
  breakpoint configuration to PerfEvent::attach() and perf_event_open
  functions.
- ebpf: Generate bindings for `struct bpf_perf_event_data` and update
  the PerfEventContext to use them instead of a void pointer.
- xtask: Update codegen for constified anonymous HW_BREAKPOINT_* enums
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 5f046899b5
xtask: teach integration-test vm to consume kernel debs directly
Bundle handling of Debian kernel archives into xtask so callers can pipe
the raw `.deb` paths straight into `cargo xtask integration-test vm …`.
The driver now extracts each archive into `<cache>/kernel-archives`,
locates the matching `vmlinuz-*`, `lib/modules/*`, and config files, and
feeds those into the initramfs build without requiring the user to
pre-run dpkg/tar. With this in place we drop
`.github/scripts/find_kernels.py`, simplify AGENTS.md/CI instructions to
use `find test/.tmp -name '*.deb'`, remove the gnu-tar requirement we no
longer need, and add `tar` as a workspace dependency for the extractor.
1 month ago
Tamir Duberstein fab4fc44b2
xtask: reduce `fs` imports 1 month ago
Tamir Duberstein d16711b2be
xtask: avoid variables named `cmd` and `child` 1 month ago
Tamir Duberstein ffa65efb36
integration-ebpf: avoid mentioning the size 1 month ago
Tamir Duberstein d82ed60795
.cargo/config: use musl-cross on x86_64 as well
This allows us to run virtualized integration tests on macOS hosts.

Bump Ubuntu to 24.04 because we seem to be getting miscompilation on
x86_64 otherwise (when using `x86_64-linux-musl-gcc`). Add `apt install
liblzma-dev` since it doesn't seem to be present in ubuntu-24.04.
1 month ago
Tamir Duberstein 71f6176e24
xtask: ensure we actually built depmod 1 month ago
Tamir Duberstein 82750ae3b1
.github: attempt to enable KVM 1 month ago
Tamir Duberstein 9bc185a61e
aya-tool: simplify and improve error handling 1 month ago
Michal R 98e8c78376 aya-ebpf: Make use of `Borrow` and `BorrowMut` in map methods
Let callers pass either owned objects or references. We do that already
in the user-space methods.
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 6babf17969
maps: use shared helpers 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 742f700dcc
maps: add newline between doc and imports 1 month ago
Tamir Duberstein 0013ff4e9e
ebpf: use null pointers at runtime
The values here do not matter, this is just to get type information.
1 month ago
Tamir Duberstein 275c5b6bbc
ebpf: use `ptr::from_ref`
This is consistent with other such conversions.
1 month ago
Tamir Duberstein a2324e6e50
Add Brewfile 1 month ago
Tamir Duberstein b73b9092ee
Add AGENTS.md 1 month ago
Tamir Duberstein fe99fa1d2e
ebpf: run clippy with target=bpf
This build warnings from integration tests and makes `aya-ebpf`'s build
script stricter.
1 month ago
Tamir Duberstein 552b69367f
xtask: remove outdated snippet
We handed this to QEMU in e3bfeb9dd6.
1 month ago
Tamir Duberstein bb45904b08
xtask: patch gen_init_cpio.c
Recent changes[0][1] have broken compatibility with macOS; add a patch
to conditionally compile these snippets.

Patch and compile the source unconditionally; caching only the network
portion is good enough and less error prone.

[0] ae18b94099
[1] 97169cd6d9
1 month ago
dependabot[bot] 8e31f5fa43
Merge pull request #1355 from aya-rs/dependabot/cargo/cargo-crates-7838c61200 1 month ago
dependabot[bot] ace02870f2
build(deps): update cargo_metadata requirement in the cargo-crates group
Updates the requirements on [cargo_metadata](https://github.com/oli-obk/cargo_metadata) to permit the latest version.

Updates `cargo_metadata` to 0.22.0
- [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.22.0...0.22.0)

---
updated-dependencies:
- dependency-name: cargo_metadata
  dependency-version: 0.22.0
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
1 month ago
Tamir Duberstein 5f5305c2a8
lint all crates; enable strict pointer lints 1 month ago
Tamir Duberstein ec3eacc1d8
Increase VM memory
Since 6.1.0-40 we're seeing `Initramfs unpacking failed: write error`.
1 month ago
Tamir Duberstein d1bb7bcc38
deny clippy::unnecessary_cast 1 month ago
Tamir Duberstein be4d74fd06
deny clippy::fn_to_numeric_cast{,_with_truncation} 1 month ago
Tamir Duberstein fa03dbdb46
deny clippy::char_lit_as_u8 1 month ago
Tamir Duberstein a7206b9098
deny clippy::cast_precision_loss 1 month ago
Tamir Duberstein 72104c4076
deny clippy::cast_lossless 1 month ago
Tamir Duberstein 82e72a14ad
Remove unused import
```
  error: unused import: `define_linear_ds_test`
    --> test/integration-ebpf/src/linear_data_structures.rs:59:5
     |
  59 | use define_linear_ds_test;
     |     ^^^^^^^^^^^^^^^^^^^^^
     |
     = note: `-D unused-imports` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(unused_imports)]`

  error: could not compile `integration-ebpf` (bin "linear_data_structures") due to 1 previous error
```
1 month ago
Tamir Duberstein d1fdbb9930
Update to macOS 15 (#1351) 1 month ago
Thomas Eizinger e2a68ee384 aya-log: add `#[must_use]` attribute to `EbpfLogger` 2 months ago
Tamir Duberstein 30182463bd
aya-obj: explicitly enable hashbrown features 2 months ago
tamird 32071bdca7 public-api: regenerate 2 months 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
Michal R e0ceb6214b aya-obj: Remove `Safety: union` comments
They serve no purpose, there are no unions no unsafe operations around.
2 months ago
Tamir Duberstein 658ae0fbb9 aya-obj: simplify using CStr::from_bytes_until_nul 2 months ago
Michal R d5e4e9270a aya-ebpf: Remove irrelevant `FIXME` comment
eBPF verifier in recent kernels should be smart enough to track map
map types and catch invalid pointer casts. Rust type system makes sure
that the `get` method can return only the same type the map was created
with. Therefore, safe usage of Aya map types shouldn't cause element
type mismatches.

Manual alignment checks (`pointer::is_aligned` or manual pointer
arithmetic operations) cause the following verifier error:

```
bitwise operator &= on pointer prohibited
```

And it extremely unlikely `bpf_map_lookup_elem` ever returns a
misaligned pointer.
2 months ago