Skip to content

fix BTF usage on embedded systems

Tony Ambardar bpf linux-arch netdev 1 version Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 6 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/3bpf: fix sysfs export of empty BTF sectionkernel/bpf/sysfs_btf.c+3 -32 replies
2/3bpf: prevent .BTF section eliminationinclude/asm-generic/vmlinux.lds.h+1 -11 reply
3/3libbpf: fix native endian assumption when parsing BTFtools/lib/bpf/btf.c+6 -01 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJohn FastabendAndrii Nakryiko
SeriesA-b
1/3A-b A-b
2/3A-b
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH bpf v1 0/3] fix BTF usage on embedded systems

Hello,

I've been experimenting with BPF and BTF on small, emebedded platforms requiring cross-compilation to varying archs, word-sizes, and endianness. These environments are not the most common for the majority of eBPF users, and have exposed multiple problems with basic functionality. This patch series addresses some of these issues.

Enabling BTF support in the kernel can sometimes result in sysfs export of /sys/kernel/btf/vmlinux as a zero-length file, which is still readable and seen to leak non-zero kernel data. Patch #1 adds a sanity-check to avoid this situation.

Small systems commonly enable LD_DEAD_CODE_DATA_ELIMINATION, which causes the .BTF section data to be incorrectly removed and can trigger the problem above. Patch #2 preserves the BTF data.

Even if BTF data is generated and embedded in the kernel, it may be encoded as non-native endianness due to another bug [1] currently being worked on. Patch #3 lets bpftool recognize the wrong BTF endianness rather than output a confusing/misleading ELF header error message.

Patches #1 and #2 were first developed for Linux 5.4.x and should be backported if possible. Feedback and suggestions for improvement are welcome!

Thanks,
Tony

[1] https://lore.kernel.org/bpf/CAPGftE8ipAacAnm9xMHFabXCL-XrCXGmOsX-Nsjvz9wnh3Zx-w@mail.gmail.com/

Tony Ambardar (3):
bpf: fix sysfs export of empty BTF section
bpf: prevent .BTF section elimination
libbpf: fix native endian assumption when parsing BTF

 include/asm-generic/vmlinux.lds.h | 2 +-
 kernel/bpf/sysfs_btf.c            | 6 +++---
 tools/lib/bpf/btf.c               | 6 ++++++
 3 files changed, 10 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1