Commit Graph

1743 Commits (492feb2147da669487cfde5c3ad5633137f84245)
 

Author SHA1 Message Date
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.
1 year ago
Alessandro Decina 3a9a54fd9b
Merge pull request #602 from marysaka/fix/btf-reloc-all-functions
aya: Apply BTF relocations to all functions
1 year ago
Alessandro Decina 3211d2c928
Merge pull request #616 from nak3/fix-bump
[codegen] Update libbpf to f7eb43b90f4c8882edf6354f8585094f8f3aade0
1 year ago
Kenjiro Nakayama afb4aa1c66 Add a few tweak a code to fix libbpf's API change. 1 year ago
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.
1 year ago
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
1 year ago
Robert Bartlensky 47a2f25fca aya-log-ebpf-macros: fix compile errors
aya-log-ebpf-macros was failing to compile because it was referencing
a couple of `DisplayHint` variants that no longer exist. These were
removed in #599.

```
    Compiling aya-log-ebpf-macros v0.1.0 (/home/robert/aya/aya-log-ebpf-macros)
error[E0599]: no variant or associated item named `Ipv4` found for enum `DisplayHint` in the current scope
  --> aya-log-ebpf-macros/src/expand.rs:93:22
   |
93 |         DisplayHint::Ipv4 => parse_str("::aya_log_ebpf::macro_support::check_impl_ipv4"),
   |                      ^^^^ variant or associated item not found in `DisplayHint`

error[E0599]: no variant or associated item named `Ipv6` found for enum `DisplayHint` in the current scope
  --> aya-log-ebpf-macros/src/expand.rs:94:22
   |
94 |         DisplayHint::Ipv6 => parse_str("::aya_log_ebpf::macro_support::check_impl_ipv6"),
   |                      ^^^^ variant or associated item not found in `DisplayHint`

For more information about this error, try `rustc --explain E0599`.
```
1 year ago
William Batista 3d1013d729 Fixed a typo in the per_cpu_hashmap documentation 1 year ago
Michal Rostecki 84e5e2894f aya-log: Unify IP format hints into one, repsesent it by `:i` token
Having separate format hints and tokens per IP address family is
unnecessary, since they are represented by different types and we handle
format hints for each type separately. So we can just have one format
hint.

