Commit Graph

462 Commits (06f89388082274155519e620cc046feeba7aab00)
 

Author SHA1 Message Date
Dave Tucker 06f8938808
Merge pull request #164 from dave-tucker/btf_verifier
aya: Fix BTF verifier output
3 years ago
Dave Tucker 5d8b279265 aya: Fix BTF verifier output
Currently errors can occur if the verifier output is > buffer as we get
ENOMEM. We should only provide a log_buf if initial load failed, then
retry up to 10 times to get full verifier output.

To DRY this logic it has been moved to a function so its shared with
program loading

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>

one verifier loop to rule them all

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker d9496df3a7
Merge pull request #173 from alessandrod/func-proto-fixup
Add fixup for FuncProto
3 years ago
Dave Tucker f70ab2caa7
Merge pull request #174 from alessandrod/func-global-fix
btf: fix sanitization if BTF_FUNC_GLOBAL is not supported
3 years ago
Alessandro Decina 7ad0524283 btf: fix sanitization if BTF_FUNC_GLOBAL is not supported
The lower 16 bits were not actually being cleared.
3 years ago
Alessandro Decina 9ba2e147a1 btf: fixup func protos
If an argument has a type, it must also have a name, see btf_func_check
in the kernel.

Given:

SEC("lsm/syslog")
int BPF_PROG(syslog_audit, int type, int ret_prev)
{
        return 0;
}

Fixes:

error: BTF error: the BPF_BTF_LOAD syscall failed. Verifier output: magic: 0xeb9f
version: 1
flags: 0x0
hdr_len: 24
type_off: 0
type_len: 76
str_off: 76
str_len: 128
btf_total_size: 228
[1] FUNC_PROTO (anon) return=2 args=(3 (anon))
[2] INT int size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
[3] PTR (anon) type_id=4
[4] INT long long unsigned int size=8 bits_offset=0 nr_bits=64 encoding=(none)
[5] FUNC syslog_audit type_id=1
[5] FUNC syslog_audit type_id=1 Invalid arg#1
: Invalid argument (os error 22)
3 years ago
Alessandro Decina 89b5dd32ed btf: run fixup in place 3 years ago
Alessandro Decina b45a160bb0
Merge pull request #168 from dave-tucker/decl_tag
btf: Add support for BTF_TYPE_KIND_{TAG,DECL_TAG}
3 years ago
Alessandro Decina b93188fefe
Merge pull request #172 from dave-tucker/name_trunc
aya: Fix name truncation
3 years ago
Dave Tucker 8f9a32ff10 aya: Fix name truncation
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina dccdc45ccd
Merge pull request #171 from dave-tucker/nametoolong
aya: Truncate long program names
3 years ago
Dave Tucker 437432cdd6 aya: Truncate long program names
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 5d9ff70498 btf: Add support for BTF_TYPE_KIND_{TAG,DECL_TAG}
Adds support for two new BTF kinds including feature probes and BTF
sanitization

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 1492d85a7b
Merge pull request #169 from dave-tucker/fix_array_relo
aya: Fix BTF type resolution for Arrays and Ints
3 years ago
Alessandro Decina 6a91fdf5a7
Merge pull request #157 from dave-tucker/doc-aya
aya: document the public api
3 years ago
Dave Tucker 686ce45f93 aya: Fix BTF type resolution for Arrays and Ints
The union of `size` and `type` is unused in BTF_KIND_ARRAY.
Type information of elements is in the btf_array struct that follows in
the type_ field while the index type is in the index_type field.

