Skip to content

Commit 9803d41

Browse files
Roberto SassuMimi Zohar
authored andcommitted
ima: pass the filename argument up to ima_add_template_entry()
Pass the filename argument to ima_add_template_entry() in order to eliminate a dependency on template specific data (third argument of integrity_audit_msg). This change is required because, with the new template management mechanism, the generation of a new measurement entry will be performed by new specific functions (introduced in next patches) and the current IMA code will not be aware anymore of how data is stored in the entry payload. Signed-off-by: Roberto Sassu <roberto.sassu@polito.it> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
1 parent 7d802a2 commit 9803d41

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

‎security/integrity/ima/ima.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ int ima_fs_init(void);
6969
void ima_fs_cleanup(void);
7070
int ima_inode_alloc(struct inode *inode);
7171
int ima_add_template_entry(struct ima_template_entry *entry, int violation,
72-
const char *op, struct inode *inode);
72+
const char *op, struct inode *inode,
73+
const unsigned char *filename);
7374
int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash);
7475
int ima_calc_buffer_hash(const void *data, int len,
7576
struct ima_digest_data *hash);
@@ -107,7 +108,7 @@ void ima_store_measurement(struct integrity_iint_cache *iint, struct file *file,
107108
void ima_audit_measurement(struct integrity_iint_cache *iint,
108109
const unsigned char *filename);
109110
int ima_store_template(struct ima_template_entry *entry, int violation,
110-
struct inode *inode);
111+
struct inode *inode, const unsigned char *filename);
111112
void ima_template_show(struct seq_file *m, void *e, enum ima_show_type show);
112113
const char *ima_d_path(struct path *path, char **pathbuf);
113114

‎security/integrity/ima/ima_api.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ static const char *IMA_TEMPLATE_NAME = "ima";
4040
* Returns 0 on success, error code otherwise
4141
*/
4242
int ima_store_template(struct ima_template_entry *entry,
43-
int violation, struct inode *inode)
43+
int violation, struct inode *inode,
44+
const unsigned char *filename)
4445
{
4546
const char *op = "add_template_measure";
4647
const char *audit_cause = "hashing_error";
@@ -67,7 +68,7 @@ int ima_store_template(struct ima_template_entry *entry,
6768
}
6869
memcpy(entry->digest, hash.hdr.digest, hash.hdr.length);
6970
}
70-
result = ima_add_template_entry(entry, violation, op, inode);
71+
result = ima_add_template_entry(entry, violation, op, inode, filename);
7172
return result;
7273
}
7374

@@ -96,7 +97,7 @@ void ima_add_violation(struct file *file, const unsigned char *filename,
9697
}
9798
memset(&entry->template, 0, sizeof(entry->template));
9899
strncpy(entry->template.file_name, filename, IMA_EVENT_NAME_LEN_MAX);
99-
result = ima_store_template(entry, violation, inode);
100+
result = ima_store_template(entry, violation, inode, filename);
100101
if (result < 0)
101102
kfree(entry);
102103
err_out:
@@ -248,7 +249,7 @@ void ima_store_measurement(struct integrity_iint_cache *iint,
248249
(strlen(filename) > IMA_EVENT_NAME_LEN_MAX) ?
249250
file->f_dentry->d_name.name : filename);
250251

251-
result = ima_store_template(entry, violation, inode);
252+
result = ima_store_template(entry, violation, inode, filename);
252253
if (!result || result == -EEXIST)
253254
iint->flags |= IMA_MEASURED;
254255
if (result < 0)

‎security/integrity/ima/ima_init.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ static void __init ima_add_boot_aggregate(void)
7171
memcpy(entry->template.digest, hash.hdr.digest,
7272
hash.hdr.length);
7373
}
74-
result = ima_store_template(entry, violation, NULL);
74+
result = ima_store_template(entry, violation, NULL,
75+
boot_aggregate_name);
7576
if (result < 0)
7677
kfree(entry);
7778
return;

‎security/integrity/ima/ima_queue.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ static int ima_pcr_extend(const u8 *hash)
104104
* and extend the pcr.
105105
*/
106106
int ima_add_template_entry(struct ima_template_entry *entry, int violation,
107-
const char *op, struct inode *inode)
107+
const char *op, struct inode *inode,
108+
const unsigned char *filename)
108109
{
109110
u8 digest[TPM_DIGEST_SIZE];
110111
const char *audit_cause = "hash_added";
@@ -141,8 +142,7 @@ int ima_add_template_entry(struct ima_template_entry *entry, int violation,
141142
}
142143
out:
143144
mutex_unlock(&ima_extend_list_mutex);
144-
integrity_audit_msg(AUDIT_INTEGRITY_PCR, inode,
145-
entry->template.file_name,
145+
integrity_audit_msg(AUDIT_INTEGRITY_PCR, inode, filename,
146146
op, audit_cause, result, audit_info);
147147
return result;
148148
}

0 commit comments

Comments
 (0)