Also, we should be consistent with the format strings grammar in
Rust[0]. The `type` token, which is mapped to formatting traits, usually
consists of one letter[1] (and optional `?` for `Debug` trait, but that
doesn't matter for us). It shouldn't consist of multiple letters. Our
`:ipv4` and `:ipv6` tokens were clearly breaking that convention, so we
should rather switch to something with one letter - hence `:i`.

[0] https://doc.rust-lang.org/std/fmt/#syntax
[1] https://doc.rust-lang.org/std/fmt/#formatting-traits
1 year ago
Andrés 5894c4ce82
Fix load errors for empty (but existent) BTF/BTF.ext sections (#608)
* use the hdr_len of BTF.ext sections rather than size of struct

Otherwise this will erroneously fail on older btf_ext_header that have
less fields than the bindgen'd struct

* do not attempt to load a BTF object that has no types

* add tests

* fix: hdr_len i32 -> u32

* guard against a bigger header in the future

* use separate unsafe blocks

* simplify writing to zero'd out header

* merge safe block and address typo
1 year ago
Alessandro Decina 58f1ecbf00
Merge pull request #606 from Hanaasagi/check-format-in-log
feat(aya-log): check format and value type in proc macro
1 year ago
Hanaasagi d999a95b41 fix(aya-log): remove some useless code 1 year ago
Hanaasagi 0970300d1f feat(aya-log): check format and value type in proc macro 1 year ago
Alessandro Decina d4bfd72f57
Merge pull request #607 from Hanaasagi/fix-warning
clippy: clean useless `any` in cfg
1 year ago
Hanaasagi 0e4aec475f fix(lint): remove useless `any` `all` in cfg. 1 year ago
Shubham Jain 1fa1c142f4
docs(macros): add rust docs for cgroup_sock_addr macro (#566)
Signed-off-by: Shubham Jain <shubhamkjain@outlook.com>
Co-authored-by: vadorovsky <vadorovsky@protonmail.com>
1 year ago
vadorovsky a06a5ae07e
Merge pull request #598 from nak3/add-user_regs_strct
xtask: codegen: generate bindings for user_regs_struct
1 year ago
Alessandro Decina 5165bf2f99
Merge pull request #585 from probulate/tag-len-value
aya-log-common: support logging byte slices
1 year ago
Alessandro Decina 9c437aafd9
Merge pull request #605 from marysaka/fix/global-data-reloc-ancient-kernels
aya: Do not create data maps on kernel without global data support
1 year ago
Alessandro Decina 3a9058e762
Merge pull request #604 from marysaka/fix/section-kind-from-str
aya-obj: Fix ProgramSection::from_str for bss and rodata sections
1 year ago
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.
1 year ago
Mary 18b3d75d09 aya-obj: Fix ProgramSection::from_str for bss and rodata sections 1 year ago
Tamir Duberstein d9f966ec9e
aya-log-common: support logging byte slices
These only support LowerHex and UpperHex hints for now.
1 year ago
Tamir Duberstein 9a1a720a74
aya-log-common: generalize TagLenValue
This allows logging values backed by generators.
1 year ago
Tamir Duberstein a4a69a6bcf
aya-log, aya-log-common: economize bytes
- Replace all `#[repr(usize)]` with `#[repr(u8)]`; this saves
  3*(sizeof(word)-1) bytes per log message.
- Encode payload length as u16 rather than usize; this saves
  sizeof(word)-1 bytes per log message. This is safe because the maximum
  size of a log message is less than (1 << 16 - 1).

This changes `level` to a require field in every log message. It was
already always present, but was treated as optional when reading.
1 year ago
Tamir Duberstein e4537e389a
aya-log: check errors in tests 1 year ago
Tamir Duberstein 4d098ef413
aya-log-pbf-macros: ensure WriteToBuf is used
Previously any old `write` method could be selected.
1 year ago
Tamir Duberstein 490d7d587a
aya-log, aya-log-common: Remove duplicate struct
Previously `struct TagLenValue` was defined in both aya-log and
aya-log-common where the former implemented reading and the latter
writing; the reading logic doesn't need the struct, so remove it.
1 year ago
Tamir Duberstein 4e2f8322cc
Build tests with all features
Remove mem::forget::<HashMap>() calls in tests which fail to compile when
HashMap is provided by hashbrown:

  info: running `cargo check --all-targets --no-default-features` on aya-obj (11/23)
      Checking aya-obj v0.1.0 (/home/tamird/src/aya/aya-obj)
  error[E0505]: cannot move out of `map` because it is borrowed
     --> aya-obj/src/relocation.rs:594:21
      |
  578 |         let map = fake_legacy_map(1);
      |             --- binding `map` declared here
  579 |         let maps_by_symbol = HashMap::from([(1, ("test_map", Some(1), &map))]);
      |                                                                       ---- borrow of `map` occurs here
  ...
  594 |         mem::forget(map);
      |                     ^^^ move out of `map` occurs here
  595 |     }
      |     - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap<usize, (&str, Option<i32>, &maps::Map)>`

  error[E0505]: cannot move out of `map_1` because it is borrowed
     --> aya-obj/src/relocation.rs:655:21
      |
  632 |         let map_1 = fake_legacy_map(1);
      |             ----- binding `map_1` declared here
  ...
  635 |             (1, ("test_map_1", Some(1), &map_1)),
      |                                         ------ borrow of `map_1` occurs here
  ...
  655 |         mem::forget(map_1);
      |                     ^^^^^ move out of `map_1` occurs here
  656 |         mem::forget(map_2);
  657 |     }
      |     - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap<usize, (&str, Option<i32>, &maps::Map)>`

  error[E0505]: cannot move out of `map_2` because it is borrowed
     --> aya-obj/src/relocation.rs:656:21
      |
  633 |         let map_2 = fake_legacy_map(2);
      |             ----- binding `map_2` declared here
  ...
  636 |             (2, ("test_map_2", Some(2), &map_2)),
      |                                         ------ borrow of `map_2` occurs here
  ...
  656 |         mem::forget(map_2);
      |                     ^^^^^ move out of `map_2` occurs here
  657 |     }
      |     - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap<usize, (&str, Option<i32>, &maps::Map)>`

  error[E0505]: cannot move out of `map` because it is borrowed
     --> aya-obj/src/relocation.rs:694:21
      |
  678 |         let map = fake_btf_map(1);
      |             --- binding `map` declared here
  679 |         let maps_by_symbol = HashMap::from([(1, ("test_map", Some(1), &map))]);
      |                                                                       ---- borrow of `map` occurs here
  ...
  694 |         mem::forget(map);
      |                     ^^^ move out of `map` occurs here
  695 |     }
      |     - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap<usize, (&str, Option<i32>, &maps::Map)>`

  error[E0505]: cannot move out of `map_1` because it is borrowed
     --> aya-obj/src/relocation.rs:755:21
      |
  732 |         let map_1 = fake_btf_map(1);
      |             ----- binding `map_1` declared here
  ...
  735 |             (1, ("test_map_1", Some(1), &map_1)),
      |                                         ------ borrow of `map_1` occurs here
  ...
  755 |         mem::forget(map_1);
      |                     ^^^^^ move out of `map_1` occurs here
  756 |         mem::forget(map_2);
  757 |     }
      |     - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap<usize, (&str, Option<i32>, &maps::Map)>`

  error[E0505]: cannot move out of `map_2` because it is borrowed
     --> aya-obj/src/relocation.rs:756:21
      |
  733 |         let map_2 = fake_btf_map(2);
      |             ----- binding `map_2` declared here
  ...
  736 |             (2, ("test_map_2", Some(2), &map_2)),
      |                                         ------ borrow of `map_2` occurs here
  ...
  756 |         mem::forget(map_2);
      |                     ^^^^^ move out of `map_2` occurs here
  757 |     }
      |     - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap<usize, (&str, Option<i32>, &maps::Map)>`

  For more information about this error, try `rustc --explain E0505`.
  error: could not compile `aya-obj` due to 6 previous errors
  warning: build failed, waiting for other jobs to finish...
  error: process didn't exit successfully: `/home/tamird/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo check --all-targets --manifest-path aya-obj/Cargo.toml --no-default-features` (exit status: 101)
