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:31
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:ima_calc_file_hash_tfm

Proto:static int ima_calc_file_hash_tfm(struct file *file, struct ima_digest_data *hash, struct crypto_shash *tfm)

Type:int

Parameter:

TypeParameterName
struct file *file
struct ima_digest_data *hash
struct crypto_shash *tfm
335  offset = 0
338  SHASH_DESC_ON_STACK(shash, tfm)
340  tfm = tfm
342  length = rypto_shash_digestsize() - obtain message digest size*@tfm: cipher handle* The size for the message digest created by the message digest cipher* referenced with the cipher handle is returned.* Return: digest size of cipher
344  rc = rypto_shash_init() - (re)initialize message digest*@desc: operational state handle that is already filled* The call (re-)initializes the message digest referenced by the* operational state handle. Any potentially existing state created by
345  If rc != 0 Then Return rc
348  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
350  If i_size == 0 Then Go to out
353  rbuf = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
354  If Not rbuf Then Return -ENOMEM
357  When offset < i_size cycle
360  rbuf_len = grity_kernel_read - read data from the file* This is a function for reading file content instead of kernel_read().* It does not perform locking checks to ensure it cannot be blocked.* It does not perform security checks because it is irrelevant for IMA.
361  If rbuf_len < 0 Then
362  rc = rbuf_len
363  Break
365  If rbuf_len == 0 Then Break
367  offset += rbuf_len
369  rc = rypto_shash_update() - add data to message digest for processing*@desc: operational state handle that is already initialized*@data: input data to be added to the message digest*@len: length of the input data
370  If rc Then Break
373  kfree(rbuf)
374  out :
375  If Not rc Then rc = rypto_shash_final() - calculate message digest*@desc: operational state handle that is already filled with data*@out: output buffer filled with the message digest* Finalize the message digest operation and create the message digest
377  Return rc
Caller
NameDescribe
ima_calc_file_shash