Skip to content

Fix libbpf BPF skeleton forward/backward compat

Andrii Nakryiko bpf 2 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 4 repliesApplied 3/3
  2. v12 patches 10 repliesSuperseded

Changes in v2 from the cover letter

- fix SOB, add acks, typo fixes (Quentin, Eduard);
- improve reporting of skipped map auto-attachment (Alan, Eduard).

Patches in v2 All 3 applied

#Subject and filesSizeRepliesApplied
1/3bpftool: improve skeleton backwards compat with old buggy libbpfstools/bpf/bpftool/gen.c+32 -143 repliesApplied
2/3libbpf: fix BPF skeleton forward/backward compat handlingtools/lib/bpf/libbpf.c+27 -200 repliesApplied
3/3libbpf: improve old BPF skeleton handling for map auto-attachtools/lib/bpf/libbpf.c+14 -121 replyApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchQuentin MonnetEduard ZingermanAlan Maguire
1/3A-b A-b
2/3A-b R-b
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 bpf-next 0/3] Fix libbpf BPF skeleton forward/backward compat

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).

v1->v2:
- fix SOB, add acks, typo fixes (Quentin, Eduard);
- improve reporting of skipped map auto-attachment (Alan, Eduard).

Andrii Nakryiko (3):
bpftool: improve skeleton backwards compat with old buggy libbpfs
libbpf: fix BPF skeleton forward/backward compat handling
libbpf: improve old BPF skeleton handling for map auto-attach

 tools/bpf/bpftool/gen.c | 46 ++++++++++++++++++--------
 tools/lib/bpf/libbpf.c  | 71 +++++++++++++++++++++++------------------
 2 files changed, 72 insertions(+), 45 deletions(-)
Signature · 1 line
2.43.0