Commit Graph

2028 Commits (main)
 

Author SHA1 Message Date
Tamir Duberstein 5732b2c203 test-distro: build without cross toolchain
Make the xz2 dependency optional to allow building without a C cross
compiler. This allows clippy.sh to be used on e.g. macOS more easily:

```
./clippy.sh --target x86_64-unknown-linux-gnu --exclude-features xz2
```
5 days ago
Tamir Duberstein edae5cd676 test-distro: reduce indentation 5 days ago
Tamir Duberstein 35279b7c7b test-distro: extract common decompression code
Remove vector preallocation in the uncompressed case; the standard
library implementation of `io::Read` for `fs::File` already does this.
5 days ago
Tamir Duberstein 680402be0c Revert "ci: download gen_init_cpio with authentication"
This removes octorust which takes absolutely ages to compile and also
requires native TLS libraries which in turn require a C toolchain. The
latter is a pain when cross compiling from macOS.

This reverts commit cc2da4a2a4.
5 days ago
Tamir Duberstein e967d0aea2 Use nul bytes as delimiters 5 days ago
Tamir Duberstein e692e5ffc5 Remove stale comments
Upstream isn't planning to do this.
5 days ago
Tamir Duberstein fe8e1c48b0 Remove getrandom patch
https://github.com/rust-random/getrandom/releases/tag/v0.3.2 contains
b75db5cede.
2 weeks ago
Dave Tucker 4c5fbef869
Merge pull request #1240 from dave-tucker/use-gen-bpf-add 2 weeks ago
dependabot[bot] 11e9dcc179
Merge pull request #1241 from aya-rs/dependabot/cargo/cargo-crates-cb2c366dd6 2 weeks ago
dependabot[bot] ac6b04fa1d
build(deps): update public-api requirement in the cargo-crates group
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.44.2
- [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.44.0...public-api-v0.44.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2 weeks ago
Dave Tucker 23a5e06c75 chore(aya): Use BPF_ADD from bindings
We should use the generated one, not the one provided by the libc crate.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 weeks ago
Dave Tucker 756d8172f5
Merge pull request #1239 from aya-rs/create-pull-request/codegen 2 weeks ago
dave-tucker 5e4e12ce78 aya-obj, aya-ebpf-bindings: regenerate
libbpf commit: 20ea95b4505c477af3b6ff6ce9d19cee868ddc5d
2 weeks ago
Dave Tucker e362ac2fbc
Merge pull request #1238 from dave-tucker/bind-all-insns 2 weeks ago
Dave Tucker 59c02447fa chore: generate bindings for all eBPF insns
The binding for BPF_ADD was missing from codegen.
Use BPF_.* to capture all of these to avoid missing bindings in future.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 weeks ago
Andres fc69a06972
aya: fix is_probe_read_kernel_supported in aarch64 kernels 5.5 (#1235)
In aarch64, with kernel 5.5, my programs that use `bpf_probe_read_user`
don't work successfully because `aya` is mistakenly re-writting it
`bpf_probe_read` because it falsely detects that the kernel doesn't
support `bpf_probe_read_user`.

I hadn't updated my `aya` version in a while, but while updating it to
fix a separate issue (panics when parsing kernel versions of PVE
kernels) and running my test suite I saw tests failing on aarch64 5.5
kernels. A git bisect led me to this commit:
942ea51906 and further investigation in the
difference of the new and old assembly showed that the only difference
was subtracting 8 vs adding -8. When I put it back as adding 8 (but
without handwritten assembly) then things work as expected. Since it
used to be `BPF_ADD` and the commit that changed it was just about no
longer handwriting assembly without any reason for the switch to
`BPF_SUB` putting it back as `BPF_ADD` seems reasonable. 

When using `BPF_SUB` 8, the handwritten program in this function
returns a permission error which is treated by this function as
`bpf_probe_read_kernel` not being supported when it is but for some
reason `BPF_SUB` is not. My guess is that it might be an early verifier
error but I am not 100% sure as I thought verifier errors are normally
`EINVAL` not `EPERM` but I have a vague memory of seeing `EPERM` in the
past for errors that happened very early in the verifier.

Fixes: #1233
2 weeks 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.
2 weeks 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
2 weeks ago
Dave Tucker 816f6d8a25
Merge pull request #1234 from dave-tucker/fix-clippy-warn
chore: Fix clippy panic_handler warnings
2 weeks ago
Dave Tucker 3078e5aba0 chore: Fix clippy panic_handler warnings
Working with aya in vscode will currently show a number of warnings
along the lines of:

```
found duplicate lang item `panic_impl`
the lang item is first defined in crate `std` (which `aya` depends on)
...
second definition in the local crate (`bpf_probe_read`)
```

This comes from feature unification.
integration-test requires the integration-common user feature, which
requires aya, which in turn brings in std.

For this same reason we avoid running clippy across the whole workspace.

We can avoid this issue by using the panic handler from the another
crate, which implements the same loop {} panic handler we use today.
It seems rustc is happy to conditionally link the panic handler
from an external crate without issuing warnings.

Therefore, we add our own crate - ebpf-panic - for this purpose.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 weeks ago
Dave Tucker da3f09e28b chore: move network-types to workspace dep
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 weeks ago
Dave Tucker 1db534defa
Merge pull request #1209 from dave-tucker/from_prog_info
feat: Allow conversions to Program from ProgramInfo
3 weeks ago
Dave Tucker d9ef2df2f0
Merge pull request #1225 from dave-tucker/fix-clippy
chore(aya): Fix clippy unused cfg_attr
3 weeks ago
Dave Tucker e8e268ba76 chore(aya): Fix clippy unused cfg_attr
clippy complained that cfg_attr is applied to the macro invocation and
therefore will not be expanded. This was a false-positive, however
when playing with cargo expand I did notice that the cfg and cfg_attr
section weren't propagating as I would expect them to.

Adding a meta matcher to the impl_try_from_map macro allows us to
remove the need for AsyncPerfEventArray to be in a separate invocation
of the macro while also making sure that attributes do get propagated
to the generated functions.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 weeks 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>
3 weeks ago
tamird e96431f07a public-api: regenerate 3 weeks ago
Dave Tucker 9eecbe9d0e
Merge pull request #1224 from dave-tucker/unused_trait_names
chore(*): set clippy unused_trait_names = warn
3 weeks 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>
3 weeks ago
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>
3 weeks ago
x0rw 34a3d6c27b Update README.md
CgroupSkb::attach() requires three parameters
4 weeks ago
Dave Tucker 29f4f2b780
Merge pull request #1160 from dave-tucker/modprobe 4 weeks ago
Dave Tucker abe5f743a3 feat: Refactor init into test-distro
The init module contains a small init system for running our integration
tests against a kernel. While we don't need a full-blown linux distro,
we do need some utilities.

Once such utility is `modprobe` which allows us to load kernel modules.
Rather than create a new module for this utility, I've instead
refactored `init` into `test-distro` which is a module that contains
multiple binaries.

The xtask code has been adjusted to ensure these binaries are inserted
into the correct places in our cpio archive, as well as bringing in the
kernel modules.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
4 weeks ago
Tamir Duberstein 3edc36af9d aya: remove unhelpful comment 4 weeks ago
Tamir Duberstein f890bb3dce integration-test: kernel_assert anti-condition
Rather than emitting a warning, assert the inverse of the condition when
the current kernel version is lower than required. This strengthens the
assertions made by our tests (provided we run them over kernel versions
before and after the listed version, which is not yet the case).
4 weeks ago
Tamir Duberstein 509032f195 integration-test: use scopeguard over panic hook 4 weeks ago
Tamir Duberstein b8f0c56d15 integration-test: avoid Option::is_some_and
These are just pointless.
4 weeks ago
Tamir Duberstein 1320aa1a28 integration-test: fix typo 4 weeks ago
Tamir Duberstein 49a828ec56 taplo: reorder-keys
Group non-workspace keys before workspace ones for readability.
4 weeks ago
Tamir Duberstein 1ff2c0a2d2 Cargo.toml: sort dependencies 4 weeks ago
Tamir Duberstein 0153bdd950 github: update dependabot docs link 4 weeks ago
tamird 75aac18f8a public-api: regenerate 4 weeks ago
WANG Rui e3aa47f0db Update octorust to 0.10 1 month ago
Michal Rostecki f48b5a4a84 aya: Ensure that truncated map names are NULL terminated
Limit of map names in eBPF is 16 bytes and they have to be NULL
terminated.

Before this change, long names were truncated to 16 bytes.
`MAP_WITH_LOOOONG_NAAAAAAAAME` would become `MAP_WITH_LOOOONG`, which
doesn't contain the NULL byte.

This change fixes that by truncating the name to 15 bytes, ensuring
that the 16th byte is NULL. `MAP_WITH_LOOOONG_NAAAAAAAAME` is truncated
to `MAP_WITH_LOOOON\0`.
1 month ago
tamird dcf66db845 public-api: regenerate 1 month ago
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.
1 month ago
Dave Tucker 65489e1d4c
Merge pull request #1210 from dave-tucker/no-mergify-dependabot
chore: Disable mergify on dependabot PRs
1 month ago
Tamir Duberstein 22c8f783e7 programs: allow program names to be static strings 1 month ago
Dave Tucker 00b5cc5aaf chore: Disable mergify on dependabot PRs
Merging via comment isn't possible. We could merge this automatically on
green, however we'd prefer to use @dependabot merge or merge manually.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 month ago
arctic-alpaca 73a34e1571 aya: Add `XskMap::unset` 1 month ago
Dave Tucker ea76e0f62d aya: parse complete entries from /proc/$pid/maps
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
1 month ago