Skip to content

Commit

Permalink
libbpf-tools: Allow filelife to run on kernels without CONIFG_SECURITY
Browse files Browse the repository at this point in the history
security_inode_create does NOT exist if CONIFG_SECURITY is not set.
The tool filelife attaches to security_inode_create unconditionally
and result in attach error. Fix it by checking symbol existence.

Signed-off-by: Hengqi Chen <[email protected]>
  • Loading branch information
chenhengqi authored and yonghong-song committed Jul 3, 2022
1 parent df8d58a commit c3c99a9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libbpf-tools/filelife.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ int main(int argc, char **argv)
/* initialize global data (filtering options) */
obj->rodata->targ_tgid = env.pid;

if (!kprobe_exists("security_inode_create"))
bpf_program__set_autoload(obj->progs.security_inode_create, false);

err = filelife_bpf__load(obj);
if (err) {
fprintf(stderr, "failed to load BPF object: %d\n", err);
Expand Down

0 comments on commit c3c99a9

Please sign in to comment.