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)一旦启用后,在执行新的可执行文件

IMA(IntegrityMeasurementArchitecture)是Linux内核的安全子系统,用于文件和数据的完整性检测。文章详细介绍了IMA的hook机制,包括定义回调函数如ima_bprm_check、ima_inode_setxattr等,以及ima_bprm_check在执行新可执行文件时的检查功能。此外,还提到了ima_appraise_measurement用于评价文件度量值,并与EVM(ExtendedVerificationModule)结合进行完整性校验。文章还讨论了IMA的管理系统,如ascii_runtime_measurements的seq文件操作,以及PCA(PlatformConfigurationRegisters)在IMA中的作用,用于存储测量值并验证系统完整性。
最低0.47元/天 解锁文章
802