1 year ago
Alessandro Decina 9291457fbd
Merge pull request #603 from probulate/main
Replace actions-rs/toolchain with dtolnay/rust-toolchain
1 year ago
Tamir Duberstein d5d6a95de6
Replace actions-rs/toolchain with dtolnay/rust-toolchain
See https://github.com/actions-rs/toolchain/issues/216; actions-rs seems
to be unmaintained.
1 year ago
Mary 9e1109b3ce aya: Move program's functions to the same map 1 year ago
Alessandro Decina 7d88470944
Merge pull request #600 from probulate/system-llvm
Remove reference to system-llvm
1 year ago
Tamir Duberstein b1abac89c4
Remove reference to system-llvm
This feature is being phased out of bpf-linker.
1 year ago
vadorovsky 4776029a9f
Merge pull request #578 from aya-rs/dependabot/cargo/bindgen-0.65
build(deps): update bindgen requirement from 0.64 to 0.65
1 year ago
dependabot[bot] ee0a3c7924
build(deps): update bindgen requirement from 0.64 to 0.65
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.64.0...v0.65.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
vadorovsky 3ad3cb9ed8
Merge pull request #550 from aya-rs/dependabot/cargo/syn-2.0
build(deps): update syn requirement from 1.0 to 2.0
1 year ago
Kenjiro Nakayama 8c8d236f42 xtask: codegen: generate bindings for user_regs_struct
This patch adds `user_regs_struct`.

riscv provides struct user_regs_struct instead of struct pt_regs to userspace.
After bindings generates the code, adding the riscv support in `bpf/aya-bpf/src/args.rs`
then aya-bpf can be built for riscv.
1 year ago
dependabot[bot] 45072c0789 build(deps): update syn requirement from 1.0 to 2.0
Updates the requirements on [syn](https://github.com/dtolnay/syn) to permit the latest version.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.0...2.0.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
vadorovsky 7cd1c642e3
Merge pull request #597 from nak3/test-clippy
aya: drop unnecessary `mut`
1 year ago
Kenjiro Nakayama e67025b66f Drop unnecessary mut 1 year ago
Alessandro Decina 0a1f1a2898
Merge pull request #594 from aya-rs/dependabot/github_actions/mikepenz/release-changelog-builder-action-3
build(deps): bump mikepenz/release-changelog-builder-action from 2 to 3
1 year ago
Alessandro Decina 38b403f1be
Merge pull request #595 from aya-rs/dependabot/github_actions/actions/checkout-3
build(deps): bump actions/checkout from 2 to 3
1 year ago
Alessandro Decina 67f480eb8e
Merge pull request #592 from probulate/update-bitflags
build(deps): update bitflags requirement from 1.2.1 to 2.2.1
1 year ago
dependabot[bot] 31301e4f51
build(deps): bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
dependabot[bot] 53fb408b02
build(deps): bump mikepenz/release-changelog-builder-action from 2 to 3
Bumps [mikepenz/release-changelog-builder-action](https://github.com/mikepenz/release-changelog-builder-action) from 2 to 3.
- [Release notes](https://github.com/mikepenz/release-changelog-builder-action/releases)
- [Commits](https://github.com/mikepenz/release-changelog-builder-action/compare/v2...v3)

---
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>
1 year ago
Alessandro Decina e840c22602
Merge pull request #593 from probulate/actions-bot
Add github-actions dependabot config
1 year ago
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)
1 year ago
Tamir Duberstein 8e41cf6f5a
Add github-actions dependabot config 1 year ago
Alessandro Decina 2222b681be
Merge pull request #574 from vadorovsky/integration-aya-log
integration-test: Add tests for aya-log
1 year ago