Provide a wrapper function to get the IMA hash of an inode. This helper is useful in fingerprinting files (e.g executables on execution) and using these fingerprints in detections like an executable unlinking itself. Since the ima_inode_hash can sleep, it's only allowed for sleepable LSM hooks.
Showing the changes to include/uapi/linux (1 of 4 files). Show all
Unified · Split
| @@ -3807,6 +3807,16 @@ union bpf_attr { · 3806 unmodified lines | |||
| 3807 | * See: **clock_gettime**\ (**CLOCK_MONOTONIC_COARSE**) | 3807 | * See: **clock_gettime**\ (**CLOCK_MONOTONIC_COARSE**) |
| 3808 | * Return | 3808 | * Return |
| 3809 | * Current *ktime*. | 3809 | * Current *ktime*. |
| 3810 | * | ||
| 3811 | * long bpf_ima_inode_hash(struct inode *inode, void *dst, u32 size) | ||
| 3812 | * Description | ||
| 3813 | * Returns the stored IMA hash of the *inode* (if it's avaialable). | ||
| 3814 | * If the hash is larger than *size*, then only *size* | ||
| 3815 | * bytes will be copied to *dst* | ||
| 3816 | * Return | ||
| 3817 | * The **hash_algo** is returned on success, | ||
| 3818 | * **-EOPNOTSUP** if IMA is disabled or **-EINVAL** if | ||
| 3819 | * invalid arguments are passed. | ||
| 3810 | */ | 3820 | */ |
| 3811 | #define __BPF_FUNC_MAPPER(FN) \ | 3821 | #define __BPF_FUNC_MAPPER(FN) \ |
| 3812 | FN(unspec), \ | 3822 | FN(unspec), \ |
| @@ -3970,6 +3980,7 @@ union bpf_attr { · 157 unmodified lines | |||
| 3970 | FN(get_current_task_btf), \ | 3980 | FN(get_current_task_btf), \ |
| 3971 | FN(bprm_opts_set), \ | 3981 | FN(bprm_opts_set), \ |
| 3972 | FN(ktime_get_coarse_ns), \ | 3982 | FN(ktime_get_coarse_ns), \ |
| 3983 | FN(ima_inode_hash), \ | ||
| 3973 | /* */ | 3984 | /* */ |
| 3974 | 3985 | ||
| 3975 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper | 3986 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |