lkml.org 
[lkml]   [2013]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCH 4/6] ima: replace ima_template_desc_current() with ima_get_template_desc()
Date
This patch replaces calls to ima_template_desc_current() in ima_api.c
and ima_main.c with ima_get_template_desc() as the former function
is called by the latter when passed arguments are both NULL. The patch
also declares the former function as static so that it will not be
longer available outside ima_template.c.

Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
---
security/integrity/ima/ima.h | 1 -
security/integrity/ima/ima_api.c | 3 ++-
security/integrity/ima/ima_main.c | 6 ++++--
security/integrity/ima/ima_template.c | 2 +-
4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index d7b4c19..f72c488 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -106,7 +106,6 @@ void ima_add_violation(struct file *file, const unsigned char *filename,
int ima_init_crypto(void);
void ima_putc(struct seq_file *m, void *data, int datalen);
void ima_print_digest(struct seq_file *m, u8 *digest, int size);
-struct ima_template_desc *ima_template_desc_current(void);
struct ima_template_desc *ima_get_template_desc(char *template_name,
char *template_fmt);
int ima_init_template(void);
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index 0e75408..f10328d 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -29,9 +29,10 @@ int ima_alloc_init_template(struct integrity_iint_cache *iint,
struct evm_ima_xattr_data *xattr_value,
int xattr_len, struct ima_template_entry **entry)
{
- struct ima_template_desc *template_desc = ima_template_desc_current();
+ struct ima_template_desc *template_desc;
int i, result = 0;

+ template_desc = ima_get_template_desc(NULL, NULL);
*entry = kzalloc(sizeof(**entry) + template_desc->num_fields *
sizeof(struct ima_field_data), GFP_NOFS);
if (!*entry)
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 149ee11..6e1d3db 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -41,12 +41,13 @@ static int hash_setup_done;

static int __init hash_setup(char *str)
{
- struct ima_template_desc *template_desc = ima_template_desc_current();
+ struct ima_template_desc *template_desc;
int i;

if (hash_setup_done)
return 1;

+ template_desc = ima_get_template_desc(NULL, NULL);
if (strcmp(template_desc->name, IMA_TEMPLATE_IMA_NAME) == 0) {
if (strncmp(str, "sha1", 4) == 0)
ima_hash_algo = HASH_ALGO_SHA1;
@@ -166,7 +167,7 @@ static int process_measurement(struct file *file, const char *filename,
{
struct inode *inode = file_inode(file);
struct integrity_iint_cache *iint;
- struct ima_template_desc *template_desc = ima_template_desc_current();
+ struct ima_template_desc *template_desc;
char *pathbuf = NULL;
const char *pathname = NULL;
int rc = -ENOMEM, action, must_appraise, _func;
@@ -210,6 +211,7 @@ static int process_measurement(struct file *file, const char *filename,
goto out_digsig;
}

+ template_desc = ima_get_template_desc(NULL, NULL);
if (strcmp(template_desc->name, IMA_TEMPLATE_IMA_NAME) == 0) {
if (action & IMA_APPRAISE_SUBMASK)
xattr_ptr = &xattr_value;
diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index 7daf2ba..f66e06d 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -240,7 +240,7 @@ static int init_defined_templates(void)
return result;
}

-struct ima_template_desc *ima_template_desc_current(void)
+static struct ima_template_desc *ima_template_desc_current(void)
{
if (!ima_template)
ima_template =
--
1.8.1.4
[unhandled content-type:application/x-pkcs7-signature]
\
 
 \ /
  Last update: 2013-11-07 17:01    [W:0.045 / U:1.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site