Commit Graph

178 Commits

Author SHA1 Message Date
Tamir Duberstein 2c927581fe Remove duplicate attach type state
Pass the kernel attach type into the shared loader from each typed
wrapper instead of storing a second mutable copy in `ProgramData`.

This removes the from_pin repair pattern, avoids stale shadow state, and
keeps attach paths driven by wrapper-owned typed attach metadata or
fixed constants.

Also simplify `{sk,cgroup}_skb` section parsing by representing all
variants as `ProgramSection::SkSkb { kind }` and
`ProgramSection::CgroupSkb { attach_type }` respectively, with the
attach type enums shared from aya-obj.
2026-04-03 11:21:32 -04:00
Weixie Cui 5bce2b7e29 aya-obj: mask Func linkage with 16 bits
Match `Func::new` and `set_linkage`, which store linkage in the low
16 bits of `info`; reading with 0xFFF dropped the high nibble of that
field.
2026-03-26 14:55:27 +01:00
Weixie Cui 8f690b7734 aya-obj: fix line_info.num_info when linking functions
Set num_info from the merged line_info table length, matching func_info
handling and BTF line_info record counts.
2026-03-26 09:23:25 +00:00
Tamir Duberstein aa122f319f appease clippy
```
  error: this `if` can be collapsed into the outer `match`
     --> aya-obj/src/btf/btf.rs:743:21
      |
  743 | /                     if !features.btf_enum64 {
  744 | |                         debug!("{kind}: not supported. replacing with UNION");
  ...   |
  798 | |                         *t = BtfType::Union(Union::new(name_offset, size, members, Some(fallback)));
  799 | |                     }
      | |_____________________^
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
      = note: `-D clippy::collapsible-match` implied by `-D warnings`
      = help: to override `-D warnings` add `#[allow(clippy::collapsible_match)]`
  help: collapse nested if block
      |
  740 ~                 BtfType::Enum64(ty)
  741 |                     // Kernels before 6.0 do not support ENUM64. See
  742 |                     // https://github.com/torvalds/linux/commit/6089fb325cf737eeb2c4d236c94697112ca860da.
  743 ~                     if !features.btf_enum64 => {
  744 |                         debug!("{kind}: not supported. replacing with UNION");
  ...
  798 |                         *t = BtfType::Union(Union::new(name_offset, size, members, Some(fallback)));
  799 ~                     }
