Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\integrity\ima\ima_api.c Create Date:2022-07-28 19:58:43
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name: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

Proto:int ima_collect_measurement(struct integrity_iint_cache *iint, struct file *file, void *buf, loff_t size, enum hash_algo algo, struct modsig *modsig)

Type:int

Parameter:

TypeParameterName
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  If modsig Then ima_collect_modsig(modsig, buf, size)
230  If flags & #define IMA_COLLECT 0x00000010 do not use this flag Then Go to 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, size of digest )
244  If buf Then result = ima_calc_buffer_hash(buf, size, & hdr)
246  Else 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  If result && result != -EBADF && result != -EINVAL Then Go to out
252  length = size of 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  If Not tmpbuf Then
255  result = -ENOMEM
256  Go to out
259  ima_hash = tmpbuf
260  memcpy(ima_hash, & hash, length)
261  rack inode changes = i_version
264  If Not result Then flags |= #define IMA_COLLECT 0x00000010 do not use this flag
266  out :
267  If result Then
268  If f_flags & O_DIRECT Then audit_cause = "failed(directio)"
271  integrity_audit_msg(Data integrity verification , inode, filename, "collect_data", audit_cause, result, 0)
275  Return result
Caller
NameDescribe
ima_update_xattrma_update_xattr - update 'security.ima' hash value
process_measurement