For BTF_KIND_INT, only the offset should be compared and size and
signedness should be ignored.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 01187735f0
Merge pull request #167 from aya-rs/codegen
Update libbpf to be89b28f96be426e30a2b0c5312d13b30ee518c7
3 years ago
dave-tucker 324c679a41 Update libbpf to be89b28f96be426e30a2b0c5312d13b30ee518c7 3 years ago
Alessandro Decina 4e9bc32a3d aya: maps: rename from_pinned() to open_pinned() 3 years ago
Alessandro Decina 9b1ab96ad5
Merge pull request #166 from dave-tucker/decl_tag
codegen: add btf_decl_tag
3 years ago
Dave Tucker 19af687480 codegen: add btf_decl_tag
This is required to add support for BTF_KIND_DECL_TAG

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina f12054a00d
Merge pull request #165 from dave-tucker/prog_pinned
aya: Retrieve program from pinned path
3 years ago
Dave Tucker abc8d27440 aya: Retrieve program from pinned path
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 353b5f9cb1
Merge pull request #163 from aya-rs/codegen
Update libbpf to 22411acc4b2c846868fd570b2d9f3b016d2af2cb
3 years ago
dave-tucker 0619f80090 Update libbpf to 22411acc4b2c846868fd570b2d9f3b016d2af2cb 3 years ago
Dave Tucker 13d3b5eea5
Merge pull request #162 from nimrodshn/add_bpf_lpm_trie_key_to_bindings
Add bpf_lpm_trie_key to bindings
3 years ago
Ubuntu 0beb0c501f Add bpf_lpm_trie_key to aya codegen to generate bindings 3 years ago
Alessandro Decina 001348a301
Merge pull request #158 from dave-tucker/btf-fix
aya: allocate func/line_info buffers outside if
3 years ago
Dave Tucker 83cfe56fe7 aya: allocate func/line_info buffers outside if
the pointer isn't valid in the current code!

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker bca01580e7 aya: document the public api
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina c5a10f8fbe
Merge pull request #127 from dave-tucker/ext
Support for BPF_PROG_TYPE_EXT
3 years ago
Dave Tucker 877c76043a btf: Add fixup for PTR types from Rust
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 5c6131afba Add BPF_PROG_TYPE_EXT
This requires loading the BTF to kernel when loading all programs as
well as implementing Extension program type

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 379bb313b1 obj: Add Btf::to_bytes
This allows for parsed BTF to be re-encoded such that it could be loaded
in to the kernel. It moves bytes_of to the utils package. We could use
Object::bytes_of, but this requires the impl of the Pod trait on
generated code.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina c3cd45c6df
Merge pull request #154 from dave-tucker/release-notes
ci: Add dependencies/codegen/docs to rel notes
3 years ago
Dave Tucker d2449ca292 ci: add docs to release notes
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker fbed584f78 ci: Add dependencies/codegen to rel notes
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 2ea6d68544
Merge pull request #152 from dave-tucker/release-notes
ci: Add autogenerated release notes
3 years ago
Dave Tucker dc16739b06 ci: Add autogenerated release notes
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 923cd9b767
Merge pull request #142 from vadorovsky/args-mut-ptr
aya-bpf: Add bpf_probe_write_user helper
3 years ago
Michal Rostecki 1df3b17d29 aya-bpf: Add bpf_probe_write_user helper
This helper allows to write to mutable pointers in the userspace, which
come from userspace functions that uprobes attach to.

Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
3 years ago
Alessandro Decina 5836b3f1b8
Merge pull request #149 from willfindlay/program_array
bpf/maps: implement ProgramArray
3 years ago
Alessandro Decina 149fa86de7
Merge pull request #150 from willfindlay/fix-tests
bpf/macros: fix tests
3 years ago
William Findlay b28ae97053
bpf/macros: fix tests
Doctests were broken due to depencencies on a generated vmlinux, incorrect function
signatures, and a missing unsafe keyword.
3 years ago
William Findlay df26fd94a7
bpf/program_array: use never type, add unsafe flag, and document safety 3 years ago
William Findlay ff14493751
bpf/maps: implement ProgramArray
This PR implements the ProgramArray map type in aya-bpf. Includes a convenient tail_call
method that wraps the bpf_tail_call helper.
3 years ago
Alessandro Decina faa36763f7
Merge pull request #146 from dave-tucker/ro-maps
Mark .rodata maps as readonly and freeze on load
3 years ago
Michal Rostecki 54377b6140 aya-bpf: Allow to convert probe arguments to mutable pointers
Before this change, arguments fetched with `arg` from `ProbeContext`
could be only fetched as const pointers. This change allows to get mut
pointers as well.

Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
3 years ago
Michal Rostecki 5d8afc58f4 aya-bpf-macros: Fix LSM macro documentation
It was causing `cargo doc` inside bpf/ to fail.

Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
3 years ago
Dave Tucker 65a0b83205 Mark .rodata maps as readonly and freeze on load
This commit marks .rodata maps as BPF_F_RDONLY_PROG when loaded to
prevent a BPF program mutating them.

Initial map data is populated by the loader using the new
`BpfLoader::set_global()` API. The loader will mark
is marked as frozen using bpf_map_freeze to prevent map data
being changed from userspace.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago