Skip to content

Fix double-free when linker processes empty sections

Eduard Zingerman bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review 1 of 2 applied

Patches in v1 1 of 2 applied

#Subject and filesSizeRepliesApplied
1/2selftests/bpf: Test if bpftool linker handles empty sectionstools/testing/selftests/bpf/progs/linked_funcs1.c tools/testing/selftests/bpf/progs/linked_funcs2.c+6 -01 reply
2/2libbpf: Fix double-free when linker processes empty sectionstools/lib/bpf/linker.c+13 -11 replyApplied

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by.

PatchJames Hilliard
1/2
2/2T-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-next 0/2] Fix double-free when linker processes empty sections

Fixes double-free error in linker.c:bpf_linker__free() caused by realloc(..., 0) call in linker.c:extend_sec() (such a call "frees" memory every second time :). The error is triggered when object files with empty sections of the same name are processed by linker.

- The first patch extends progs/linked_funcs[12].c to trigger the error upon tests compilation;
- The second patch contains detailed description of the error, fix and appropriate attributions.

Eduard Zingerman (2):
selftests/bpf: Test if bpftool linker handles empty sections
libbpf: Fix double-free when linker processes empty sections

 tools/lib/bpf/linker.c                            | 14 +++++++++++++-
 tools/testing/selftests/bpf/progs/linked_funcs1.c |  3 +++
 tools/testing/selftests/bpf/progs/linked_funcs2.c |  3 +++
 3 files changed, 19 insertions(+), 1 deletion(-)
Signature · 1 line
2.40.0