BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] Fix double-free when linker processes empty sections
@ 2023-03-28  0:47 Eduard Zingerman
  2023-03-28  0:47 ` [PATCH bpf-next 1/2] selftests/bpf: Test if bpftool linker handles " Eduard Zingerman
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Eduard Zingerman @ 2023-03-28  0:47 UTC (permalink / raw)
  To: bpf, ast
  Cc: andrii, daniel, martin.lau, kernel-team, yhs, james.hilliard1,
	Eduard Zingerman

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

-- 
2.40.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-28  3:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-28  0:47 [PATCH bpf-next 0/2] Fix double-free when linker processes empty sections Eduard Zingerman
2023-03-28  0:47 ` [PATCH bpf-next 1/2] selftests/bpf: Test if bpftool linker handles " Eduard Zingerman
2023-03-28  3:04   ` Andrii Nakryiko
2023-03-28  0:47 ` [PATCH bpf-next 2/2] libbpf: Fix double-free when linker processes " Eduard Zingerman
2023-03-28  2:18   ` James Hilliard
2023-03-28  3:10 ` [PATCH bpf-next 0/2] " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox