bpf: check if lsm link ptr is libbpf error
authorJulia Kartseva <hex@fb.com>
Fri, 7 Jan 2022 23:02:57 +0000 (15:02 -0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 10 Jan 2022 20:47:21 +0000 (21:47 +0100)
commitf9370f91881a5bc5bf9c8b0ed8d56deb87437079
treec1b5b1b009c45af58fc7fb11971618843a1a925d
parent911516e1614e435755814ada5fc6064fa107a105
bpf: check if lsm link ptr is libbpf error

BPF_RAW_TRACEPOINT_OPEN is expected to work only on x86 and x86_64,
since BPF trampoline is implemented only on these architectures.

Attach probing by bpf_program__attach_lsm already happens in
`bpf_lsm_supported`. The resulting pointer can store libbpf error and
that is the case for unsupported architectures.
Add libbpf error check to `bpf_lsm_supported` so execution does not
reach the point where unit startup fails.

(cherry picked from commit f409aa5c6363144c9711226319614f3b248d9828)
src/core/bpf-lsm.c