函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\integrity\ima\ima_api.c Create Date:2022-07-27 22:01:58
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:ma_collect_measurement - collect file measurement* Calculate the file hash, if it doesn't already exist,* storing the measurement and i_version in the iint.* Must be called with iint->mutex held.* Return 0 on success, error code otherwise

函数原型:int ima_collect_measurement(struct integrity_iint_cache *iint, struct file *file, void *buf, loff_t size, enum hash_algo algo, struct modsig *modsig)

返回类型:int

参数:

类型参数名称
struct integrity_iint_cache *iint
struct file *file
void *buf
loff_tsize
enum hash_algoalgo
struct modsig *modsig
210  audit_cause等于"failed"
211  inode等于file_inode(file)
212  filename等于name
213  result等于0
217  struct{struct ima_digest_data hdr;char digest[64];}hash
227  如果modsigima_collect_modsig(modsig, buf, size)
230  如果flags按位与#define IMA_COLLECT 0x00000010 do not use this flag 则转到:out
238  i_version等于de_query_iversion - read i_version for later use*@inode: inode from which i_version should be read* Read the inode i_version counter
239  algo等于algo
242  memset( & digest, 0, digest的长度)
244  如果bufresult等于ima_calc_buffer_hash(buf, size, & hdr)
246  否则result等于ma_calc_file_hash - calculate file hash* Asynchronous hash (ahash) allows using HW acceleration for calculating* a hash. ahash performance varies for different data sizes on different* crypto accelerators
249  如果resultresult不等于负EBADFresult不等于负EINVAL则转到:out
252  length等于hdr的长度加length
253  tmpbuf等于krealloc - reallocate memory. The contents will remain unchanged.*@p: object to reallocate memory for.*@new_size: how many bytes of memory are required.*@flags: the type of memory to allocate.* The contents of the object pointed to are preserved up to the
254  如果非tmpbuf
255  result等于负ENOMEM
256  转到:out
259  ima_hash等于tmpbuf
260  memcpy(ima_hash, & hash, length)
261  rack inode changes 等于i_version
264  如果非resultflags或等于#define IMA_COLLECT 0x00000010 do not use this flag
266  out :
267  如果result
268  如果f_flags按位与O_DIRECTaudit_cause等于"failed(directio)"
271  integrity_audit_msg(Data integrity verification , inode, filename, "collect_data", audit_cause, result, 0)
275  返回:result
调用者
名称描述
ima_update_xattrma_update_xattr - update 'security.ima' hash value
process_measurement