Commit Graph

468 Commits (4c08b9b43f2734c776c6b3f22cf9262a0db577db)

Author SHA1 Message Date
Federico Ponzi 987e8489d0 aya-utils: add syscall_prefix and syscall_fnname_add_prefix
These two functions are needed because kernel symbols representing
syscalls have architecture-specific prefixes.

These are the equivalent of bcc's get_syscall_fnname and
get_syscall_prefix.

Solves: 
Mary 49c6f5d122 aya: Fix uprobe support on 4.16 and lower
Fix uprobe support on Ubuntu 18.04.
Mary 8e9f395eab aya: Add support for old ld.so.cache format
This fix uprobe support on Debian 10. (and possibly others)
This implement support to parse the original libc5 format.
Alexis (Poliorcetics) Bourget 243986c1da fix: Relax unnecessarily strict atomic ordering on probe event_alias
Mary e9be3d9023 aya: Make probe event_alias unique
This fixes issues when trying to attach the same kernel function multiple times on 4.17 and lower (possibly upper too?)
Alessandro Decina 3a9a54fd9b
Merge pull request from marysaka/fix/btf-reloc-all-functions
aya: Apply BTF relocations to all functions
Kenjiro Nakayama afb4aa1c66 Add a few tweak a code to fix libbpf's API change.
William Batista 3d1013d729 Fixed a typo in the per_cpu_hashmap documentation
Hanaasagi 0e4aec475f fix(lint): remove useless `any` `all` in cfg.
Mary 591e21267a aya: Do not create data maps on kernel without global data support
Fix map creation failure when a BPF have a data section on older
kernel. (< 5.2)

