Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

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

Proto:int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash)

Type:int

Parameter:

TypeParameterName
struct file *file
struct ima_digest_data *hash
413  f = file
414  bool new_file_instance = TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0., modified_flags = false
420  If f_flags & O_DIRECT Then
421  length = hash_digest_size[ima_hash_algo]
422  algo = ima_hash_algo
423  Return -EINVAL
427  If Not (f_mode & le is open for reading ) Then
428  flags = f_flags & ~( O_WRONLY | O_APPEND | O_TRUNC | O_CREAT | O_NOCTTY | O_EXCL)
430  flags |= O_RDONLY
431  f = dentry_open( & f_path, flags, f_cred)
432  If IS_ERR(f) Then
437  pr_info_ratelimited("Unable to reopen file for reading.\n")
438  f = file
440  modified_flags = true
441  Else
442  new_file_instance = true
446  i_size = NOTE: in a 32bit arch with a preemptable kernel and* an UP compile the i_size_read/write must be atomic* with respect to the local cpu (unlike with preempt disabled),* but they don't need to be atomic with respect to other cpus like in* true SMP (so they
448  If minimum file size for ahash use && i_size >= minimum file size for ahash use Then
449  rc = ima_calc_file_ahash(f, hash)
450  If Not rc Then Go to out
454  rc = ima_calc_file_shash(f, hash)
455  out :
456  If new_file_instance Then fput(f)
458  Else if modified_flags Then f_flags &= ~le is open for reading
460  Return rc
Caller
NameDescribe
ima_collect_measurementma_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
ima_eventdigest_initThis function writes the digest of an event (with size limit).