1 // SPDX-License-Identifier: GPL-2.0 2 3 /* 4 * Copyright 2020 Google LLC. 5 */ 6 7 #include "vmlinux.h" 8 #include <errno.h> 9 #include <bpf/bpf_helpers.h> 10 #include <bpf/bpf_tracing.h> 11 12 long ima_hash_ret = -1; 13 u64 ima_hash = 0; 14 u32 monitored_pid = 0; 15 16 char _license[] SEC("license") = "GPL"; 17 18 SEC("lsm.s/bprm_committed_creds") 19 int BPF_PROG(ima, struct linux_binprm *bprm) 20 { 21 u32 pid = bpf_get_current_pid_tgid() >> 32; 22 23 if (pid == monitored_pid) 24 ima_hash_ret = bpf_ima_inode_hash(bprm->file->f_inode, 25 &ima_hash, sizeof(ima_hash)); 26 27 return 0; 28 } 29