If the BPF uses that section, relocation will fail accordingly and
report an error.
Mary 9e1109b3ce aya: Move program's functions to the same map
Tamir Duberstein ae8a95b0ee
build(deps): update bitflags requirement from 1.2.1 to 2.2.1
Updates the requirements on [bitflags](https://github.com/bitflags/bitflags) to permit the latest version.
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/1.2.1...2.2.1)
vadorovsky deb054afa4
Merge pull request from aya-rs/dependabot/cargo/object-0.31
build(deps): update object requirement from 0.30 to 0.31
Alessandro Decina 120b59dd2e
Merge pull request from epompeii/lsm_sleepable
Add `BPF_F_SLEEPABLE` flag support to LSM
dependabot[bot] 4c78f7f1a0
build(deps): update object requirement from 0.30 to 0.31
Updates the requirements on [object](https://github.com/gimli-rs/object) to permit the latest version.
- [Release notes](https://github.com/gimli-rs/object/releases)
- [Changelog](https://github.com/gimli-rs/object/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gimli-rs/object/compare/0.30.0...0.31.0)

---
updated-dependencies:
- dependency-name: object
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Alessandro Decina 45efa6384f
Merge pull request from probulate/no-std-inversion
aya: flip feature "no_std" to feature "std"
Tamir Duberstein 33a0a2b604
aya: flip feature "no_std" to feature "std"
This fixes `cargo build --all-features` by sidestepping the feature
unification problem described in The Cargo Book[0].

Add `cargo hack --feature-powerset` to CI to enforce that this doesn't
regress (and that all combinations of features work).

Since error_in_core is nightly-only, use core-error and a fake std
module to allow aya-obj to build without std on stable.

[0] https://doc.rust-lang.org/cargo/reference/features.html#feature-unification
Everett Pompeii 1f2006bfde
Merge branch 'aya-rs:main' into lsm_sleepable
Dave Tucker ed14751c79
Merge pull request from dave-tucker/borrow
aya: MapData should be Borrow, not AsRef
Mary 3aeeb8167b aya: Correctly set the kernel code version for Debian kernel
Fix BPF syscall failure related to the kernel code version.
Mary f1d891836e aya: Correctly set the kernel code version for Ubuntu kernel
Fix BPF syscall failure related to the kernel code version.
Mary 1132b6e01b aya: Add sanitize code for kernels without bpf_probe_read_kernel
Required for kernel before 5.5.

Also move Features to aya-obj.
Mary 7c25fe90a9 aya: Do not use unwrap with btf_fd in bpf_create_map
Fixes a crash when trying to create a map of type BPF_MAP_TYPE_PERCPU_ARRAY when btf_fd is None.

Tested on Ubuntu 18.04 (4.15.0-202-generic)
Alessandro Decina 93ac3e94bc aya: support relocations across multiple text sections + fixes
Fix R_BPF_64_64 text relocations in sections other than .text (for
instance .text.unlikely). Also fix misc bugs triggered by integration
tests.
Alessandro Decina 401ea5e848 aya, aya-obj: refactor map relocations
Clearly split the code between `.maps`, `maps` and data maps (bss, data,
rodata). Sprinkle comments.

Remove MapKind which was effectively only needed since we used to have
one variant - BpfSectionKind::Data - to represent all data maps. Instead
add explicit BpfSectionKind::{Data, Rodata, Bss} variants and match on
those when we initialize maps.
epompeii 85714d5cf3 review
epompeii 17f497ce42 program_section
Alessandro Decina b13070a342
Merge pull request from drewvis/main
Add check for empty tracefs mounts
Alessandro Decina bcb2972a96 aya: make it possible to use set_global() with slices of Pod(s)
drewvis 8f64cf8cd5 Added code check comment
drewvis 3a2c0cd1dd Add check for empty tracefs mounts
Alessandro Decina 8ef00c4c63 Revert "aya: make it possible to use set_global() with slices of Pod(s)"
This reverts commit b614ffd603.
Alessandro Decina b614ffd603 aya: make it possible to use set_global() with slices of Pod(s)
Mikhail Trishchenkov ce60854934 Don't leak libc types
Mikhail Trishchenkov 896e3ab313 Fix formatting
Mikhail Trishchenkov 676b5cdc0d Rename method and fix comment
Mikhail Trishchenkov 2e3c1779be aya: Allow to attach XDP probe by interface index
Mary 94049ec661 aya: Fix MapData Clone implementation
The Clone implementation of MapData was previously not storing the
result of the dup operation.
Dave Tucker de4905a24b aya: Add loaded_programs() API to list all loaded programs
This uses a Programs iterator to yield all loaded bpf programs using
bpf_prog_get_next_id.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker b1a70fc6e4 aya: MapData should be Borrow, not AsRef
We don't ever do ref-to-ref conversion for MapData so Borrow should
suffice.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker ce79de7ff6 aya: Fix is_perf_link_supported
This was mistakenly comparing the exit code of the syscall, which is
always -1 and not the corresponding error-code. Added unit tests to
ensure we don't regress.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker 7479c1dd6c aya: More discrete feature logging
Just use the Debug formatter vs. printing a message for each probe.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker d0b3d3b2fa aya: Enable bpf_link for perf_attach programs
This adds support for bpf_link to PerfEvent, Tracepoint, Kprobe and
Uprobe programs.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker 763b92a2e0 aya: Add probe for bpf_link_create for perf programs
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker ce22ca668f aya: Make features a lazy_static
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker a18693b42d aya: Add support for multibuffer programs
This adds support for loading XDP programs that are multi-buffer
capable, which is signalled using the xdp.frags section name. When this
is set, we should set the BPF_F_XDP_HAS_FRAGS flag when loading the
program into the kernel.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker 7a720ab0c1 aya: Add from_pin for Programs
This commit adds from_pin() which allows the creation of a Program
from a path on bpffs. This is useful to be able to call `attach` or
other APIs for programs that are already loaded to the kernel.

This differs from  since it implements this on the concrete program
type, not the Program enum, allowing the user to pass in any additional
context that isn't available from bpf_prog_info.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Alessandro Decina cfa693bc3b
Merge pull request from alessandrod/fix-lru-hash
aya: fix Lru and LruPerCpu hash maps
Alessandro Decina c22014c757 aya: fix Lru and LruPerCpu hash maps
They were broken by https://github.com/aya-rs/aya/pull/397
Andrew Stoycos 52e625060e
Support BTF key/value specification for all maps
Fix a bug which was resulting in `ENOTSUPP` following
the `BPF_MAP_CREATE` Syscall.  This fix was initially
found by libbpf maintainers in:
https://github.com/libbpf/libbpf/issues/355.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>