WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / ima.c
blob86b21aff4bc5d6efcb62dee1e22d641cf87b2fdc
1 // SPDX-License-Identifier: GPL-2.0
3 /*
4 * Copyright 2020 Google LLC.
5 */
7 #include "vmlinux.h"
8 #include <errno.h>
9 #include <bpf/bpf_helpers.h>
10 #include <bpf/bpf_tracing.h>
12 long ima_hash_ret = -1;
13 u64 ima_hash = 0;
14 u32 monitored_pid = 0;
16 char _license[] SEC("license") = "GPL";
18 SEC("lsm.s/bprm_committed_creds")
19 int BPF_PROG(ima, struct linux_binprm *bprm)
21 u32 pid = bpf_get_current_pid_tgid() >> 32;
23 if (pid == monitored_pid)
24 ima_hash_ret = bpf_ima_inode_hash(bprm->file->f_inode,
25 &ima_hash, sizeof(ima_hash));
27 return 0;