for (i = 0; i < ima_template->num_fields; i++) if (!strcmp(ima_template->fields[i]->field_id, "modsig") ||
!strcmp(ima_template->fields[i]->field_id, "d-modsig")) returntrue;
struct ima_template_desc *lookup_template_desc(constchar *name)
{ struct ima_template_desc *template_desc; int found = 0;
rcu_read_lock();
list_for_each_entry_rcu(template_desc, &defined_templates, list) { if ((strcmp(template_desc->name, name) == 0) ||
(strcmp(template_desc->fmt, name) == 0)) {
found = 1; break;
}
}
rcu_read_unlock(); return found ? template_desc : NULL;
}
staticconststruct ima_template_field *
lookup_template_field(constchar *field_id)
{ int i;
for (i = 0; i < ARRAY_SIZE(supported_fields); i++) if (strncmp(supported_fields[i].field_id, field_id,
IMA_TEMPLATE_FIELD_ID_MAX_LEN) == 0) return &supported_fields[i]; return NULL;
}
staticint template_fmt_size(constchar *template_fmt)
{ char c; int template_fmt_len = strlen(template_fmt); int i = 0, j = 0;
while (i < template_fmt_len) {
c = template_fmt[i]; if (c == '|')
j++;
i++;
}
return j + 1;
}
int template_desc_init_fields(constchar *template_fmt, conststruct ima_template_field ***fields, int *num_fields)
{ constchar *template_fmt_ptr; conststruct ima_template_field *found_fields[IMA_TEMPLATE_NUM_FIELDS_MAX]; int template_num_fields; int i, len;
if (template_num_fields > IMA_TEMPLATE_NUM_FIELDS_MAX) {
pr_err("format string '%s' contains too many fields\n",
template_fmt); return -EINVAL;
}
for (i = 0, template_fmt_ptr = template_fmt; i < template_num_fields;
i++, template_fmt_ptr += len + 1) { char tmp_field_id[IMA_TEMPLATE_FIELD_ID_MAX_LEN + 1];
len = strchrnul(template_fmt_ptr, '|') - template_fmt_ptr; if (len == 0 || len > IMA_TEMPLATE_FIELD_ID_MAX_LEN) {
pr_err("Invalid field with length %d\n", len); return -EINVAL;
}
if (fields && num_fields) {
*fields = kmalloc_array(i, sizeof(**fields), GFP_KERNEL); if (*fields == NULL) return -ENOMEM;
memcpy(*fields, found_fields, i * sizeof(**fields));
*num_fields = i;
}
return0;
}
void ima_init_template_list(void)
{ int i;
if (!list_empty(&defined_templates)) return;
spin_lock(&template_list); for (i = 0; i < ARRAY_SIZE(builtin_templates); i++) {
list_add_tail_rcu(&builtin_templates[i].list,
&defined_templates);
}
spin_unlock(&template_list);
}
if (hdr[HDR_TEMPLATE_NAME].len >= MAX_TEMPLATE_NAME_LEN) {
pr_err("attempting to restore a template name that is too long\n");
ret = -EINVAL; break;
}
/* template name is not null terminated */
memcpy(template_name, hdr[HDR_TEMPLATE_NAME].data,
hdr[HDR_TEMPLATE_NAME].len);
template_name[hdr[HDR_TEMPLATE_NAME].len] = 0;
if (strcmp(template_name, "ima") == 0) {
pr_err("attempting to restore an unsupported template \"%s\" failed\n",
template_name);
ret = -EINVAL; break;
}
template_desc = lookup_template_desc(template_name); if (!template_desc) {
template_desc = restore_template_fmt(template_name); if (!template_desc) break;
}
/* *Onlytherunningsystem'stemplateformatisinitialized *onboot.Asneeded,initializetheothertemplateformats.
*/
ret = template_desc_init_fields(template_desc->fmt,
&(template_desc->fields),
&(template_desc->num_fields)); if (ret < 0) {
pr_err("attempting to restore the template fmt \"%s\" failed\n",
template_desc->fmt);
ret = -EINVAL; break;
}
ret = ima_restore_template_data(template_desc,
hdr[HDR_TEMPLATE_DATA].data,
hdr[HDR_TEMPLATE_DATA].len,
&entry); if (ret < 0) break;
if (memcmp(hdr[HDR_DIGEST].data, zero, sizeof(zero))) {
ret = ima_calc_field_array_hash(
&entry->template_data[0],
entry); if (ret < 0) {
pr_err("cannot calculate template digest\n");
ret = -EINVAL; break;
}
}
entry->pcr = !ima_canonical_fmt ? *(u32 *)(hdr[HDR_PCR].data) :
le32_to_cpu(*(__le32 *)(hdr[HDR_PCR].data));
ret = ima_restore_measurement_entry(entry); if (ret < 0) break;
} return ret;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.