Re: [RFC][Patch 5/5]integrity: IMA as an integrity service provider

From: Randy Dunlap
Date: Wed Jun 11 2008 - 18:38:16 EST


On Tue, 27 May 2008 10:36:03 -0400 Mimi Zohar wrote:

> Index: linux-2.6.26-rc3-git2/security/integrity/ima/ima_api.c
> ===================================================================
> --- /dev/null
> +++ linux-2.6.26-rc3-git2/security/integrity/ima/ima_api.c
> @@ -0,0 +1,365 @@
> +/*
> + * Copyright (C) 2008 IBM Corporation
> + *
> + * Authors:
> + * Mimi Zohar <zohar@xxxxxxxxxx>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation, version 2 of the
> + * License.
> + *
> + * File: ima_api.c
> + * - implements the LIM API
> + */
> +#include <linux/module.h>
> +#include <linux/integrity.h>
> +#include <linux/magic.h>
> +#include <linux/writeback.h>
> +#include <linux/string.h>
> +#include <linux/list.h>
> +#include <linux/audit.h>
> +#include <linux/ima.h>
> +
> +#include "ima.h"
> +
> +struct template_operations ima_template_ops = {
> + .must_measure = ima_must_measure,
> + .collect_measurement = ima_collect_measurement,
> + .store_measurement = ima_store_measurement,
> + .display_template = ima_template_show
> +};
> +
> +#ifdef CONFIG_IMA_BOOTPARAM
> +static int ima_enabled = CONFIG_IMA_BOOTPARAM_VALUE;
> +
> +static int __init ima_enabled_setup(char *str)
> +{
> +
> + ima_enabled = simple_strtol(str, NULL, 0);
> + return 1;
> +}
> +
> +__setup("ima=", ima_enabled_setup);
> +#else
> +static int ima_enabled = 1;
> +#endif
> +
> +/**
> + * mode_setup - for compatability with non-template IMA versions
> + * @str - is pointer to a string
> + */
> +int ima_template_mode = 1;
> +static int __init mode_setup(char *str)
> +{
> + if (strncmp(str, "ima", 3) == 0)
> + ima_template_mode = 0;
> + if (strncmp(str, "template", 7) == 0)
> + ima_template_mode = 1;
> + printk(KERN_INFO "%s: template_mode %s \n", __func__,
> + ima_template_mode ? "template" : "ima");
> + return 1;
> +}
> +
> +__setup("ima_mode=", mode_setup);
> +
> +/**
> + * ima_digest_cpy - copy the hash in the IMA template structure to a digest
> + * @template_name: string containing the name of the template (i.e. "ima")
> + * @template - pointer to template structure

* @template:

> + * @digest - pointer to the digest

* @digest:

> + *
> + * Returns 0 on success, error code otherwise
> + */
> +static int ima_digest_cpy(char *template_name, void *template, u8 *digest)
> +{
> + int rc, result = 0;
> + struct ima_inode_measure_entry *inode_template =
> + (struct ima_inode_measure_entry *)template;
> +
> + rc = strcmp(template_name, "ima");
> + if (rc == 0)
> + memcpy(digest, inode_template->digest,
> + sizeof inode_template->digest);
> + else
> + result = -ENODATA;
> + return result;
> +}


Thanks.
---
~Randy
--
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/