[PATCH-v2 1/3] ima: added error messages to template-related functions

From: Roberto Sassu
Date: Fri Dec 06 2013 - 07:59:29 EST


This patch adds some error messages to inform users about the following
events: template descriptor not found, template field not found, and
template initialization failed.

Signed-off-by: Roberto Sassu <roberto.sassu@xxxxxxxxx>
Signed-off-by: Mimi Zohar <zohar@xxxxxxxxxxxxxxxxxx>
---
security/integrity/ima/ima_template.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index 635695f..a001477 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -49,8 +49,11 @@ static int __init ima_template_setup(char *str)
* If not, use CONFIG_IMA_DEFAULT_TEMPLATE.
*/
template_desc = lookup_template_desc(str);
- if (!template_desc)
+ if (!template_desc) {
+ pr_err("IMA: template %s not found, using %s\n",
+ str, CONFIG_IMA_DEFAULT_TEMPLATE);
return 1;
+ }

/*
* Verify whether the current hash algorithm is supported
@@ -134,6 +137,7 @@ static int template_desc_init_fields(const char *template_fmt,
struct ima_template_field *f = lookup_template_field(c);

if (!f) {
+ pr_err("IMA: field '%s' not found\n", c);
result = -ENOENT;
goto out;
}
@@ -161,8 +165,12 @@ static int init_defined_templates(void)
result = template_desc_init_fields(template->fmt,
&(template->fields),
&(template->num_fields));
- if (result < 0)
+ if (result < 0) {
+ pr_err("IMA: template %s init failed, result: %d\n",
+ (strlen(template->name) ?
+ template->name : template->fmt), result);
return result;
+ }
}
return result;
}
--
1.8.1.4

Attachment: smime.p7s
Description: S/MIME cryptographic signature