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_atfm

Proto:static int ima_calc_file_hash_atfm(struct file *file, struct ima_digest_data *hash, struct crypto_ahash *tfm)

Type:int

Parameter:

TypeParameterName
struct file *file
struct ima_digest_data *hash
struct crypto_ahash *tfm
209  char * rbuf[2] = {NULL, }
210  active = 0 , ahash_rc = 0
216  length = rypto_ahash_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: message digest size of cipher
218  req = ahash_request_alloc() - allocate request data structure*@tfm: cipher handle to be registered with the request*@gfp: memory allocation flag that is handed to kmalloc by the API call.* Allocate the request data structure that must be used with the ahash
219  If Not req Then Return -ENOMEM
222  crypto_init_wait( & wait)
223  ahash_request_set_callback() - set asynchronous callback function*@req: request handle*@flags: specify zero or an ORing of the flags* CRYPTO_TFM_REQ_MAY_BACKLOG the request queue may back log and* increase the wait queue beyond the initial maximum size;*
227  rc = ahash_wait(rypto_ahash_init() - (re)initialize message digest handle*@req: ahash_request handle that already is initialized with all necessary* data using the ahash_request_* API functions* The call (re-)initializes the message digest referenced by the ahash_request, & wait)
228  If rc Then Go to out1
231  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
233  If i_size == 0 Then Go to out2
240  rbuf[0] = ma_alloc_pages() - Allocate contiguous pages
241  If Not rbuf[0] Then
242  rc = -ENOMEM
243  Go to out1
247  If i_size > rbuf_size[0] Then
253  rbuf[1] = ma_alloc_pages() - Allocate contiguous pages
257  When offset < i_size cycle
258  If Not rbuf[1] && offset Then
263  rc = ahash_wait(ahash_rc, & wait)
264  If rc Then Go to out3
268  rbuf_len = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(loff_t, i_size - offset, rbuf_size[active])
269  rc = 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.
271  If rc != rbuf_len Then
272  If rc >= 0 Then rc = -EINVAL
279  Go to out3
282  If rbuf[1] && offset Then
287  rc = ahash_wait(ahash_rc, & wait)
288  If rc Then Go to out3
292  sg_init_one - Initialize a single entry sg list*@sg: SG entry*@buf: Virtual address for IO*@buflen: IO length
293  ahash_request_set_crypt() - set data buffers*@req: ahash_request handle to be updated*@src: source scatter/gather list*@result: buffer that is filled with the message digest -- the caller must* ensure that the buffer has sufficient space by, for example,
295  ahash_rc = rypto_ahash_update() - add data to message digest for processing*@req: ahash_request handle that was previously initialized with the* crypto_ahash_init call
297  If rbuf[1] Then active = Not active
301  rc = ahash_wait(ahash_rc, & wait)
302  out3 :
303  ma_free_pages() - Free pages allocated by ima_alloc_pages().*@ptr: Pointer to allocated pages.*@size: Size of allocated buffer.
304  ma_free_pages() - Free pages allocated by ima_alloc_pages().*@ptr: Pointer to allocated pages.*@size: Size of allocated buffer.
305  out2 :
306  If Not rc Then
307  ahash_request_set_crypt() - set data buffers*@req: ahash_request handle to be updated*@src: source scatter/gather list*@result: buffer that is filled with the message digest -- the caller must* ensure that the buffer has sufficient space by, for example,
308  rc = ahash_wait(rypto_ahash_final() - calculate message digest*@req: reference to the ahash_request handle that holds all information* needed to perform the cipher operation* Finalize the message digest operation and create the message digest, & wait)
310  out1 :
311  ahash_request_free() - zeroize and free the request data structure*@req: request data structure cipher handle to be freed
312  Return rc
Caller
NameDescribe
ima_calc_file_ahash