aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--security/integrity/ima/ima_template.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index e854862c9337..1310afc587f3 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -52,8 +52,11 @@ static int __init ima_template_setup(char *str)
52 * If not, use CONFIG_IMA_DEFAULT_TEMPLATE. 52 * If not, use CONFIG_IMA_DEFAULT_TEMPLATE.
53 */ 53 */
54 template_desc = lookup_template_desc(str); 54 template_desc = lookup_template_desc(str);
55 if (!template_desc) 55 if (!template_desc) {
56 pr_err("template %s not found, using %s\n",
57 str, CONFIG_IMA_DEFAULT_TEMPLATE);
56 return 1; 58 return 1;
59 }
57 60
58 /* 61 /*
59 * Verify whether the current hash algorithm is supported 62 * Verify whether the current hash algorithm is supported
@@ -117,8 +120,11 @@ static int template_desc_init_fields(const char *template_fmt,
117 int template_num_fields = template_fmt_size(template_fmt); 120 int template_num_fields = template_fmt_size(template_fmt);
118 int i, result = 0; 121 int i, result = 0;
119 122
120 if (template_num_fields > IMA_TEMPLATE_NUM_FIELDS_MAX) 123 if (template_num_fields > IMA_TEMPLATE_NUM_FIELDS_MAX) {
124 pr_err("format string '%s' contains too many fields\n",
125 template_fmt);
121 return -EINVAL; 126 return -EINVAL;
127 }
122 128
123 /* copying is needed as strsep() modifies the original buffer */ 129 /* copying is needed as strsep() modifies the original buffer */
124 template_fmt_copy = kstrdup(template_fmt, GFP_KERNEL); 130 template_fmt_copy = kstrdup(template_fmt, GFP_KERNEL);
@@ -137,6 +143,7 @@ static int template_desc_init_fields(const char *template_fmt,
137 struct ima_template_field *f = lookup_template_field(c); 143 struct ima_template_field *f = lookup_template_field(c);
138 144
139 if (!f) { 145 if (!f) {
146 pr_err("field '%s' not found\n", c);
140 result = -ENOENT; 147 result = -ENOENT;
141 goto out; 148 goto out;
142 } 149 }
@@ -163,8 +170,13 @@ struct ima_template_desc *ima_template_desc_current(void)
163int __init ima_init_template(void) 170int __init ima_init_template(void)
164{ 171{
165 struct ima_template_desc *template = ima_template_desc_current(); 172 struct ima_template_desc *template = ima_template_desc_current();
173 int result;
166 174
167 return template_desc_init_fields(template->fmt, 175 result = template_desc_init_fields(template->fmt,
168 &(template->fields), 176 &(template->fields),
169 &(template->num_fields)); 177 &(template->num_fields));
178 if (result < 0)
179 pr_err("template %s init failed, result: %d\n", template->name);
180
181 return result;
170} 182}