Re: [PATCH-v2 2/6] ima: added new template helperlookup_template_desc_by_fmt()

From: Mimi Zohar
Date: Mon Dec 09 2013 - 08:35:06 EST


On Tue, 2013-11-19 at 13:33 +0100, Roberto Sassu wrote:
> This patch adds a new helper to search a template descriptor by its format.

The initial template and larger hash digest patch set was quite large.
In order not to break backward compatibility and move forward, functions
were added before they were actually used. For future reference, we
normally define new functions and use them in the same patch.

thanks,

Mimi

> Also, the old function lookup_template_desc(), which performs the search
> by name, has been renamed to lookup_template_desc_by_name().
>
> Signed-off-by: Roberto Sassu <roberto.sassu@xxxxxxxxx>
> ---
> security/integrity/ima/ima_template.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
> index 33c911a..c849723 100644
> --- a/security/integrity/ima/ima_template.c
> +++ b/security/integrity/ima/ima_template.c
> @@ -38,7 +38,7 @@ static struct ima_template_field supported_fields[] = {
> };
>
> static struct ima_template_desc *ima_template;
> -static struct ima_template_desc *lookup_template_desc(const char *name);
> +static struct ima_template_desc *lookup_template_desc_by_name(const char *name);
> static struct ima_template_field *lookup_template_field(const char *field_id);
>
> static int __init ima_template_setup(char *str)
> @@ -53,7 +53,7 @@ static int __init ima_template_setup(char *str)
> * Verify that a template with the supplied name exists.
> * If not, use CONFIG_IMA_DEFAULT_TEMPLATE.
> */
> - template_desc = lookup_template_desc(str);
> + template_desc = lookup_template_desc_by_name(str);
> if (!template_desc) {
> pr_err("IMA: template %s not found, using %s\n",
> str, CONFIG_IMA_DEFAULT_TEMPLATE);
> @@ -117,7 +117,7 @@ static int __init ima_template_fmt_setup(char *str)
> }
> __setup("ima_template_fmt=", ima_template_fmt_setup);
>
> -static struct ima_template_desc *lookup_template_desc(const char *name)
> +static struct ima_template_desc *lookup_template_desc_by_name(const char *name)
> {
> int i;
>
> @@ -129,6 +129,18 @@ static struct ima_template_desc *lookup_template_desc(const char *name)
> return NULL;
> }
>
> +static struct ima_template_desc *lookup_template_desc_by_fmt(const char *fmt)
> +{
> + struct ima_template_desc *desc;
> +
> + list_for_each_entry(desc, &defined_templates[0].list, list) {
> + if (strcmp(desc->fmt, fmt) == 0)
> + return desc;
> + }
> +
> + return NULL;
> +}
> +
> static struct ima_template_field *lookup_template_field(const char *field_id)
> {
> int i;
> @@ -232,7 +244,7 @@ struct ima_template_desc *ima_template_desc_current(void)
> {
> if (!ima_template)
> ima_template =
> - lookup_template_desc(CONFIG_IMA_DEFAULT_TEMPLATE);
> + lookup_template_desc_by_name(CONFIG_IMA_DEFAULT_TEMPLATE);
> return ima_template;
> }
>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/