Commit Graph

400 Commits

Author SHA1 Message Date
dependabot[bot]
db64fcf73b build(deps): update public-api requirement in the cargo-crates group (#1488)
Updates the requirements on [public-api](https://github.com/cargo-public-api/cargo-public-api) to permit the latest version.

Updates `public-api` to 0.51.0
- [Release notes](https://github.com/cargo-public-api/cargo-public-api/releases)
- [Changelog](https://github.com/cargo-public-api/cargo-public-api/blob/main/CHANGELOG.md)
- [Commits](https://github.com/cargo-public-api/cargo-public-api/compare/public-api-v0.50.0...public-api-v0.51.0)

---
updated-dependencies:
- dependency-name: public-api
  dependency-version: 0.51.0
  dependency-type: direct:production
  dependency-group: cargo-crates
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-02 07:31:25 -08:00
vad
ae8c76d037 maps: Fix BloomFilter::contains method
Require the caller to pass a reference, not the owned value. That makes
sure that the pointer is valid from the beginning.
2026-02-16 18:19:28 +00:00
vad
0bf462d221 maps: Take &self in all methods of BloomFilter 2026-02-16 18:19:28 +00:00
vad
8962fc79c1 aya-ebpf: Use i32 as a type for eBPF helper return codes
The helpers always return a signed 64-bit r0 value, but the JIT that
translates eBPF into native instructions differs by architecture. On
x86_64 the generated code writes the helper result into a 64-bit
register, so the CPU sign-extends negative errnos automatically. On
aarch64 the JIT frequently uses 32-bit operations (w0) when copying the
helper return and only zero-extends into the upper half of x0.

That results in broken errno codes on aarch64. For example, when a map
operation returns `-ENOENT`, which is supposed to be -2, the i64
representation yields something like `0x0000_0000_FFFF_FFFE`
(4294967294) instead of -2. In short: the ARM64 JIT doesn’t preserve the
sign in the upper half of the 64-bit register, and the error code has to
be cast to a 32-bit integer to make the sign visible.

This makes it awkward for users, because that behavior prevents simply
comparing helper error codes with constants like `libc::ENOENT` without
manual casts.

Given that the maximum error code limit `MAX_ERRNO` in the kernel is
4095, which fits in a 32-bit integer, coerce the error codes to be `i32`
and make all helpers return `Result<T, i32>`.
2026-02-16 18:19:28 +00:00
tamird
a30c1496f7 public-api: regenerate 2026-02-16 08:04:48 +00:00
Jamie Hill-Daniel
294e0c1941 ebpf: Add helper for safe loading of globals 2026-02-13 11:13:57 -08:00
Tamir Duberstein
2f8759cc62 Dial the lints to 100 2026-01-29 10:02:48 -05:00
Tamir Duberstein
d10ed519c3 xtask: move libbpf-sys hacks to Rust
This restores my ability to run integration tests locally.

Replace `clippy.sh` with `cargo xtask clippy`.
2026-01-28 21:08:01 -05:00
root
930fa7b8af aya-ebpf: generalize btf_map_def macro type parameters
Modify the btf_map_def! macro to generate flat #[repr(C)] structs
instead of UnsafeCell wrappers. This produces BTF that both aya
and libbpf can parse.

Support type parameters with optional defaults and const generics with
configurable types. Allow trailing commas and improve formatting.

Also remove UnsafeCell traversal code from aya-obj loader since
it is no longer needed with flat struct layout.
2026-01-27 14:49:22 +00:00
Tamir Duberstein
e746618143 enable unused_qualifications lint 2026-01-23 11:03:26 -05:00
Tamir Duberstein
f35f7a3610 aya, aya-ebpf: reduce duplication 2026-01-21 09:05:51 -05:00
Tamir Duberstein
3eb9cacef4 aya-ebpf: add BTF ring buffer
Co-developed-by: Lukas Hoehl <lukas.hoehl@stackit.cloud>
2026-01-13 05:43:45 -05:00
Donghyun Shin
1d10f8751d aya-ebpf: fix redirect_sk_lookup receiver type
The `redirect_sk_lookup` method for SockMap and SockHash
previously required exclusive references.

The documentation for `bpf_map_lookup_elem` makes no
mention of a requirement for exclusive references.

Therefore, `redirect_sk_lookup` has been changed to
receive shared references to SockMap and SockHash.
2026-01-12 10:43:04 -05:00
tamird
b8ed06a4cd aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
2026-01-09 06:14:47 +01:00
Tamir Duberstein
d1f72a580c aya: improve ParseLine as Debug
Print human-readable strings rather than sequences of bytes.
2026-01-05 12:23:54 -05:00
Tamir Duberstein
a9945b0957 xtask: implement unit tests in VM
This is quite useful when developing on macOS.
2025-12-31 05:01:43 -05:00
swananan
eb99da3cbb uprobe: bundle attach location+cookie via UProbeAttachPoint
This follows the #1417 review discussion: by bundling location
+ cookie into a UProbeAttachPoint we get a more idiomatic Into<_>
entry point, keep the one-to-one relationship enforced by the type
system, and make it easier to extend attach with multi-location
support without introducing parallel arrays or a brand new API.
2025-12-23 18:22:42 +01:00
Tamir Duberstein
72810f095f aya: ProbeKind is Entry/Return
We already have separate types for KProbe and UProbe.
2025-11-12 11:28:03 -05:00
Tamir Duberstein
1944c4aa00 perf_event: refactor perf_event_open_trace_point
Rewrite it in terms of perf_event_open.
2025-11-12 11:28:03 -05:00
Tamir Duberstein
7e07f85edc perf_attach: privatize PerfLink
There's no way to obtain this type externally.
2025-11-12 11:28:03 -05:00
Friday Ortiz
ab38afe95d perf_event: support hardware breakpoints
Implement `PerfEventConfig::Breakpoint`, allowing users to attach
hardware breakpoints. Generate `HW_BREAKPOINT_*` and `struct
bpf_perf_event_data` in support of this feature and update the type of
`PerfEventContext` accordingly.

Add a test exercising R, W, RW, and X breakpoints. Note that R
breakpoints are unsupported on x86, and this is asserted in the test.

Extend the VM integration test harness and supporting infrastructure
(e.g. `download_kernel_images.sh`) to download kernel debug packages and
mount `System.map` in initramfs. This is needed (at least) on the aarch
6.1 Debian kernel which was not compiled with `CONFIG_KALLSYMS_ALL=y`
for some reason, 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. The KASLR offset is computed using `gunzip` which appears
in kallsyms on all Debian kernels tested.

Co-authored-by: Tamir Duberstein <tamird@gmail.com>
2025-11-10 16:33:54 -05:00
Tamir Duberstein
0484ab5c57 xtask: use -cpu host iff host == guest 2025-11-10 16:33:53 -05:00
JPaja
d8f5497884 feat: add Ebpf::maps_disjoint_mut
Implemented using `HashMap::get_disjoint_mut` introduced in Rust 1.86.0.
2025-11-10 14:12:04 -05:00
Tamir Duberstein
989a465f0c xtask: avoid extracting complete archives
Now that we're no longer shelling out to do this, we can avoid most of
the work. Operate directly on the archive, unpacking only what we need.
2025-11-10 08:53:46 -05:00
Tamir Duberstein
2b8cd557aa xtask: drop build script logging prefix
This code doesn't run under cargo.
2025-11-09 18:49:27 -05:00
Tamir Duberstein
18c7f7ccd6 perf_event: push down type safety
This makes it more difficult to mishandle callers of `perf_event_open`.

Change `wakeup_events = 0` to 1; per `man 2 perf_event_open`:

  Prior to Linux 3.0, setting wakeup_events to 0 resulted in
  no overflow notifications; more recent kernels treat 0 the
  same as 1.
2025-11-09 17:50:53 -05:00
Tamir Duberstein
7e405c216e perf_event: simplify PerfEventScope 2025-11-09 13:20:41 -05:00
Tamir Duberstein
468b9b73db xtask: use -cpu host on x86
We have started to see errors in CI:

  qemu-system-x86_64: warning: host doesn't support requested feature: CPUID[eax=80000001h].ECX.svm [bit 2]

The internet says this is the remedy.
2025-11-09 08:19:30 -05:00
Tim W
17573e0e47 aya-build: plumb features of ebpf crates
This allows callers to select features of the ebpf crate.
2025-11-03 18:43:45 -05:00
Alessandro Decina
3a3c451009 aya: restore must_exist argument to set_global
In
03e8487177
we deprecated set_global but accidentally broke its API by deleting the
must_exist argument.
2025-10-29 13:01:34 +01:00
Tamir Duberstein
03fea9e304 aya-ebpf: reduce duplication 2025-10-26 15:51:12 -04:00
Tamir Duberstein
d9704be77d aya-build: remove cargo_metadata from public API 2025-10-26 09:50:52 -04:00
Tamir Duberstein
f610453ec2 ebpf: extract CARGO_CFG_BPF_TARGET_ARCH logic 2025-10-26 07:24:46 -04:00
Tamir Duberstein
05250da20b aya-ebpf: reduce repetition and excessive traits
The traits `FromBtfArgument`, `FromRawTracepointArgs`, `FromPtRegs` are
all fancy ways of saying `Argument` - so replace these traits with it.

This also removes the use of `bpf_probe_read` which was introduced in
05c1586202 because I can't reproduce the
need for it.
2025-10-25 15:01:52 -04:00
Michal R
a7cfc694bd xtask: Allow to run VM integration tests without dpkg
Debian packages are just nested archives, where the outer one is ar
and the inner one is lzma2 tarball. Use Rust crates to unpack them.

Co-authored-by: Tamir Duberstein <tamird@gmail.com>
2025-10-23 21:17:31 +02:00
Andrew Werner
03e8487177 aya: rename set_ methods on EbpfLoader
This loader is more of a builder, so these `set_` methods didn't
quite fit. See [this discussion][1] for the motivation.

[1]: https://reviewable.io/reviews/aya-rs/aya/1318#gh-2384180366
2025-10-22 00:05:20 -04:00
Andrew Werner
5802dc7a23 aya: allow specifying a pin path for a named map
This commit extends the EbpfLoader with set_map_pin_path that allows the
caller to associate a named map with a pin path.

One note is that this path is an absolute path, not relative to
`map_pin_path`, and it forces the map to be loaded from that path.
2025-10-21 08:30:20 -04:00
Andrew Werner
1c924bb421 aya: rename map_pin_path to default_map_pin_path
This is the path in which pinned maps are created or resolved. It
isn't actually the path for any specific map itself. This rename
makes way for a method `set_map_pin_path` that actually specifies
the pin path for a specific map.
2025-10-21 08:30:20 -04:00
Tamir Duberstein
0144c0eb22 integration-test: defer cleanup to ensure unpin 2025-10-17 22:16:28 -04:00
Tamir Duberstein
2e5f5efbf1 aya: make ProgramInfo a proper enum
This allows us to distinguish between LSM and LSM_CGROUP programs and do
the proper capability check in is_program_supported.
2025-10-17 22:16:28 -04:00
Tamir Duberstein
8e9404ecd4 aya-obj: apply enum64-to-union fixup in reloc
This code is just awful.
2025-10-17 22:16:25 -04:00
Tamir Duberstein
7224efcad8 aya-obj: patch up 0-size datasec
Use OnceCell for ENUM64 while I'm here as well.
2025-10-17 15:28:22 -04:00
Tamir Duberstein
3ade19b869 Promote BTF loading failure to error on BTF relocs 2025-10-17 15:28:22 -04:00
Tyrone Wu
3d7fbaad28 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.
2025-10-16 09:51:10 -04:00
Tamir Duberstein
82aec26963 flow_dissector: add missing impl_try_into_fdlink 2025-10-16 06:20:43 -04:00
Tamir Duberstein
0cb52e850a xtask: tolerate curl failure when possible
Codex sandbox forbids network access.
2025-10-16 06:20:42 -04:00
Tamir Duberstein
667790e103 xtask: avoid git submodule update when possible
`git submodule update` fails when running in a codex sandbox:

```
  error: could not lock config file /Users/tamird/src/aya/.git/modules/libbpf/config: Operation not permitted
```

so just avoid it when not necessary.
2025-10-16 06:20:42 -04:00
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.
2025-10-16 05:22:10 -04:00
Altug Bozkurt
fc5387c806 lsm: cgroup attachment type support 2025-10-09 06:23:19 -07:00
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.
2025-10-08 08:59:04 -07:00