Commit Graph

1237 Commits (b3db9161eb304a4b83aa6122ebfc3d81fd4cd995)
 

Author SHA1 Message Date
Tamir Duberstein e93e3c4a55
Merge pull request from aya-rs/test-no-bpftool
Remove dependency on bpftool in integration tests
Tamir Duberstein 25859e4e33
xtask: emit clang command on failure
Tamir Duberstein 7067db450a
xtask: Avoid lossy string conversion
Tamir Duberstein 5a2906a6c9
test,xtask: Replace lazy_static with OnceCell
This doesn't affect MSRV because this is testing code.
Tamir Duberstein ff86f1385c
Remove dependency on bpftool in integration tests
Mary 5c86b7ee95
Merge pull request from marysaka/misc/aya-obj-enum-public
misc: aya-obj: Make it possible to externally assemble BtfEnum
Mary d9dfd94f29 misc: aya-obj: Make it possible to externally assemble BtfEnum
Alessandro Decina 4b8ffa40bb
Merge pull request from alessandrod/str-helpers-asm-bounds
bpf: improve bpf_probe_read_kernel_str_bytes and bpf_probe_read_user_str_bytes
Alessandro Decina 11c227743d bpf: improve bpf_probe_read_kernel_str_bytes and bpf_probe_read_user_str_bytes
This change does a few things:

- it fixes a bug in the wrappers, where we were expecting the kernel to
  return len=1 for b"\0" where it instead returns 0 and doesn't write
  out the NULL terminator

- it makes the helpers more robust by hardcoding bound checks in
  assembly so that LLVM optimizations can't transform the checks in a
  way that the verifier can't understand.

- it adds integration tests
Dave Tucker bc0d02143f
Merge pull request from dave-tucker/probe-cookie
aya: Make FEATURES public
Dave Tucker 47f764c191 aya: Make Features part of the public API
This commit adds a new probe for bpf_attach_cookie, which would be used
to implement USDT probes. Since USDT probes aren't currently supported,
we this triggers a dead_code warning in clippy.

There are cases where exposing FEATURES - our lazy static - is actually
helpful to users of the library. For example, they may wish to choose to
load a different version of their bytecode based on current features.
Or, in the case of an orchestrator like bpfd, we might want to allow
users to describe which features their program needs and return nice
error message is one or more nodes in their cluster doesn't support the
necessary feature set.

To do this without breaking the API, we make all the internal members of
the `Features` and `BtfFeatures` structs private, and add accessors for
them. We then add a `features()` API to avoid leaking the
lazy_static.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Alessandro Decina 76d35d10ce
Merge pull request from dave-tucker/trie
aya: Remove iter_key from LPM Trie API
Dave Tucker 00c480d2f9 aya: Remove iter_key from LPM Trie API
Based on the discussion in Discord we've decided to drop the
iter_key() API for LPM Trie. According to the kernel self-tests and
experimentation done in Aya, providing a key into bpf_map_get_next_id
will either:

- If key is an EXACT match, proceed iterating through all keys in the
trie from this point
- If key is NOT an EXACT match, proceed iterating through all keys in
the trie starting at the leftmost entry.

An API in Aya could be crafted that gets the LPM match + less specific
matches for a prefix using these semantics BUT it would only apply to
userspace. Therefore we've opted out of fixing this.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Tamir Duberstein 5c6bd55260
Merge pull request from ajwerner/change-fd-import
aya: replace os::unix::prelude with os::fd
ajwerner 65d10f9ffc aya: replace os::unix::prelude with os::fd
Mary b2737d5b0d
Merge pull request from marysaka/feat/global-data-optional
aya: allow global value to be optional
Mary 77cce840f7
Update aya/src/bpf.rs
Co-authored-by: Alessandro Decina <alessandro.d@gmail.com>
Mary 93435fc854 aya: allow global value to be optional
This allow to not error out when a global symbol is missing from the object.
Andrew Stoycos 17930a88c5
Fixups in response to alessandrod review
Move BpfError::UnsupportedMap into MapError and add a map_type field to
the error.

Update the `allow_unsupported_maps` function comment.

Update the logic to check if any unsupported maps are being used. More
specifically only search a program's maps if `allow_unsupported_maps` is
set and then use the iter function `try_for_each` with a match statement
which allows us to return the inner map type if it's unsupported.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
Andrew Stoycos b5719c5b3f
Add Unsupported Map type
Just because aya doesn't support working with some map
types doesn't mean we should't allow them to be loaded.

Add a new `Unsupported` map type to facilitate this,

