mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
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.
This commit is contained in:
parent
79a67f3ca4
commit
f409aa5c63
@ -45,10 +45,11 @@ static bool bpf_can_link_lsm_program(struct bpf_program *prog) {
|
||||
assert(prog);
|
||||
|
||||
link = sym_bpf_program__attach_lsm(prog);
|
||||
if (!link)
|
||||
return -ENOMEM;
|
||||
|
||||
return 1;
|
||||
/* If bpf_program__attach_lsm fails the resulting value stores libbpf error code instead of memory
|
||||
* pointer. That is the case when the helper is called on architectures where BPF trampoline (hence
|
||||
* BPF_LSM_MAC attach type) is not supported. */
|
||||
return sym_libbpf_get_error(link) == 0;
|
||||
}
|
||||
|
||||
static int prepare_restrict_fs_bpf(struct restrict_fs_bpf **ret_obj) {
|
||||
|
Loading…
Reference in New Issue
Block a user