You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aya/aya-obj/CHANGELOG.md

43 KiB

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

0.1.0 (2024-02-28)

Chore

  • Use the cargo workspace package table This allows for inheritance of common fields from the workspace root. The following fields have been made common:

    • authors
    • license
    • repository
    • homepage
    • edition
  • Appease clippy unused imports

Documentation

  • Add CHANGELOG

Other

  • appease new nightly clippy lints

      error: unnecessary use of `get("foo").is_some()`
          --> aya-obj/src/obj.rs:1690:26
           |
      1690 |         assert!(obj.maps.get("foo").is_some());
           |                          ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("foo")`
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
      note: the lint level is defined here
          --> aya-obj/src/lib.rs:68:9
           |
      68   | #![deny(clippy::all, missing_docs)]
           |         ^^^^^^^^^^^
           = note: `#[deny(clippy::unnecessary_get_then_check)]` implied by `#[deny(clippy::all)]`
    
      error: unnecessary use of `get("foo").is_some()`
          --> aya-obj/src/obj.rs:1777:26
           |
      1777 |         assert!(obj.maps.get("foo").is_some());
           |                          ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("foo")`
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
    
      error: unnecessary use of `get("bar").is_some()`
          --> aya-obj/src/obj.rs:1778:26
           |
      1778 |         assert!(obj.maps.get("bar").is_some());
           |                          ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("bar")`
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
    
      error: unnecessary use of `get("baz").is_some()`
          --> aya-obj/src/obj.rs:1779:26
           |
      1779 |         assert!(obj.maps.get("baz").is_some());
           |                          ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("baz")`
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
    
      error: unnecessary use of `get(".bss").is_some()`
          --> aya-obj/src/obj.rs:1799:26
           |
      1799 |         assert!(obj.maps.get(".bss").is_some());
           |                          ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(".bss")`
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
    
      error: unnecessary use of `get(".rodata").is_some()`
          --> aya-obj/src/obj.rs:1810:26
           |
      1810 |         assert!(obj.maps.get(".rodata").is_some());
           |                          ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(".rodata")`
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
    
      error: unnecessary use of `get(".rodata.boo").is_some()`
          --> aya-obj/src/obj.rs:1821:26
           |
      1821 |         assert!(obj.maps.get(".rodata.boo").is_some());
           |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(".rodata.boo")`
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
    
      error: unnecessary use of `get(".data").is_some()`
          --> aya-obj/src/obj.rs:1832:26
           |
      1832 |         assert!(obj.maps.get(".data").is_some());
           |                          ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(".data")`
           |
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
    
      error: unnecessary use of `get(".data.boo").is_some()`
          --> aya-obj/src/obj.rs:1843:26
           |
      1843 |         assert!(obj.maps.get(".data.boo").is_some());
           |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(".data.boo")`
    
  • Handle lack of match of enum variants correctly When comparing local_spec with target_spec for enum relocations, we can encounter a situation when a matchinng variant in a candidate spec doesn't exist.

    Before this change, such case wasn't handled explicitly, therefore resulted in returning currently constructed target_spec at the end. The problem is that such target_spec was, due to lack of match, incomplete. It didn't contain any accessors nor parts.

    Later usage of such incomplete target_spec was leading to panics, since the code operating on enums' target_spec expects at least one accessor to be available.

  • don't parse labels as programs Fixes a bug introduced by https://github.com/aya-rs/aya/pull/413 where we were generating a bunch of spurious LBB* programs.

  • remove redundant keys default-features = false is already in the root Cargo.toml.

  • group_imports = "StdExternalCrate" High time we stop debating this; let the robots do the work.

  • make maps work on kernels not supporting ProgIds On startup, the kernel is probed for support of chained program ids for CpuMap, DevMap and DevMapHash, and will patch maps at load time to have the proper size. Then, at runtime, the support is checked and will error out if a program id is passed when the kernel does not support it.

  • add support for map-bound XDP programs Such programs are to be bound to cpumap or devmap instead of the usual network interfaces.

  • MapFd and SockMapFd are owned

  • reduce indirection in section parsing Remove repetition of permitted cgroup attach types. Make optionality of name more explicit rather than pretending both kind and name are equal to section.

  • MapData::fd is non-optional The primary driver of change here is that MapData::create is now a factory function that returns Result<Self, _> rather than mutating &mut self. The remaining changes are consequences of that change, the most notable of which is the removal of several errors which are no longer possible.

  • Add clang-format

  • s/types.types[i]/*t/ where possible We already have a mutable reference in scope, use it where possible.

  • Mutate BTF in-place without clone The BTF we're working on is Cow anyway so modifying in-place is fine. All we need to do is store some information before we start our mutable iteration to avoid concurrently borrowing types both mutably and immutably.

  • use Self instead of restating the type

  • avoid multiple vector allocations Rather than creating an empty vector and iteratively appending - which might induce intermediate allocations - create an ExactSizeIterator and collect it into a vector, which should produce exactly one allocation.

  • Fix (func|line)_info multiple progs in section This commit fixes the (func|line)_info when we have multiple programs in the same section. The integration test reloc.bpf.c serves as our test case here. This required filtering down the (func|line)_info to only that in scope of the current symbol + then adjusting the offets to appease the kernel.

  • Remove name from ProgramSection The name here is never used as we get the program name from the symbol table instead.

  • Propagate sleepable into ProgramSection

  • Find programs using the symbol table This makes a few changes to the way that Aya reads the ELF object files.

    1. To find programs in a section, we use the symbols table. This allows for cases where multiple programs could appear in the same section.
    2. When parsing our ELF file we build symbols_by_section_index as an optimization as we use it for legacy maps, BTF maps and now programs.

    As a result of theses changes the "NAME" used in bpf.prog_mut("NAME") is now ALWAYS the same as the function name in the eBPF code, making the user experience more consistent.

  • better panic messages Always include operands in failing assertions. Use assert_matches over manual match + panic.

  • Define dependencies on the workspace level This way we will avoid version mismatches and make differences in features across our crates clearer.

  • avoid an allocation

  • remove dead code This logic moved in bb595c4e69. The mutation here prevented the compiler from noticing.

  • don't allocate static strings

  • aya-obj: Make it possible to externally assemble BtfEnum

  • 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.

  • allow global value to be optional This allow to not error out when a global symbol is missing from the object.

  • update hashbrown requirement from 0.13 to 0.14 Updates the requirements on hashbrown to permit the latest version.


    updated-dependencies:

    • dependency-name: hashbrown dependency-type: direct:production ...
  • update rbpf requirement from 0.1.0 to 0.2.0 Updates the requirements on rbpf to permit the latest version.


    updated-dependencies:

    • dependency-name: rbpf dependency-type: direct:production ...
  • 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.

  • 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.

  • 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.

  • Fix ProgramSection::from_str for bss and rodata sections

  • Move program's functions to the same map

  • update object requirement from 0.30 to 0.31 Updates the requirements on object to permit the latest version.


    updated-dependencies:

    • dependency-name: object dependency-type: direct:production ...
  • 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

  • Add sanitize code for kernels without bpf_probe_read_kernel Required for kernel before 5.5.

    Also move Features to aya-obj.

  • fix DATASEC to STRUCT conversion This fix the following issues:

    • Previously the DATASEC name wasn't sanitized resulting on "Invalid name" returned by old kernels.
    • The newly created BTF struct had a size of 0 making old kernels refuse it.

    This was tested on Debian 10 with kernel 4.19.0-21.

  • 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.

  • change two drain() calls to into_iter()

  • rework maps section parsing Avoid allocations and add comments explaining how things work.

  • fix compilation with nightly

  • More discrete feature logging Just use the Debug formatter vs. printing a message for each probe.

  • Make features a lazy_static

  • Add multibuffer support for XDP

  • 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.

  • btf: add support for BTF_KIND_ENUM64

  • btf: fix relocations for signed enums (32 bits) Enums now carry a signed bit in the info flags. Take it into account when applying enum relocations.

  • btf: switch ComputedRelocationValue::value to u64 This is in preparation of adding Enum64 relocation support

  • Add new map types Include all new map types which were included in the last libbpf update (5d13fd5aca).

  • Update BPF_MAP_TYPE_CGROUP_STORAGE name to BPF_MAP_TYPE_CGRP_STORAGE It changed in libbpf

  • update documentation and versioning info

    • Set the version number of aya-obj to 0.1.0.
    • Update the description of the aya-obj crate.
    • Add a section in README and rustdoc warning about the unstable API.
  • add documentation on program names This commit adds documentation on how program names are parsed from section names, as is used by aya_obj::Object.programs as HashMap keys, and updates the examples into using program names.

  • fix rustfmt diffs and typos

  • add no_std feature The crate has few libstd dependencies. Since it should be platform- independent in principle, making it no_std like the object crate would seem reasonable.

    However, the feature error_in_core is not yet stabilized, and the thiserror crate currently offers no no_std support. When the feature no_std is selected, we enable the error_in_core feature, switch to thiserror-core and replace the HashMap with the one in hashbrown.

  • add integration tests against rbpf

  • add basic documentation to public members Types relevant to maps are moved into aya_obj::maps. Some members are marked pub(crate) again.

  • migrate aya::obj into a separate crate To split the crate into two, several changes were made:

    1. Most pub(crate) are now pub to allow access from Aya;
    2. Parts of BpfError are merged into, for example, RelocationError;
    3. BTF part of Features is moved into the new crate;
    4. #![deny(missing_docs)] is removed temporarily;
    5. Some other code gets moved into the new crate, mainly:
      • aya::{bpf_map_def, BtfMapDef, PinningType},
      • aya::programs::{CgroupSock*AttachType},

    The new crate is currenly allowing missing_docs. Member visibility will be adjusted later to minimize exposure of implementation details.

  • migrate bindgen destination

Test

  • avoid lossy string conversions We can be strict in tests.

Commit Statistics

  • 145 commits contributed to the release over the course of 422 calendar days.
  • 63 commits were understood as conventional.
  • 1 unique issue was worked on: #608

Commit Details

view details
  • #608
    • Fix load errors for empty (but existent) BTF/BTF.ext sections (5894c4c)
  • Uncategorized
    • Merge pull request #891 from dave-tucker/changelog (431ce23)
    • Add CHANGELOG (72e8aab)
    • Appease new nightly clippy lints (3369169)
    • Merge pull request #882 from dave-tucker/metadata (0fadd69)
    • Use the cargo workspace package table (b3e7ef7)
    • Merge pull request #885 from dave-tucker/nightly-up (2d72197)
    • Appease clippy unused imports (770a95e)
    • Handle lack of match of enum variants correctly (c05a3b6)
    • Don't parse labels as programs (35e21ae)
    • Merge pull request #812 from tamird/redundant-cargo (715d490)
    • Remove redundant keys (cc48523)
    • Merge pull request #797 from aya-rs/rustfmt-group-imports (373fb7b)
    • Group_imports = "StdExternalCrate" (d16e607)
    • Merge pull request #527 from Tuetuopay/xdpmaps (7f9ce06)
    • Aya, bpf: misc fixes following review comments (579e3ce)
    • Make maps work on kernels not supporting ProgIds (00dc7a5)
    • Add support for map-bound XDP programs (139f382)
    • Merge pull request #770 from aya-rs/mapfd-is-owned (41d01f6)
    • MapFd and SockMapFd are owned (f415926)
    • Merge pull request #766 from aya-rs/obj-better-sense (e9690df)
    • Reduce indirection in section parsing (c139627)
    • Merge pull request #742 from aya-rs/avoid-utf-assumption (8ffd9bb)
    • Avoid lossy string conversions (572d047)
    • Merge pull request #758 from aya-rs/map-fd-not-option (1d5f764)
    • MapData::fd is non-optional (89bc255)
    • Merge pull request #749 from dave-tucker/clang-format (8ce1c00)
    • Add clang-format (0212400)
    • Merge pull request #734 from aya-rs/reduce-slicing (d3513e7)
    • S/types.types[i]/*t/ where possible (dfb6020)
    • Merge pull request #725 from dave-tucker/enum64 (2a55fc7)
    • Aya, aya-obj: Implement ENUM64 fixups (e38e256)
    • Merge pull request #731 from dave-tucker/noclone-btf (e210012)
    • Mutate BTF in-place without clone (098d436)
    • Merge pull request #726 from aya-rs/btf-iter-alloc (761e4dd)
    • Use Self instead of restating the type (826e0e5)
    • Avoid multiple vector allocations (2a054d7)
    • Merge pull request #721 from dave-tucker/fix-funcinfo (1979da9)
    • Fix (func|line)_info multiple progs in section (79ea64c)
    • Merge pull request #720 from dave-tucker/programsection-noname (e915379)
    • Remove name from ProgramSection (cca9b8f)
    • Merge pull request #711 from dave-tucker/sleepable (77e9603)
    • Propagate sleepable into ProgramSection (677e7bd)
    • Merge pull request #413 from dave-tucker/fix-names-once-and-for-all (e833a71)
    • Merge pull request #704 from aya-rs/better-panic (868a9b0)
    • Find programs using the symbol table (bf7fdff)
    • Better panic messages (17f25a6)
    • Merge pull request #699 from aya-rs/cache-again-god-damn-it (e95f76a)
    • Do not escape newlines on Err(LoadError).unwrap() (8961be9)
    • Merge pull request #667 from vadorovsky/workspace-dependencies (f554d42)
    • Define dependencies on the workspace level (96fa08b)
    • Merge pull request #665 from aya-rs/dead-code-rm (893ab76)
    • Avoid an allocation (6f2a8c8)
    • Remove dead code (d71d1e1)
    • Merge pull request #656 from aya-rs/kernel-version-fml (232cd45)
    • Replace matches with assert_matches (961f45d)
    • Merge pull request #650 from aya-rs/test-cleanup (61608e6)
    • Run tests with powerset of features (8e9712a)
    • Merge pull request #648 from aya-rs/clippy-more (a840a17)
    • Clippy over tests and integration-ebpf (e621a09)
    • Merge pull request #643 from aya-rs/procfs (6e9aba5)
    • Remove verifier log special case (b5ebcb7)
    • Merge pull request #641 from aya-rs/logger-messages-plz (4c0983b)
    • Hide details of VerifierLog (6b94b20)
    • Use procfs crate for kernel version parsing (b611038)
    • Merge pull request #642 from aya-rs/less-strings (32be47a)
    • Don't allocate static strings (27120b3)
    • Merge pull request #635 from marysaka/misc/aya-obj-enum-public (5c86b7e)
    • Aya-obj: Make it possible to externally assemble BtfEnum (d9dfd94)
    • Merge pull request #531 from dave-tucker/probe-cookie (bc0d021)
    • Make Features part of the public API (47f764c)
    • Merge pull request #632 from marysaka/feat/global-data-optional (b2737d5)
    • Allow global value to be optional (93435fc)
    • Merge pull request #626 from aya-rs/dependabot/cargo/hashbrown-0.14 (26c6b92)
    • Update hashbrown requirement from 0.13 to 0.14 (f5f8083)
    • Merge pull request #623 from aya-rs/dependabot/cargo/rbpf-0.2.0 (53ec1f2)
    • Update rbpf requirement from 0.1.0 to 0.2.0 (fa3dd4b)
    • Merge pull request #563 from marysaka/fix/reloc-less-strict (85ad019)
    • Make relocations less strict (35eaa50)
    • Merge pull request #602 from marysaka/fix/btf-reloc-all-functions (3a9a54f)
    • Merge pull request #616 from nak3/fix-bump (3211d2c)
    • Apply BTF relocations to all functions (c4e721f)
    • [codegen] Update libbpf to f7eb43b90f4c8882edf6354f8585094f8f3aade0Update libbpf to f7eb43b90f4c8882edf6354f8585094f8f3aade0 (0bc886f)
    • Merge pull request #585 from probulate/tag-len-value (5165bf2)
    • Merge pull request #605 from marysaka/fix/global-data-reloc-ancient-kernels (9c437aa)
    • Merge pull request #604 from marysaka/fix/section-kind-from-str (3a9058e)
    • Do not create data maps on kernel without global data support (591e212)
    • Fix ProgramSection::from_str for bss and rodata sections (18b3d75)
    • Build tests with all features (4e2f832)
    • Move program's functions to the same map (9e1109b)
    • Merge pull request #597 from nak3/test-clippy (7cd1c64)
    • Drop unnecessary mut (e67025b)
    • Merge pull request #577 from aya-rs/dependabot/cargo/object-0.31 (deb054a)
    • Merge pull request #545 from epompeii/lsm_sleepable (120b59d)
    • Update object requirement from 0.30 to 0.31 (4c78f7f)
    • Merge pull request #586 from probulate/no-std-inversion (45efa63)
    • Flip feature "no_std" to feature "std" (33a0a2b)
    • Merge branch 'aya-rs:main' into lsm_sleepable (1f2006b)
    • Merge pull request #583 from 0xrawsec/fix-builtin-linkage (b2d5059)
      • comment changed to be more precise - adapted test to be more readable (1464bdc)
    • Added memmove, memcmp to the list of function changed to BTF_FUNC_STATIC (72c1572)
    • Fixed indent (a51c9bc)
    • Removed useless line break and comments (5b4fc9e)
    • Add debug messages (74bc754)
    • Merge pull request #582 from marysaka/feature/no-kern-read-sanitizer (b5c2928)
    • Add sanitize code for kernels without bpf_probe_read_kernel (1132b6e)
    • Fixed BTF linkage of memset and memcpy to static (4e41da6)
    • Merge pull request #581 from marysaka/fix/datasec-struct-conversion (858f77b)
    • Fix DATASEC to STRUCT conversion (4e33fa0)
    • Merge pull request #572 from alessandrod/reloc-fixes (542ada3)
    • Support relocations across multiple text sections + fixes (93ac3e9)
    • Change two drain() calls to into_iter() (b25a089)
    • Aya, aya-obj: refactor map relocations (401ea5e)
    • Rework maps section parsing (5c4f1d6)
    • Review (85714d5)
    • Macro (6dfb9d8)
    • Obj (6a25d4d)
    • Fix compilation with nightly (dfbe120)
    • Merge pull request #537 from aya-rs/codegen (8684a57)
    • [codegen] Update libbpf to a41e6ef3251cba858021b90c33abb9efdb17f575Update libbpf to a41e6ef3251cba858021b90c33abb9efdb17f575 (24f15ea)
    • More discrete feature logging (7479c1d)
    • Make features a lazy_static (ce22ca6)
    • Merge pull request #519 from dave-tucker/frags (bc83f20)
    • Add multibuffer support for XDP (376c486)
    • Add support for multibuffer programs (a18693b)
    • Merge pull request #453 from alessandrod/btf-kind-enum64 (e8e2767)
    • Btf: add support for BTF_KIND_ENUM64 (9a6f814)
    • Merge pull request #501 from alessandrod/fix-enum32-relocs (f81b1b9)
    • Btf: fix relocations for signed enums (32 bits) (4482db4)
    • Btf: switch ComputedRelocationValue::value to u64 (d6b976c)
    • Fix lints (9f4ef6f)
    • Merge pull request #487 from vadorovsky/new-map-types (42c4a8b)
    • Add new map types (3d03c8a)
    • Merge pull request #483 from aya-rs/codegen (0399991)
    • Update BPF_MAP_TYPE_CGROUP_STORAGE name to BPF_MAP_TYPE_CGRP_STORAGE (cb28533)
    • [codegen] Update libbpf to 3423d5e7cdab356d115aef7f987b4a1098ede448Update libbpf to 3423d5e7cdab356d115aef7f987b4a1098ede448 (5d13fd5)
    • Merge pull request #475 from yesh0/aya-obj (897957a)
    • Update documentation and versioning info (9c451a3)
    • Add documentation on program names (772af17)
    • Fix rustfmt diffs and typos (9ec3447)
    • Add no_std feature (30f1fab)
    • Add integration tests against rbpf (311ead6)
    • Add basic documentation to public members (e52497c)
    • Migrate aya::obj into a separate crate (ac49827)
    • Migrate bindgen destination (81bc307)