Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit 99fb9531 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov
Browse files

libbpf: fix BPF skeleton forward/backward compat handling


BPF skeleton was designed from day one to be extensible. Generated BPF
skeleton code specifies actual sizes of map/prog/variable skeletons for
that reason and libbpf is supposed to work with newer/older versions
correctly.

Unfortunately, it was missed that we implicitly embed hard-coded most
up-to-date (according to libbpf's version of libbpf.h header used to
compile BPF skeleton header) sizes of those structs, which can differ
from the actual sizes at runtime when libbpf is used as a shared
library.

We have a few places were we just index array of maps/progs/vars, which
implicitly uses these potentially invalid sizes of structs.

This patch aims to fix this problem going forward. Once this lands,
we'll backport these changes in Github repo to create patched releases
for older libbpfs.

Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
Reviewed-by: default avatarAlan Maguire <alan.maguire@oracle.com>
Fixes: d66562fb ("libbpf: Add BPF object skeleton support")
Fixes: 430025e5 ("libbpf: Add subskeleton scaffolding")
Fixes: 08ac454e

 ("libbpf: Auto-attach struct_ops BPF maps in BPF skeleton")
Co-developed-by: default avatarMykyta Yatsenko <yatsenko@meta.com>
Signed-off-by: default avatarMykyta Yatsenko <yatsenko@meta.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20240708204540.4188946-3-andrii@kernel.org


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 06e71ad5
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment