IMA/EVM完整性检测
IMA(Integrity Measurement Architecture)是一个内核安全子系统,用于检测文件或数据的完整性和安全性。IMA的hook机制指的是内核接口钩子(kernel interface hooks),用于向IMA注册和实现一系列回调函数,以便在文件系统操作过程中拦截和记录检测信息。
1.0 IMA的hook机制
IMA的hook机制包括以下几个主要步骤:
1.1 定义回调函数
在IMA hook机制中,需要定义一系列回调函数,包括measure、appraise、policy、inode_free和post_parse等函数。measure函数用于在文件读取之前计算文件的哈希值;appraise函数用于评估文件完整性;policy函数用于读取并更新IMA策略;inode_free函数用于在删除文件时更新操作系统的IMA状态信息;post_parse函数用于在解析之后更新文件系统缓存和错误日志。
int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
enum kernel_read_file_id id)
{
int ret;
ret = call_int_hook(kernel_post_read_file, 0, file, buf, size, id);
if (ret)
return ret;
return ima_post_read_file(file, buf, size, id);
}
EXPORT_SYMBOL_GPL(security_kernel_post_read_file);
其中ima_post_read_file为ima的重要文件测量函数,可以看到,imahook独立与call_int_hook, 也就是lsm的审计框架体系。
其中还包括
ima_bprm_check
ima_inode_setxattr
ima_inode_removexattr
ima_file_mmap
ima_read_file
ima_post_read_file
ima_load_data
1.2 ima_bprm_check
ima_bprm_check指的是Linux内核中一个函数,全名是“int ima_bprm_check(struct linux_binprm *bprm)”。该函数用于在执行新的可执行文件之前检查其完整性和安全性。
当一个新的可执行文件被加载到内存中时,内核会调用ima_bprm_check函数。该函数通过访问内存中的内容和计算哈希值等方式对可执行文件的完整性进行检查。在哈希值被计算之后,该函数还会对哈希值进行数字签名验证。
IMA(Integrity Measurement Architecture)一旦启用后,在执行新的可执行文件


1万+

被折叠的 条评论
为什么被折叠?



