Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\kexec_file.c Create Date:2022-07-28 11:04:26
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:kexec_calculate_store_digests

Proto:static int kexec_calculate_store_digests(struct kimage *image)

Type:int

Parameter:

TypeParameterName
struct kimage *image
710  ret = 0
715  pi = Information for loading purgatory
717  If Not IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_ARCH_HAS_KEXEC_PURGATORY) Then Return 0
720  zero_buf = __va(page_to_pfn(ZERO_PAGE(0)) << PAGE_SHIFT determines the page size )
721  zero_buf_sz = PAGE_SIZE
723  tfm = crypto_alloc_shash("sha256", 0, 0)
724  If IS_ERR(tfm) Then
725  ret = PTR_ERR(tfm)
726  Go to out
729  desc_size = rypto_shash_descsize() - obtain the operational state size*@tfm: cipher handle* The size of the operational state the cipher needs during operation is* returned for the hash referenced with the cipher handle + size of desc
730  desc = 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).
731  If Not desc Then
732  ret = -ENOMEM
733  Go to out_free_tfm
736  sha_region_sz = The artificial cap on the number of segments passed to kexec_load. * sizeof(structkexec_sha_region)
737  sha_regions = vzalloc(sha_region_sz)
738  If Not sha_regions Then Go to out_free_desc
741  tfm = tfm
743  ret = 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
744  If ret < 0 Then Go to out_free_sha_regions
747  digest = 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).
748  If Not digest Then
749  ret = -ENOMEM
750  Go to out_free_sha_regions
753  When i < nr_segments cycle
756  ksegment = segment[i]
761  If kbuf == * Temporary, modifiable buffer for stripped purgatory used for * relocation. This memory can be freed post image load. Then Continue
764  ret = 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
766  If ret Then Break
773  nullsz = memsz - bufsz
774  When nullsz cycle
775  bytes = nullsz
777  If bytes > zero_buf_sz Then bytes = zero_buf_sz
780  If ret Then Break
782  nullsz -= bytes
785  If ret Then Break
788  start = mem
789  len = memsz
790  j++
793  If Not ret Then
794  ret = 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
795  If ret Then Go to out_free_digest
797  ret = kexec_purgatory_get_set_symbol(image, "purgatory_sha_regions", sha_regions, sha_region_sz, 0)
799  If ret Then Go to out_free_digest
802  ret = kexec_purgatory_get_set_symbol(image, "purgatory_sha256_digest", digest, SHA256_DIGEST_SIZE, 0)
804  If ret Then Go to out_free_digest
808  out_free_digest :
809  kfree(digest)
810  out_free_sha_regions :
811  vfree(sha_regions)
812  out_free_desc :
813  kfree(desc)
814  out_free_tfm :
815  kfree(tfm)
816  out :
817  Return ret
Caller
NameDescribe
SYSCALL_DEFINE5