Fix recently identified (but long standing) bug with handling BPF skeleton forward and backward compatibility. On libbpf side, even though BPF skeleton was always designed to be forward and backwards compatible through recording actual size of constrituents of BPF skeleton itself (map/prog/var skeleton definitions), libbpf implementation did implicitly hard-code those sizes by virtue of using a trivial array access syntax. This issue will only affect libbpf used as a shared library. Statically compiled libbpfs will always be in sync with BPF skeleton, bypassing this problem altogether. This patch set fixes libbpf, but also mitigates the problem for old libbpf versions by teaching bpftool to generate more conservative BPF skeleton, if possible (i.e., if there are no struct_ops maps defined). Andrii Nakryiko (2): bpftool: improve skeleton backwards compat with old buggy libbpfs libbpf: fix BPF skeleton forward/backward compat handling tools/bpf/bpftool/gen.c | 46 ++++++++++++++++++++++++++++------------ tools/lib/bpf/libbpf.c | 47 +++++++++++++++++++++++------------------ 2 files changed, 59 insertions(+), 34 deletions(-) -- 2.43.0