f952a6f69f
When trying to use BTF encoding for an apparently problematic kernel file, pahole segfaults. As can be seen below [1], the problem is that we are trying to dereference a NULL decoder. Fix this by checking the return value of dwfl_getmodules which [2] will return -1 on errors or an offset if one of the modules did not return DWARF_CB_OK. (In this specific case, it was __cus__load_debug_types that returned DWARF_CB_ABORT.) [1]: $ gdb -q --args ./pahole -J vmlinux-5.3.18-24.102-default.debug Reading symbols from ./pahole... (gdb) r Starting program: /tmp/pahole/build/pahole -J vmlinux-5.3.18-24.102-default.debug [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7f4000e in gobuffer__size (gb=0x18) at /tmp/pahole/gobuffer.h:39 39 return gb->index; (gdb) bt (gdb) frame 1 1042 if (gobuffer__size(&encoder->percpu_secinfo) != 0) (gdb) list 1037 1038 int btf_encoder__encode(struct btf_encoder *encoder) 1039 { 1040 int err; 1041 1042 if (gobuffer__size(&encoder->percpu_secinfo) != 0) 1043 btf_encoder__add_datasec(encoder, PERCPU_SECTION); 1044 1045 /* Empty file, nothing to do, so... done! */ 1046 if (btf__get_nr_types(encoder->btf) == 0) (gdb) print encoder $1 = (struct btf_encoder *) 0x0 [2] https://sourceware.org/git/?p=elfutils.git;a=blob;f=libdwfl/libdwfl.h;h=f98f1d525d94bc7bcfc7c816890de5907ee4bd6d;hb=HEAD#l200 Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com> Acked-by: John Fastabend <john.fastabend@gmail.com> Cc: bpf@vger.kernel.org Cc: dwarves@vger.kernel.org Link: http://lore.kernel.org/lkml/20220316132338.3226871-1-kkourt@kkourt.io Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> |
||
---|---|---|
cmake/modules | ||
lib | ||
man-pages | ||
ostra | ||
rpm/SPECS | ||
.gitignore | ||
.gitmodules | ||
btf_encoder.c | ||
btf_encoder.h | ||
btf_loader.c | ||
btfdiff | ||
buildcmd.sh | ||
changes-v1.13 | ||
changes-v1.16 | ||
changes-v1.17 | ||
changes-v1.18 | ||
changes-v1.19 | ||
changes-v1.20 | ||
changes-v1.21 | ||
changes-v1.22 | ||
changes-v1.23 | ||
CMakeLists.txt | ||
codiff.c | ||
config.h.cmake | ||
COPYING | ||
ctf_encoder.c | ||
ctf_encoder.h | ||
ctf_loader.c | ||
ctf.h | ||
ctfdwdiff | ||
ctracer.c | ||
dtagnames.c | ||
dutil.c | ||
dutil.h | ||
dwarf_loader.c | ||
dwarves_emit.c | ||
dwarves_emit.h | ||
dwarves_fprintf.c | ||
dwarves_reorganize.c | ||
dwarves_reorganize.h | ||
dwarves.c | ||
dwarves.h | ||
elf_symtab.c | ||
elf_symtab.h | ||
elfcreator.c | ||
elfcreator.h | ||
fullcircle | ||
gobuffer.c | ||
gobuffer.h | ||
hash.h | ||
libctf.c | ||
libctf.h | ||
list.h | ||
MANIFEST | ||
NEWS | ||
pahole.c | ||
pdwtags.c | ||
pfunct.c | ||
pglobal.c | ||
prefcnt.c | ||
rbtree.c | ||
rbtree.h | ||
README | ||
README.btf | ||
README.cross | ||
README.ctracer | ||
README.DEBUG | ||
README.tarball | ||
regtest | ||
scncopy.c | ||
syscse.c |
Build instructions: 1. install cmake 2. mkdir build 3. cd build 4. cmake -D__LIB=lib .. 5. make install cmake Options: -DBUILD_SHARED_LIBS By default SHARED libraries are created and applications are linked to it. Use -DBUILD_SHARED_LIBS=OFF while invoking cmake to create STATIC libraries and link applications to it. Ex. cmake -D__LIB=lib -DBUILD_SHARED_LIBS=OFF .. -DCMAKE_INSTALL_PREFIX Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX= when invoking cmake to specify another install location. Known to work scenarios: Mandriva Cooker: cmake 2.4.5-1mdv2007.1 libelfutils1-devel 0.123-1mdv2007.1 Debian Unstable: cmake 2.4.5-1 libdw-dev 0.123-2 Fedora Core 6: cmake 2.4.5-2.fc6 elfutils-devel 0.126-1.fc6