```
2026-02-27 11:26:34 -05:00
Tamir Duberstein 2f8759cc62 Dial the lints to 100 2026-01-29 10:02:48 -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
Daniel Mellado 7a3c03e178 Add licese for aya-obj
This commit adds a link for the needed licenses in aya-obj for fedora
packaging.

Signed-off-by: Daniel Mellado <dmellado@fedoraproject.org>
2025-11-30 13:58:43 -05:00
Tamir Duberstein d238b2ea6f Release crates
- aya v0.13.2
- aya-build v0.1.3
- aya-ebpf v0.1.2
- aya-ebpf-bindings v0.1.2
- aya-ebpf-cty v0.2.3
- aya-ebpf-macros v0.1.2
- aya-log v0.2.2
- aya-log-common v0.1.16
- aya-log-ebpf v0.1.2
- aya-log-ebpf-macros v0.1.1
- aya-log-parser v0.1.14
- aya-obj v0.2.2

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
2025-11-17 14:51:14 -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 866cbe4837 all: bump MSRV to 1.87.0
Use newly stabilized `is_multiple_of`.
2025-11-09 12:23:04 -05: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 166ad2f40f btf: reduce repetition
This code is bad.
2025-10-17 15:28:22 -04:00
Tamir Duberstein 122cf17a43 btf: avoid unreachable!() and unwrap() 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
Tamir Duberstein f76fdf9da5 Improve error output
- Use consistent casing.
- Emit syscall return value.
2025-10-16 06:20:43 -04:00
Altug Bozkurt fc5387c806 lsm: cgroup attachment type support 2025-10-09 06:23:19 -07:00
Tamir Duberstein 5f5305c2a8 lint all crates; enable strict pointer lints 2025-09-29 05:19:23 -04:00
Tamir Duberstein 30182463bd aya-obj: explicitly enable hashbrown features 2025-09-19 16:32:49 +09:00
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>
2025-09-18 10:49:59 +00:00
Michal R e0ceb6214b aya-obj: Remove Safety: union comments
They serve no purpose, there are no unions no unsafe operations around.
2025-09-18 10:49:59 +00:00
Tamir Duberstein 658ae0fbb9 aya-obj: simplify using CStr::from_bytes_until_nul 2025-09-18 10:49:59 +00:00
tamird 23cbab571c aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
2025-09-01 00:57:03 -04:00
Tamir Duberstein a3aa387a2e remove superfluous commas 2025-08-11 16:50:31 -04:00
tamird bd0424ca61 aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
2025-06-09 15:24:17 -04:00
Tamir Duberstein b6daf463e6 Remove stale comment since a1b46ece05 2025-05-16 10:13:08 -04:00
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.
2025-05-14 08:03:51 -04:00
Tamir Duberstein 583709f6a0 appease clippy::uninlined-format-args 2025-04-24 06:42:21 -04:00
dave-tucker 5e4e12ce78 aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
2025-03-31 12:55:59 +00:00
Dave Tucker 9eecbe9d0e Merge pull request #1224 from dave-tucker/unused_trait_names
chore(*): set clippy unused_trait_names = warn
2025-03-20 19:31:36 +00:00
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>
2025-03-20 13:54:10 -04:00
Dave Tucker f6c5cb2ad2 chore(*): set clippy unused_trait_names = warn
We have previously tried to import traits anonymously where possible but
enforcing this manually was hard.

Since Rust 1.83 clippy can now enforce this for us.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2025-03-20 15:16:11 +00:00
Tamir Duberstein 49a828ec56 taplo: reorder-keys
Group non-workspace keys before workspace ones for readability.
2025-03-17 11:38:09 -04:00
Tamir Duberstein a43e40ae1d introduce workspace lints, warn on unused crates
In practice this will forbid unused dependencies because we run clippy
with `--deny warnings`.

Workspace lints is a nice place to ratchet up lints through the codebase
all at once and consistently.
2025-03-06 14:46:03 -05:00
Tamir Duberstein 6252b4c972 aya-obj,aya-ebpf-*: hook up loongarch64
This causes rustfmt to format those files.

Squish some other conditional compilation to get rustfmt sorting.
2025-03-04 15:59:00 -05:00
Tamir Duberstein 56ebe1406e aya-tool: do not attempt to run rustfmt
This can be done externally. Do so in CI.

This is an attempt to resolve the inconsistency between CI and local
rustfmt in the generated bindings.

Restore running CI on generated branches; the presence of a PR is
apparently not enough.
2025-03-04 11:45:05 -05:00
tamird 2bb2302d1d aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
2025-03-04 10:46:20 -05:00
Tamir Duberstein f0a9f19ddc Bump edition to 2024
Change FromRawTracepointArgs::arg to return T rather than *const T which
seems to have been returning a dangling pointer.

Arguably this is not strictly necessary; edition 2024 seems to be
focused on increased strictness around unsafe code which doesn't unlock
new functionality for our users. That said, this work revealed an
apparent bug (see above) that we wouldn't otherwise catch due to
allow-by-default lints.
2025-03-04 10:43:56 -05:00
Tamir Duberstein ea5f7e3015 Reduce the scope of expected warnings
This fixes a few safety comments to avoid the warnings.
2025-03-04 10:43:56 -05:00
Tamir Duberstein 4101a5a55d Use #[expect(...)] rather than #[allow(...)]
This is stricter, and revealed a few unused allowances.
2025-03-04 10:43:56 -05:00
dave-tucker ce0e93c75d aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
2025-03-04 08:23:26 -05:00
Tamir Duberstein bdd8ae2d0b *: avoid _
This can silently discard information, so we shouldn't do it.
2025-03-03 11:28:34 -05:00
Tamir Duberstein 5ff57f1d9e Use ignore rather than not compile on big endian 2025-03-03 10:04:46 -05:00
Tamir Duberstein 9a47495227 aya,aya-obj: preserve pointer provenance 2025-03-03 10:04:46 -05:00
Tamir Duberstein b500a6326b tests: use cfg! to tidy up 2025-03-03 08:29:13 -05:00
tamird f49a761c27 aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
2025-03-02 11:50:54 -05:00
tamird ade2e2a739 aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
2025-02-05 11:15:35 -05:00
Tamir Duberstein c8f14b18d4 codegen: tidy up
Move some code out of a loop, where it appears to be nonsense.
2025-02-05 10:39:17 -05:00