提交 0d6bc14b 编写于 作者: Z Zhang Tianxing 提交者: Zheng Zengkai

Revert "ima: Keep track of the measurment list per ima namespace"

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4O25G
CVE: NA

--------------------------------

This reverts commit a1f9c162.
Signed-off-by: NZhang Tianxing <zhangtianxing3@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
Acked-by: Xiu Jianfeng<xiujianfeng@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 9c1e64e4
...@@ -232,7 +232,6 @@ struct ima_namespace { ...@@ -232,7 +232,6 @@ struct ima_namespace {
bool frozen; bool frozen;
struct ima_policy_data *policy_data; struct ima_policy_data *policy_data;
struct integrity_iint_tree *iint_tree; struct integrity_iint_tree *iint_tree;
struct list_head ns_measurements;
} __randomize_layout; } __randomize_layout;
extern struct ima_namespace init_ima_ns; extern struct ima_namespace init_ima_ns;
......
...@@ -119,7 +119,6 @@ struct ima_template_entry { ...@@ -119,7 +119,6 @@ struct ima_template_entry {
struct ima_queue_entry { struct ima_queue_entry {
struct hlist_node hnext; /* place in hash collision list */ struct hlist_node hnext; /* place in hash collision list */
struct list_head later; /* place in ima_measurements list */ struct list_head later; /* place in ima_measurements list */
struct list_head ns_later; /* place in ima namespace list */
struct ima_template_entry *entry; struct ima_template_entry *entry;
}; };
extern struct list_head ima_measurements; /* list of all measurements */ extern struct list_head ima_measurements; /* list of all measurements */
...@@ -152,8 +151,7 @@ int ima_init(void); ...@@ -152,8 +151,7 @@ int ima_init(void);
int ima_fs_init(void); int ima_fs_init(void);
int ima_add_template_entry(struct ima_template_entry *entry, int violation, int ima_add_template_entry(struct ima_template_entry *entry, int violation,
const char *op, struct inode *inode, const char *op, struct inode *inode,
const unsigned char *filename, const unsigned char *filename);
struct ima_namespace *ima_ns);
int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash); int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash);
int ima_calc_buffer_hash(const void *buf, loff_t len, int ima_calc_buffer_hash(const void *buf, loff_t len,
struct ima_digest_data *hash); struct ima_digest_data *hash);
...@@ -295,8 +293,7 @@ int ima_alloc_init_template(struct ima_event_data *event_data, ...@@ -295,8 +293,7 @@ int ima_alloc_init_template(struct ima_event_data *event_data,
struct ima_template_desc *template_desc); struct ima_template_desc *template_desc);
int ima_store_template(struct ima_template_entry *entry, int violation, int ima_store_template(struct ima_template_entry *entry, int violation,
struct inode *inode, const unsigned char *filename, struct inode *inode, const unsigned char *filename,
int pcr, struct ima_digest *digest, int pcr, struct ima_digest *digest);
struct ima_namespace *ima_ns);
void ima_free_template_entry(struct ima_template_entry *entry); void ima_free_template_entry(struct ima_template_entry *entry);
const char *ima_d_path(const struct path *path, char **pathbuf, char *filename); const char *ima_d_path(const struct path *path, char **pathbuf, char *filename);
......
...@@ -104,8 +104,7 @@ int ima_alloc_init_template(struct ima_event_data *event_data, ...@@ -104,8 +104,7 @@ int ima_alloc_init_template(struct ima_event_data *event_data,
int ima_store_template(struct ima_template_entry *entry, int ima_store_template(struct ima_template_entry *entry,
int violation, struct inode *inode, int violation, struct inode *inode,
const unsigned char *filename, int pcr, const unsigned char *filename, int pcr,
struct ima_digest *digest, struct ima_digest *digest)
struct ima_namespace *ima_ns)
{ {
static const char op[] = "add_template_measure"; static const char op[] = "add_template_measure";
static const char audit_cause[] = "hashing_error"; static const char audit_cause[] = "hashing_error";
...@@ -135,11 +134,10 @@ int ima_store_template(struct ima_template_entry *entry, ...@@ -135,11 +134,10 @@ int ima_store_template(struct ima_template_entry *entry,
} }
entry->pcr = pcr; entry->pcr = pcr;
result = ima_add_template_entry(entry, violation, op, inode, filename, result = ima_add_template_entry(entry, violation, op, inode, filename);
ima_ns);
if (!result && duplicated_entry) { if (!result && duplicated_entry) {
result = ima_add_template_entry(duplicated_entry, violation, op, result = ima_add_template_entry(duplicated_entry, violation, op,
inode, filename, ima_ns); inode, filename);
if (result < 0) if (result < 0)
kfree(duplicated_entry); kfree(duplicated_entry);
} }
...@@ -179,7 +177,7 @@ void ima_add_violation(struct file *file, const unsigned char *filename, ...@@ -179,7 +177,7 @@ void ima_add_violation(struct file *file, const unsigned char *filename,
goto err_out; goto err_out;
} }
result = ima_store_template(entry, violation, inode, filename, result = ima_store_template(entry, violation, inode, filename,
CONFIG_IMA_MEASURE_PCR_IDX, NULL, ima_ns); CONFIG_IMA_MEASURE_PCR_IDX, NULL);
if (result < 0) if (result < 0)
ima_free_template_entry(entry); ima_free_template_entry(entry);
err_out: err_out:
...@@ -366,7 +364,7 @@ void ima_store_measurement(struct integrity_iint_cache *iint, ...@@ -366,7 +364,7 @@ void ima_store_measurement(struct integrity_iint_cache *iint,
} }
result = ima_store_template(entry, violation, inode, filename, pcr, result = ima_store_template(entry, violation, inode, filename, pcr,
digest, ima_ns); digest);
out: out:
if ((!result || result == -EEXIST) && !(file->f_flags & O_DIRECT)) { if ((!result || result == -EEXIST) && !(file->f_flags & O_DIRECT)) {
iint->flags |= IMA_MEASURED; iint->flags |= IMA_MEASURED;
......
...@@ -35,7 +35,6 @@ struct ima_namespace init_ima_ns = { ...@@ -35,7 +35,6 @@ struct ima_namespace init_ima_ns = {
.frozen = true, .frozen = true,
.policy_data = &init_policy_data, .policy_data = &init_policy_data,
.iint_tree = &init_iint_tree, .iint_tree = &init_iint_tree,
.ns_measurements = LIST_HEAD_INIT(init_ima_ns.ns_measurements),
}; };
EXPORT_SYMBOL(init_ima_ns); EXPORT_SYMBOL(init_ima_ns);
...@@ -105,8 +104,7 @@ static int __init ima_add_boot_aggregate(void) ...@@ -105,8 +104,7 @@ static int __init ima_add_boot_aggregate(void)
result = ima_store_template(entry, violation, NULL, result = ima_store_template(entry, violation, NULL,
boot_aggregate_name, boot_aggregate_name,
CONFIG_IMA_MEASURE_PCR_IDX, NULL, CONFIG_IMA_MEASURE_PCR_IDX, NULL);
&init_ima_ns);
if (result < 0) { if (result < 0) {
ima_free_template_entry(entry); ima_free_template_entry(entry);
audit_cause = "store_entry"; audit_cause = "store_entry";
......
...@@ -1078,8 +1078,7 @@ void process_buffer_measurement(struct inode *inode, const void *buf, int size, ...@@ -1078,8 +1078,7 @@ void process_buffer_measurement(struct inode *inode, const void *buf, int size,
goto out; goto out;
} }
ret = ima_store_template(entry, violation, NULL, buf, pcr, NULL, ret = ima_store_template(entry, violation, NULL, buf, pcr, NULL);
ima_ns);
if (ret < 0) { if (ret < 0) {
audit_cause = "store_entry"; audit_cause = "store_entry";
ima_free_template_entry(entry); ima_free_template_entry(entry);
......
...@@ -130,7 +130,6 @@ static struct ima_namespace *clone_ima_ns(struct user_namespace *user_ns, ...@@ -130,7 +130,6 @@ static struct ima_namespace *clone_ima_ns(struct user_namespace *user_ns,
rwlock_init(&ns->iint_tree->lock); rwlock_init(&ns->iint_tree->lock);
ns->iint_tree->root = RB_ROOT; ns->iint_tree->root = RB_ROOT;
INIT_LIST_HEAD(&ns->ns_measurements);
INIT_LIST_HEAD(&ns->policy_data->ima_default_rules); INIT_LIST_HEAD(&ns->policy_data->ima_default_rules);
INIT_LIST_HEAD(&ns->policy_data->ima_policy_rules); INIT_LIST_HEAD(&ns->policy_data->ima_policy_rules);
INIT_LIST_HEAD(&ns->policy_data->ima_temp_rules); INIT_LIST_HEAD(&ns->policy_data->ima_temp_rules);
......
...@@ -91,8 +91,7 @@ static int get_binary_runtime_size(struct ima_template_entry *entry) ...@@ -91,8 +91,7 @@ static int get_binary_runtime_size(struct ima_template_entry *entry)
* (Called with ima_extend_list_mutex held.) * (Called with ima_extend_list_mutex held.)
*/ */
static int ima_add_digest_entry(struct ima_template_entry *entry, static int ima_add_digest_entry(struct ima_template_entry *entry,
bool update_htable, bool update_htable)
struct ima_namespace *ima_ns)
{ {
struct ima_queue_entry *qe; struct ima_queue_entry *qe;
unsigned int key; unsigned int key;
...@@ -106,7 +105,6 @@ static int ima_add_digest_entry(struct ima_template_entry *entry, ...@@ -106,7 +105,6 @@ static int ima_add_digest_entry(struct ima_template_entry *entry,
INIT_LIST_HEAD(&qe->later); INIT_LIST_HEAD(&qe->later);
list_add_tail_rcu(&qe->later, &ima_measurements); list_add_tail_rcu(&qe->later, &ima_measurements);
list_add_tail_rcu(&qe->ns_later, &ima_ns->ns_measurements);
atomic_long_inc(&ima_htable.len); atomic_long_inc(&ima_htable.len);
if (update_htable) { if (update_htable) {
...@@ -160,8 +158,7 @@ static int ima_pcr_extend(struct tpm_digest *digests_arg, int pcr) ...@@ -160,8 +158,7 @@ static int ima_pcr_extend(struct tpm_digest *digests_arg, int pcr)
*/ */
int ima_add_template_entry(struct ima_template_entry *entry, int violation, int ima_add_template_entry(struct ima_template_entry *entry, int violation,
const char *op, struct inode *inode, const char *op, struct inode *inode,
const unsigned char *filename, const unsigned char *filename)
struct ima_namespace *ima_ns)
{ {
u8 *digest = entry->digests[ima_hash_algo_idx].digest; u8 *digest = entry->digests[ima_hash_algo_idx].digest;
struct tpm_digest *digests_arg = entry->digests; struct tpm_digest *digests_arg = entry->digests;
...@@ -179,7 +176,7 @@ int ima_add_template_entry(struct ima_template_entry *entry, int violation, ...@@ -179,7 +176,7 @@ int ima_add_template_entry(struct ima_template_entry *entry, int violation,
} }
} }
result = ima_add_digest_entry(entry, 1, ima_ns); result = ima_add_digest_entry(entry, 1);
if (result < 0) { if (result < 0) {
audit_cause = "ENOMEM"; audit_cause = "ENOMEM";
audit_info = 0; audit_info = 0;
...@@ -208,7 +205,7 @@ int ima_restore_measurement_entry(struct ima_template_entry *entry) ...@@ -208,7 +205,7 @@ int ima_restore_measurement_entry(struct ima_template_entry *entry)
int result = 0; int result = 0;
mutex_lock(&ima_extend_list_mutex); mutex_lock(&ima_extend_list_mutex);
result = ima_add_digest_entry(entry, 0, &init_ima_ns); result = ima_add_digest_entry(entry, 0);
mutex_unlock(&ima_extend_list_mutex); mutex_unlock(&ima_extend_list_mutex);
return result; return result;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册