Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Move sample generation code to ima_test_common()

Move sample generator code to ima_test_common() so that the new function
can be called by multiple LSM hooks.

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220302111404.193900-5-roberto.sassu@huawei.com

authored by

Roberto Sassu and committed by
Alexei Starovoitov
2746de3c 174b1694

+8 -3
+8 -3
tools/testing/selftests/bpf/progs/ima.c
··· 18 18 19 19 char _license[] SEC("license") = "GPL"; 20 20 21 - SEC("lsm.s/bprm_committed_creds") 22 - void BPF_PROG(ima, struct linux_binprm *bprm) 21 + static void ima_test_common(struct file *file) 23 22 { 24 23 u64 ima_hash = 0; 25 24 u64 *sample; ··· 27 28 28 29 pid = bpf_get_current_pid_tgid() >> 32; 29 30 if (pid == monitored_pid) { 30 - ret = bpf_ima_inode_hash(bprm->file->f_inode, &ima_hash, 31 + ret = bpf_ima_inode_hash(file->f_inode, &ima_hash, 31 32 sizeof(ima_hash)); 32 33 if (ret < 0 || ima_hash == 0) 33 34 return; ··· 41 42 } 42 43 43 44 return; 45 + } 46 + 47 + SEC("lsm.s/bprm_committed_creds") 48 + void BPF_PROG(bprm_committed_creds, struct linux_binprm *bprm) 49 + { 50 + ima_test_common(bprm->file); 44 51 }