Ihor Solodrai
02bc656f90
libbpf: Verify section type in btf_find_elf_sections
...
A valid ELF file may contain a SHT_NOBITS .BTF section. This case is
not handled correctly in btf_parse_elf, which leads to a segfault.
Before attempting to load BTF section data, check that the section
type is SHT_PROGBITS, which is the expected type for BTF data. Fail
with an error if the type is different.
Bug report: https://github.com/libbpf/libbpf/issues/894
v1: https://lore.kernel.org/bpf/20250408184104.3962949-1-ihor.solodrai@linux.dev/
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20250410182823.1591681-1-ihor.solodrai@linux.dev
2025-04-29 11:33:37 -07:00
Ihor Solodrai
1b8768339f
ci: add temporary patches for selftests
...
* https://lore.kernel.org/all/20250327185528.1740787-1-song@kernel.org/
* https://lore.kernel.org/bpf/20250328193124.808784-1-song@kernel.org/
* https://lore.kernel.org/bpf/20250331033828.365077-1-yonghong.song@linux.dev/
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev >
2025-04-02 10:23:23 -07:00
Ihor Solodrai
374036c9f1
sync: latest libbpf changes from kernel
...
Syncing latest libbpf commits from kernel repository.
Baseline bpf-next commit: 239860828f8660e2be487e2fbdae2640cce3fd67
Checkpoint bpf-next commit: 79d93c8ff35855d3283ee7d82dfe0c54f90b9986
Baseline bpf commit: 319fc77f8f45a1b3dba15b0cc1a869778fd222f7
Checkpoint bpf commit: 6ccf6adb05d0fe3dbb1a77ab90bf054da8a2198d
Ihor Solodrai (1):
libbpf: Implement bpf_usdt_arg_size BPF function
Mykyta Yatsenko (3):
libbpf: Use map_is_created helper in map setters
libbpf: Introduce more granular state for bpf_object
libbpf: Split bpf object load into prepare/load
Nandakumar Edamana (1):
libbpf: Fix out-of-bound read
Peilin Ye (1):
bpf: Introduce load-acquire and store-release instructions
Yonghong Song (1):
bpf: Allow pre-ordering for bpf cgroup progs
include/uapi/linux/bpf.h | 4 +
src/libbpf.c | 201 ++++++++++++++++++++++++++-------------
src/libbpf.h | 13 +++
src/libbpf.map | 1 +
src/usdt.bpf.h | 32 +++++++
5 files changed, 183 insertions(+), 68 deletions(-)
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev >
2025-03-10 15:35:17 -07:00
Ihor Solodrai
be18fdb16a
libbpf: Implement bpf_usdt_arg_size BPF function
...
Information about USDT argument size is implicitly stored in
__bpf_usdt_arg_spec, but currently it's not accessbile to BPF programs
that use USDT.
Implement bpf_sdt_arg_size() that returns the size of an USDT argument
in bytes.
v1->v2:
* do not add __bpf_usdt_arg_spec() helper
v1: https://lore.kernel.org/bpf/20250220215904.3362709-1-ihor.solodrai@linux.dev/
Suggested-by: Andrii Nakryiko <andrii@kernel.org >
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Reviewed-by: Jiri Olsa <jolsa@kernel.org >
Link: https://lore.kernel.org/bpf/20250224235756.2612606-1-ihor.solodrai@linux.dev
2025-03-10 15:35:17 -07:00
Ihor Solodrai
42a6ef6316
sync: latest libbpf changes from kernel
...
Syncing latest libbpf commits from kernel repository.
Baseline bpf-next commit: 01f3ce5328c405179b2c69ea047c423dad2bfa6d
Checkpoint bpf-next commit: 239860828f8660e2be487e2fbdae2640cce3fd67
Baseline bpf commit: c45323b7560ec87c37c729b703c86ee65f136d75
Checkpoint bpf commit: 319fc77f8f45a1b3dba15b0cc1a869778fd222f7
Andrii Nakryiko (2):
libbpf: fix LDX/STX/ST CO-RE relocation size adjustment logic
libbpf: Fix hypothetical STT_SECTION extern NULL deref case
Daniel Borkmann (1):
netkit: Allow for configuring needed_{head,tail}room
Ihor Solodrai (3):
libbpf: Introduce kflag for type_tags and decl_tags in BTF
docs/bpf: Document the semantics of BTF tags with kind_flag
libbpf: Check the kflag of type tags in btf_dump
Tao Chen (1):
libbpf: Wrap libbpf API direct err with libbpf_err
Tony Ambardar (1):
libbpf: Fix accessing BTF.ext core_relo header
Yonghong Song (1):
bpf: Sync uapi bpf.h header for the tooling infra
include/uapi/linux/bpf.h | 5 +-
include/uapi/linux/btf.h | 3 +-
include/uapi/linux/if_link.h | 2 +
src/btf.c | 90 ++++++++++++++++++++++++++----------
src/btf.h | 3 ++
src/btf_dump.c | 5 +-
src/libbpf.c | 26 +++++------
src/libbpf.map | 2 +
src/linker.c | 2 +-
src/relo_core.c | 24 ++++++++--
10 files changed, 116 insertions(+), 46 deletions(-)
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev >
2025-02-24 15:10:59 -08:00
Ihor Solodrai
cc278ff7c0
libbpf: Check the kflag of type tags in btf_dump
...
If the kflag is set for a BTF type tag, then the tag represents an
arbitrary __attribute__. Change btf_dump accordingly.
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Reviewed-by: Alan Maguire <alan.maguire@oracle.com >
Acked-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20250130201239.1429648-4-ihor.solodrai@linux.dev
2025-02-24 15:10:59 -08:00
Ihor Solodrai
2b8b896bca
docs/bpf: Document the semantics of BTF tags with kind_flag
...
Explain the meaning of kind_flag in BTF type_tags and decl_tags.
Update uapi btf.h kind_flag comment to reflect the changes.
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20250130201239.1429648-3-ihor.solodrai@linux.dev
2025-02-24 15:10:59 -08:00
Ihor Solodrai
32bda80136
libbpf: Introduce kflag for type_tags and decl_tags in BTF
...
Add the following functions to libbpf API:
* btf__add_type_attr()
* btf__add_decl_attr()
These functions allow to add to BTF the type tags and decl tags with
info->kflag set to 1. The kflag indicates that the tag directly
encodes an __attribute__ and not a normal tag.
See Documentation/bpf/btf.rst changes in the subsequent patch for
details on the semantics.
Suggested-by: Andrii Nakryiko <andrii@kernel.org >
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Reviewed-by: Alan Maguire <alan.maguire@oracle.com >
Acked-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20250130201239.1429648-2-ihor.solodrai@linux.dev
2025-02-24 15:10:59 -08:00
Ihor Solodrai
d4a841a32b
ci: remove dependency on run-on-arch-action
...
run-on-arch-action is simply a wrapper around docker. There is no
value in using it in libbpf, as it is not complicated to run
non-native arch docker images directly on github-hosted runners.
Docker relies on qemu-user-static installed on the system to emulate
different architectures.
Recently there were various reports about multi-arch docker builds
failing with seemingly random issues, and it appears to boil down to
qemu [1]. I stumbled on this problem while updating s390x runners [2]
for BPF CI, and setting up more recent version of qemu helped.
This change addresses recent build failures on s390x and ppc64le.
[1] https://github.com/docker/setup-qemu-action/issues/188
[2] https://github.com/kernel-patches/runner/pull/69
[3] https://docs.docker.com/build/buildkit/#getting-started
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev >
2025-01-31 22:30:52 -08:00