Next add a user configurable option `allow_unsupported_maps()`
which can be called against the `bpfLoader`.  Additionally
add a nice warning log message when a program is being loaded
by Aya and contains an unsupported map type.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
dependabot[bot] 4c08b9b43f
Merge pull request from aya-rs/dependabot/cargo/bindgen-0.66
dependabot[bot] 77e3dc2c2e
build(deps): update bindgen requirement from 0.65 to 0.66
Updates the requirements on [bindgen](https://github.com/rust-lang/rust-bindgen) to permit the latest version.
- [Release notes](https://github.com/rust-lang/rust-bindgen/releases)
- [Changelog](https://github.com/rust-lang/rust-bindgen/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.65.0...v0.66.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
dependabot[bot] 26c6b92ef1
Merge pull request from aya-rs/dependabot/cargo/hashbrown-0.14
Kenjiro Nakayama 7dfabd07a7 Add pt_regs handling in aya-bpf/args.rs for riscv64
This patch introduces `pt_regs` handling in aya-bpf/args.rs
for the riscv64 architecture. The current CI is disabled
for riscv64 because this implementation is missing.
dependabot[bot] f5f8083441
build(deps): update hashbrown requirement from 0.13 to 0.14
Updates the requirements on [hashbrown](https://github.com/rust-lang/hashbrown) to permit the latest version.
- [Changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/hashbrown/compare/v0.13.1...v0.14.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Alessandro Decina 9cdae81265
Merge pull request from FedericoPonzi/issue-534
aya-utils: add syscall_prefix and syscall_fnname_add_prefix
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: 
dependabot[bot] 53ec1f23ea
Merge pull request from aya-rs/dependabot/cargo/rbpf-0.2.0
dependabot[bot] 4f85ff8a7b
build(deps): bump mikepenz/release-changelog-builder-action from 3 to 4 ()
Bumps [mikepenz/release-changelog-builder-action](https://github.com/mikepenz/release-changelog-builder-action) from 3 to 4.
- [Release notes](https://github.com/mikepenz/release-changelog-builder-action/releases)
- [Commits](https://github.com/mikepenz/release-changelog-builder-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: mikepenz/release-changelog-builder-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Mary e5bac02953
Merge pull request from marysaka/fix/uprobe-416-lower
aya: Fix uprobe support on 4.16 and lower
dependabot[bot] fa3dd4bef2
build(deps): update rbpf requirement from 0.1.0 to 0.2.0
Updates the requirements on [rbpf](https://github.com/qmonnet/rbpf) to permit the latest version.
- [Commits](https://github.com/qmonnet/rbpf/compare/v0.1.0...v0.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Mary 49c6f5d122 aya: Fix uprobe support on 4.16 and lower
Fix uprobe support on Ubuntu 18.04.
Alessandro Decina 41fe944a1a
Merge pull request from marysaka/fix/uprobe-debian-10
aya: Add support for old ld.so.cache format
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.
Alessandro Decina 95acc73b3d
Merge pull request from probulate/rust-cache
github: update Swatinem/rust-cache@{v1,v2}
Tamir Duberstein 6f286f1d4d
github: update Swatinem/rust-cache@{v1,v2}
I don't understand why, but dependabot isn't updating this. See
https://github.com/dependabot/dependabot-core/issues/7384.
Alessandro Decina 37b7c1e614
Merge pull request from poliorcetics/relax-ordering-probe-alias
fix: Relax unnecessarily strict atomic ordering on probe event_alias
Alexis (Poliorcetics) Bourget 243986c1da fix: Relax unnecessarily strict atomic ordering on probe event_alias
Mary d56ed8fd68
Merge pull request from marysaka/fix/aya-probe-event-alias-uniq
aya: Make probe event_alias unique
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 3f1a469f06
Merge pull request from probulate/check-refs-not-values
aya-log-ebpf: avoid requiring Copy
Tamir Duberstein 6feebef9e5
aya-log-ebpf: simplify argument validation
Tamir Duberstein de7972483b
aya-log-ebpf: avoid requiring Copy
Before this change:
```
error[E0382]: use of moved value: `no_copy`
  --> test/integration-ebpf/src/log.rs:35:9
   |
33 |         let no_copy = NoCopy {};
   |             ------- move occurs because `no_copy` has type `NoCopy`, which does not implement the `Copy` trait
34 |
35 |         debug!(&ctx, "{:x}", no_copy.consume());
   |         ^^^^^^^^^^^^^^^^^^^^^-------^---------^
   |         |                    |       |
   |         |                    |       `no_copy` moved due to this method call
   |         |                    use occurs due to use in closure
   |         value used here after move
   |
note: `NoCopy::consume` takes ownership of the receiver `self`, which moves `no_copy`
  --> test/integration-ebpf/src/log.rs:28:24
   |
28 |             fn consume(self) -> u64 {
   |                        ^^^^
   = note: this error originates in the macro `debug` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0382`.
error: could not compile `integration-ebpf` (bin "log") due to previous error
```
Mary 85ad0197e0
Merge pull request from marysaka/fix/reloc-less-strict
aya-obj: Make relocations less strict
Mary 35eaa50736 aya-obj: Make relocations less strict
Missing relocations at load time shouldn't cause an error in aya-obj
but instead poison related instructions.

This makes struct flavors work.
Alessandro Decina 3a9a54fd9b
Merge pull request from marysaka/fix/btf-reloc-all-functions
aya: Apply BTF relocations to all functions
Alessandro Decina 3211d2c928
Merge pull request from nak3/fix-bump
[codegen] Update libbpf to f7eb43b90f4c8882edf6354f8585094f8f3aade0
Kenjiro Nakayama afb4aa1c66 Add a few tweak a code to fix libbpf's API change.
Mary c4e721f3d3 aya: Apply BTF relocations to all functions
This fix aya wrong logic causing non entrypoint functions to not have
any BTF relocations working.

Also fix missing section_offset computation for instruction offset in
multiple spots.
alessandrod 0bc886f163 [codegen] Update libbpf to f7eb43b90f4c8882edf6354f8585094f8f3aade0Update libbpf to f7eb43b90f4c8882edf6354f8585094f8f3aade0
Files changed:
M	aya-obj/src/generated/btf_internal_bindings.rs
M	aya-obj/src/generated/linux_bindings_aarch64.rs
M	aya-obj/src/generated/linux_bindings_armv7.rs
M	aya-obj/src/generated/linux_bindings_riscv64.rs
M	aya-obj/src/generated/linux_bindings_x86_64.rs
M	bpf/aya-bpf-bindings/src/aarch64/bindings.rs
M	bpf/aya-bpf-bindings/src/armv7/bindings.rs
M	bpf/aya-bpf-bindings/src/riscv64/bindings.rs
M	bpf/aya-bpf-bindings/src/x86_64/bindings.rs