[PATCH bpf-next v4 0/2] libbpf: Fix bpftool gen object segfault

From: Rong Tao
Date: Thu Dec 05 2024 - 20:58:43 EST


From: Rong Tao <rongtao@xxxxxxxx>

When the target file is used as input and output at the same time, the
input file will read a null value, resulting in a segmentation fault.

Add judgment conditions in bpftool and libbpf to prevent segmentation
error.

ChangeLog v2 -> v3:
- argc_cpy and argv_cpy need to be initialised _after_ the call to
GET_ARG()

ChangeLog v1 -> v2:
- Compare each output file.

v4: This patchset, double check and fix in libbpf.
v3: https://lore.kernel.org/lkml/tencent_A7A870BF168D6A21BA193408D5645D5D920A@xxxxxx/
v2: https://lore.kernel.org/lkml/tencent_F62A51AFF6A38188D70664421F5934974008@xxxxxx/
v1: https://lore.kernel.org/lkml/tencent_410B8166C55CD2AB64BDEA8E92204619180A@xxxxxx/

Rong Tao (2):
bpftool: Fix gen object segfault
libbpf: linker: Avoid using object file as both input and output

tools/bpf/bpftool/gen.c | 13 +++++++++++++
tools/lib/bpf/linker.c | 5 +++++
2 files changed, 18 insertions(+)

--
2.47.1