• Michal Rostecki's avatar
    libbpf: Return btf_fd for load_sk_storage_btf · cfd49210
    Michal Rostecki authored
    Before this change, function load_sk_storage_btf expected that
    libbpf__probe_raw_btf was returning a BTF descriptor, but in fact it was
    returning an information about whether the probe was successful (0 or
    1). load_sk_storage_btf was using that value as an argument of the close
    function, which was resulting in closing stdout and thus terminating the
    process which called that function.
    
    That bug was visible in bpftool. `bpftool feature` subcommand was always
    exiting too early (because of closed stdout) and it didn't display all
    requested probes. `bpftool -j feature` or `bpftool -p feature` were not
    returning a valid json object.
    
    This change renames the libbpf__probe_raw_btf function to
    libbpf__load_raw_btf, which now returns a BTF descriptor, as expected in
    load_sk_storage_btf.
    
    v2:
    - Fix typo in the commit message.
    
    v3:
    - Simplify BTF descriptor handling in bpf_object__probe_btf_* functions.
    - Rename libbpf__probe_raw_btf function to libbpf__load_raw_btf and
    return a BTF descriptor.
    
    v4:
    - Fix typo in the commit message.
    
    Fixes: d7c4b398 ("libbpf: detect supported kernel BTF features and sanitize BTF")
    Signed-off-by: default avatarMichal Rostecki <mrostecki@opensuse.org>
    Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
    Acked-by: default avatarSong Liu <songliubraving@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    cfd49210
libbpf_probes.c 7.64 KB