Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Restore the serialized binary measurement list without extending PCRs.

Proto:int ima_restore_measurement_list(loff_t size, void *buf)

Type:int

Parameter:

TypeParameterName
loff_tsize
void *buf
352  khdr = buf
353  struct ima_field_data hdr[HDR__LAST] = {[HDR_PCR] = {len = sizeof(u32)}, [HDR_DIGEST] = {len = Max TPM v1.2 PCR size }, }
358  bufp = buf + size of khdr
362  DECLARE_BITMAP(hdr_mask, HDR__LAST)
363  count = 0
364  ret = 0
366  If Not buf || size < size of khdr Then Return 0
369  If ima_canonical_fmt Then
370  version = le16_to_cpu(version)
371  count = le64_to_cpu(count)
372  buffer_size = le64_to_cpu(buffer_size)
375  If version != 1 Then
376  pr_err("attempting to restore a incompatible measurement list")
377  Return -EINVAL
380  If count > ULONG_MAX - 1 Then
381  pr_err("attempting to restore too many measurements")
382  Return -EINVAL
385  bitmap_zero(hdr_mask, HDR__LAST)
386  bitmap_set(hdr_mask, HDR_PCR, 1)
387  bitmap_set(hdr_mask, HDR_DIGEST, 1)
394  bufendp = buf + buffer_size
395  When bufp < bufendp && count++ < count cycle
396  enforce_mask = ENFORCE_FIELDS
398  enforce_mask |= If count == count Then ENFORCE_BUFEND Else 0
399  ret = ima_parse_buf(bufp, bufendp, & bufp, HDR__LAST, hdr, NULL, hdr_mask, enforce_mask, "entry header")
401  If ret < 0 Then Break
405  pr_err("attempting to restore a template name that is too long\n")
406  ret = -EINVAL
407  Break
411  memcpy(template_name, data, len)
413  template_name[len] = 0
415  If strcmp(template_name, "ima") == 0 Then
416  pr_err("attempting to restore an unsupported template \"%s\" failed\n", template_name)
418  ret = -EINVAL
419  Break
422  template_desc = lookup_template_desc(template_name)
423  If Not template_desc Then
425  If Not template_desc Then Break
433  ret = template_desc_init_fields(fmt, & (fields), & (num_fields))
436  If ret < 0 Then
437  pr_err("attempting to restore the template fmt \"%s\" failed\n", fmt)
439  ret = -EINVAL
440  Break
443  ret = ima_restore_template_data(template_desc, data, len, & entry)
447  If ret < 0 Then Break
450  memcpy( sha1 or md5 measurement hash , data, len)
452  pcr = If Not ima_canonical_fmt Then *data Else le32_to_cpu( * (data))
454  ret = ima_restore_measurement_entry(entry)
455  If ret < 0 Then Break
459  Return ret
Caller
NameDescribe
ima_load_kexec_bufferRestore the measurement list from the previous kernel.