blob: d8edff209bf3b2bfc4373fa15ef17d25b30b86ed [file] [log] [blame]
Mimi Zohar3323eec2009-02-04 09:06:58 -05001/*
2 * Copyright (C) 2008 IBM Corporation
3 * Author: Mimi Zohar <zohar@us.ibm.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
8 *
9 * ima_policy.c
10 * - initialize default measure policy rules
11 *
12 */
13#include <linux/module.h>
14#include <linux/list.h>
Mimi Zohar3323eec2009-02-04 09:06:58 -050015#include <linux/security.h>
16#include <linux/magic.h>
Mimi Zohar4af46622009-02-04 09:07:00 -050017#include <linux/parser.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090018#include <linux/slab.h>
Mimi Zohar3323eec2009-02-04 09:06:58 -050019
20#include "ima.h"
21
22/* flags definitions */
23#define IMA_FUNC 0x0001
24#define IMA_MASK 0x0002
25#define IMA_FSMAGIC 0x0004
26#define IMA_UID 0x0008
27
Mimi Zohar4af46622009-02-04 09:07:00 -050028enum ima_action { UNKNOWN = -1, DONT_MEASURE = 0, MEASURE };
29
30#define MAX_LSM_RULES 6
31enum lsm_rule_types { LSM_OBJ_USER, LSM_OBJ_ROLE, LSM_OBJ_TYPE,
32 LSM_SUBJ_USER, LSM_SUBJ_ROLE, LSM_SUBJ_TYPE
33};
Mimi Zohar3323eec2009-02-04 09:06:58 -050034
35struct ima_measure_rule_entry {
36 struct list_head list;
37 enum ima_action action;
38 unsigned int flags;
39 enum ima_hooks func;
40 int mask;
41 unsigned long fsmagic;
42 uid_t uid;
Mimi Zohar4af46622009-02-04 09:07:00 -050043 struct {
44 void *rule; /* LSM file metadata specific */
45 int type; /* audit type */
46 } lsm[MAX_LSM_RULES];
Mimi Zohar3323eec2009-02-04 09:06:58 -050047};
48
Eric Paris5789ba32009-05-21 15:47:06 -040049/*
50 * Without LSM specific knowledge, the default policy can only be
Mimi Zohar4af46622009-02-04 09:07:00 -050051 * written in terms of .action, .func, .mask, .fsmagic, and .uid
52 */
Eric Paris5789ba32009-05-21 15:47:06 -040053
54/*
55 * The minimum rule set to allow for full TCB coverage. Measures all files
56 * opened or mmap for exec and everything read by root. Dangerous because
57 * normal users can easily run the machine out of memory simply building
58 * and running executables.
59 */
Mimi Zohar3323eec2009-02-04 09:06:58 -050060static struct ima_measure_rule_entry default_rules[] = {
Eric Paris75834fc2009-05-18 10:26:10 -040061 {.action = DONT_MEASURE,.fsmagic = PROC_SUPER_MAGIC,.flags = IMA_FSMAGIC},
Mimi Zohar3323eec2009-02-04 09:06:58 -050062 {.action = DONT_MEASURE,.fsmagic = SYSFS_MAGIC,.flags = IMA_FSMAGIC},
63 {.action = DONT_MEASURE,.fsmagic = DEBUGFS_MAGIC,.flags = IMA_FSMAGIC},
64 {.action = DONT_MEASURE,.fsmagic = TMPFS_MAGIC,.flags = IMA_FSMAGIC},
Dmitry Kasatkin4c2c3922011-10-18 14:16:28 +030065 {.action = DONT_MEASURE,.fsmagic = RAMFS_MAGIC,.flags = IMA_FSMAGIC},
Eric Paris75834fc2009-05-18 10:26:10 -040066 {.action = DONT_MEASURE,.fsmagic = SECURITYFS_MAGIC,.flags = IMA_FSMAGIC},
67 {.action = DONT_MEASURE,.fsmagic = SELINUX_MAGIC,.flags = IMA_FSMAGIC},
Mimi Zohar3323eec2009-02-04 09:06:58 -050068 {.action = MEASURE,.func = FILE_MMAP,.mask = MAY_EXEC,
69 .flags = IMA_FUNC | IMA_MASK},
70 {.action = MEASURE,.func = BPRM_CHECK,.mask = MAY_EXEC,
71 .flags = IMA_FUNC | IMA_MASK},
Mimi Zohar1e93d002010-01-26 17:02:41 -050072 {.action = MEASURE,.func = FILE_CHECK,.mask = MAY_READ,.uid = 0,
Eric Paris5789ba32009-05-21 15:47:06 -040073 .flags = IMA_FUNC | IMA_MASK | IMA_UID},
Mimi Zohar3323eec2009-02-04 09:06:58 -050074};
75
76static LIST_HEAD(measure_default_rules);
Mimi Zohar4af46622009-02-04 09:07:00 -050077static LIST_HEAD(measure_policy_rules);
Mimi Zohar3323eec2009-02-04 09:06:58 -050078static struct list_head *ima_measure;
79
Mimi Zohar4af46622009-02-04 09:07:00 -050080static DEFINE_MUTEX(ima_measure_mutex);
81
Eric Paris5789ba32009-05-21 15:47:06 -040082static bool ima_use_tcb __initdata;
83static int __init default_policy_setup(char *str)
84{
85 ima_use_tcb = 1;
86 return 1;
87}
88__setup("ima_tcb", default_policy_setup);
89
Mimi Zohar3323eec2009-02-04 09:06:58 -050090/**
91 * ima_match_rules - determine whether an inode matches the measure rule.
92 * @rule: a pointer to a rule
93 * @inode: a pointer to an inode
94 * @func: LIM hook identifier
95 * @mask: requested action (MAY_READ | MAY_WRITE | MAY_APPEND | MAY_EXEC)
96 *
97 * Returns true on rule match, false on failure.
98 */
99static bool ima_match_rules(struct ima_measure_rule_entry *rule,
100 struct inode *inode, enum ima_hooks func, int mask)
101{
102 struct task_struct *tsk = current;
Mimi Zohar3db59dd2012-01-17 22:11:28 -0500103 const struct cred *cred = current_cred();
Mimi Zohar4af46622009-02-04 09:07:00 -0500104 int i;
Mimi Zohar3323eec2009-02-04 09:06:58 -0500105
106 if ((rule->flags & IMA_FUNC) && rule->func != func)
107 return false;
108 if ((rule->flags & IMA_MASK) && rule->mask != mask)
109 return false;
110 if ((rule->flags & IMA_FSMAGIC)
111 && rule->fsmagic != inode->i_sb->s_magic)
112 return false;
Mimi Zohar3db59dd2012-01-17 22:11:28 -0500113 if ((rule->flags & IMA_UID) && rule->uid != cred->uid)
Mimi Zohar3323eec2009-02-04 09:06:58 -0500114 return false;
Mimi Zohar4af46622009-02-04 09:07:00 -0500115 for (i = 0; i < MAX_LSM_RULES; i++) {
Mimi Zohar53fc0e22009-05-05 13:12:48 -0400116 int rc = 0;
Mimi Zohar4af46622009-02-04 09:07:00 -0500117 u32 osid, sid;
118
119 if (!rule->lsm[i].rule)
120 continue;
121
122 switch (i) {
123 case LSM_OBJ_USER:
124 case LSM_OBJ_ROLE:
125 case LSM_OBJ_TYPE:
126 security_inode_getsecid(inode, &osid);
127 rc = security_filter_rule_match(osid,
128 rule->lsm[i].type,
Mimi Zohar53fc0e22009-05-05 13:12:48 -0400129 Audit_equal,
Mimi Zohar4af46622009-02-04 09:07:00 -0500130 rule->lsm[i].rule,
131 NULL);
132 break;
133 case LSM_SUBJ_USER:
134 case LSM_SUBJ_ROLE:
135 case LSM_SUBJ_TYPE:
136 security_task_getsecid(tsk, &sid);
137 rc = security_filter_rule_match(sid,
138 rule->lsm[i].type,
Mimi Zohar53fc0e22009-05-05 13:12:48 -0400139 Audit_equal,
Mimi Zohar4af46622009-02-04 09:07:00 -0500140 rule->lsm[i].rule,
141 NULL);
142 default:
143 break;
144 }
145 if (!rc)
146 return false;
147 }
Mimi Zohar3323eec2009-02-04 09:06:58 -0500148 return true;
149}
150
151/**
152 * ima_match_policy - decision based on LSM and other conditions
153 * @inode: pointer to an inode for which the policy decision is being made
154 * @func: IMA hook identifier
155 * @mask: requested action (MAY_READ | MAY_WRITE | MAY_APPEND | MAY_EXEC)
156 *
157 * Measure decision based on func/mask/fsmagic and LSM(subj/obj/type)
158 * conditions.
159 *
160 * (There is no need for locking when walking the policy list,
161 * as elements in the list are never deleted, nor does the list
162 * change.)
163 */
164int ima_match_policy(struct inode *inode, enum ima_hooks func, int mask)
165{
166 struct ima_measure_rule_entry *entry;
167
168 list_for_each_entry(entry, ima_measure, list) {
169 bool rc;
170
171 rc = ima_match_rules(entry, inode, func, mask);
172 if (rc)
173 return entry->action;
174 }
175 return 0;
176}
177
178/**
179 * ima_init_policy - initialize the default measure rules.
180 *
Mimi Zohar3323eec2009-02-04 09:06:58 -0500181 * ima_measure points to either the measure_default_rules or the
Mimi Zohar4af46622009-02-04 09:07:00 -0500182 * the new measure_policy_rules.
Mimi Zohar3323eec2009-02-04 09:06:58 -0500183 */
Eric Paris932995f2009-05-21 15:43:32 -0400184void __init ima_init_policy(void)
Mimi Zohar3323eec2009-02-04 09:06:58 -0500185{
Eric Paris5789ba32009-05-21 15:47:06 -0400186 int i, entries;
Mimi Zohar3323eec2009-02-04 09:06:58 -0500187
Eric Paris5789ba32009-05-21 15:47:06 -0400188 /* if !ima_use_tcb set entries = 0 so we load NO default rules */
189 if (ima_use_tcb)
190 entries = ARRAY_SIZE(default_rules);
191 else
192 entries = 0;
193
194 for (i = 0; i < entries; i++)
Mimi Zohar3323eec2009-02-04 09:06:58 -0500195 list_add_tail(&default_rules[i].list, &measure_default_rules);
196 ima_measure = &measure_default_rules;
197}
Mimi Zohar4af46622009-02-04 09:07:00 -0500198
199/**
200 * ima_update_policy - update default_rules with new measure rules
201 *
202 * Called on file .release to update the default rules with a complete new
203 * policy. Once updated, the policy is locked, no additional rules can be
204 * added to the policy.
205 */
206void ima_update_policy(void)
207{
208 const char *op = "policy_update";
209 const char *cause = "already exists";
210 int result = 1;
211 int audit_info = 0;
212
213 if (ima_measure == &measure_default_rules) {
214 ima_measure = &measure_policy_rules;
215 cause = "complete";
216 result = 0;
217 }
218 integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
219 NULL, op, cause, result, audit_info);
220}
221
222enum {
223 Opt_err = -1,
224 Opt_measure = 1, Opt_dont_measure,
225 Opt_obj_user, Opt_obj_role, Opt_obj_type,
226 Opt_subj_user, Opt_subj_role, Opt_subj_type,
227 Opt_func, Opt_mask, Opt_fsmagic, Opt_uid
228};
229
230static match_table_t policy_tokens = {
231 {Opt_measure, "measure"},
232 {Opt_dont_measure, "dont_measure"},
233 {Opt_obj_user, "obj_user=%s"},
234 {Opt_obj_role, "obj_role=%s"},
235 {Opt_obj_type, "obj_type=%s"},
236 {Opt_subj_user, "subj_user=%s"},
237 {Opt_subj_role, "subj_role=%s"},
238 {Opt_subj_type, "subj_type=%s"},
239 {Opt_func, "func=%s"},
240 {Opt_mask, "mask=%s"},
241 {Opt_fsmagic, "fsmagic=%s"},
242 {Opt_uid, "uid=%s"},
243 {Opt_err, NULL}
244};
245
246static int ima_lsm_rule_init(struct ima_measure_rule_entry *entry,
247 char *args, int lsm_rule, int audit_type)
248{
249 int result;
250
Eric Paris7b62e162010-04-20 10:21:01 -0400251 if (entry->lsm[lsm_rule].rule)
252 return -EINVAL;
253
Mimi Zohar4af46622009-02-04 09:07:00 -0500254 entry->lsm[lsm_rule].type = audit_type;
255 result = security_filter_rule_init(entry->lsm[lsm_rule].type,
Mimi Zohar53fc0e22009-05-05 13:12:48 -0400256 Audit_equal, args,
Mimi Zohar4af46622009-02-04 09:07:00 -0500257 &entry->lsm[lsm_rule].rule);
Mimi Zohar867c2022011-01-03 14:59:10 -0800258 if (!entry->lsm[lsm_rule].rule)
259 return -EINVAL;
Mimi Zohar4af46622009-02-04 09:07:00 -0500260 return result;
261}
262
Eric Paris2f1506c2010-04-20 10:21:30 -0400263static void ima_log_string(struct audit_buffer *ab, char *key, char *value)
264{
265 audit_log_format(ab, "%s=", key);
266 audit_log_untrustedstring(ab, value);
267 audit_log_format(ab, " ");
268}
269
Mimi Zohar4af46622009-02-04 09:07:00 -0500270static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)
271{
272 struct audit_buffer *ab;
273 char *p;
274 int result = 0;
275
Mimi Zohar523979a2009-02-11 11:12:28 -0500276 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_INTEGRITY_RULE);
Mimi Zohar4af46622009-02-04 09:07:00 -0500277
Eric Paris7b62e162010-04-20 10:21:01 -0400278 entry->uid = -1;
Eric Parisb9035b12010-04-20 10:21:07 -0400279 entry->action = UNKNOWN;
Eric Paris28ef4002010-04-20 10:21:18 -0400280 while ((p = strsep(&rule, " \t")) != NULL) {
Mimi Zohar4af46622009-02-04 09:07:00 -0500281 substring_t args[MAX_OPT_ARGS];
282 int token;
283 unsigned long lnum;
284
285 if (result < 0)
286 break;
Eric Paris28ef4002010-04-20 10:21:18 -0400287 if ((*p == '\0') || (*p == ' ') || (*p == '\t'))
288 continue;
Mimi Zohar4af46622009-02-04 09:07:00 -0500289 token = match_token(p, policy_tokens, args);
290 switch (token) {
291 case Opt_measure:
Eric Paris2f1506c2010-04-20 10:21:30 -0400292 ima_log_string(ab, "action", "measure");
Eric Paris7b62e162010-04-20 10:21:01 -0400293
294 if (entry->action != UNKNOWN)
295 result = -EINVAL;
296
Mimi Zohar4af46622009-02-04 09:07:00 -0500297 entry->action = MEASURE;
298 break;
299 case Opt_dont_measure:
Eric Paris2f1506c2010-04-20 10:21:30 -0400300 ima_log_string(ab, "action", "dont_measure");
Eric Paris7b62e162010-04-20 10:21:01 -0400301
302 if (entry->action != UNKNOWN)
303 result = -EINVAL;
304
Mimi Zohar4af46622009-02-04 09:07:00 -0500305 entry->action = DONT_MEASURE;
306 break;
307 case Opt_func:
Eric Paris2f1506c2010-04-20 10:21:30 -0400308 ima_log_string(ab, "func", args[0].from);
Eric Paris7b62e162010-04-20 10:21:01 -0400309
310 if (entry->func)
311 result = -EINVAL;
312
Mimi Zohar1e93d002010-01-26 17:02:41 -0500313 if (strcmp(args[0].from, "FILE_CHECK") == 0)
314 entry->func = FILE_CHECK;
315 /* PATH_CHECK is for backwards compat */
316 else if (strcmp(args[0].from, "PATH_CHECK") == 0)
317 entry->func = FILE_CHECK;
Mimi Zohar4af46622009-02-04 09:07:00 -0500318 else if (strcmp(args[0].from, "FILE_MMAP") == 0)
319 entry->func = FILE_MMAP;
320 else if (strcmp(args[0].from, "BPRM_CHECK") == 0)
321 entry->func = BPRM_CHECK;
322 else
323 result = -EINVAL;
324 if (!result)
325 entry->flags |= IMA_FUNC;
326 break;
327 case Opt_mask:
Eric Paris2f1506c2010-04-20 10:21:30 -0400328 ima_log_string(ab, "mask", args[0].from);
Eric Paris7b62e162010-04-20 10:21:01 -0400329
330 if (entry->mask)
331 result = -EINVAL;
332
Mimi Zohar4af46622009-02-04 09:07:00 -0500333 if ((strcmp(args[0].from, "MAY_EXEC")) == 0)
334 entry->mask = MAY_EXEC;
335 else if (strcmp(args[0].from, "MAY_WRITE") == 0)
336 entry->mask = MAY_WRITE;
337 else if (strcmp(args[0].from, "MAY_READ") == 0)
338 entry->mask = MAY_READ;
339 else if (strcmp(args[0].from, "MAY_APPEND") == 0)
340 entry->mask = MAY_APPEND;
341 else
342 result = -EINVAL;
343 if (!result)
344 entry->flags |= IMA_MASK;
345 break;
346 case Opt_fsmagic:
Eric Paris2f1506c2010-04-20 10:21:30 -0400347 ima_log_string(ab, "fsmagic", args[0].from);
Eric Paris7b62e162010-04-20 10:21:01 -0400348
349 if (entry->fsmagic) {
350 result = -EINVAL;
351 break;
352 }
353
Mimi Zohar4af46622009-02-04 09:07:00 -0500354 result = strict_strtoul(args[0].from, 16,
355 &entry->fsmagic);
356 if (!result)
357 entry->flags |= IMA_FSMAGIC;
358 break;
359 case Opt_uid:
Eric Paris2f1506c2010-04-20 10:21:30 -0400360 ima_log_string(ab, "uid", args[0].from);
Eric Paris7b62e162010-04-20 10:21:01 -0400361
362 if (entry->uid != -1) {
363 result = -EINVAL;
364 break;
365 }
366
Mimi Zohar4af46622009-02-04 09:07:00 -0500367 result = strict_strtoul(args[0].from, 10, &lnum);
368 if (!result) {
369 entry->uid = (uid_t) lnum;
370 if (entry->uid != lnum)
371 result = -EINVAL;
372 else
373 entry->flags |= IMA_UID;
374 }
375 break;
376 case Opt_obj_user:
Eric Paris2f1506c2010-04-20 10:21:30 -0400377 ima_log_string(ab, "obj_user", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500378 result = ima_lsm_rule_init(entry, args[0].from,
379 LSM_OBJ_USER,
380 AUDIT_OBJ_USER);
381 break;
382 case Opt_obj_role:
Eric Paris2f1506c2010-04-20 10:21:30 -0400383 ima_log_string(ab, "obj_role", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500384 result = ima_lsm_rule_init(entry, args[0].from,
385 LSM_OBJ_ROLE,
386 AUDIT_OBJ_ROLE);
387 break;
388 case Opt_obj_type:
Eric Paris2f1506c2010-04-20 10:21:30 -0400389 ima_log_string(ab, "obj_type", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500390 result = ima_lsm_rule_init(entry, args[0].from,
391 LSM_OBJ_TYPE,
392 AUDIT_OBJ_TYPE);
393 break;
394 case Opt_subj_user:
Eric Paris2f1506c2010-04-20 10:21:30 -0400395 ima_log_string(ab, "subj_user", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500396 result = ima_lsm_rule_init(entry, args[0].from,
397 LSM_SUBJ_USER,
398 AUDIT_SUBJ_USER);
399 break;
400 case Opt_subj_role:
Eric Paris2f1506c2010-04-20 10:21:30 -0400401 ima_log_string(ab, "subj_role", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500402 result = ima_lsm_rule_init(entry, args[0].from,
403 LSM_SUBJ_ROLE,
404 AUDIT_SUBJ_ROLE);
405 break;
406 case Opt_subj_type:
Eric Paris2f1506c2010-04-20 10:21:30 -0400407 ima_log_string(ab, "subj_type", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500408 result = ima_lsm_rule_init(entry, args[0].from,
409 LSM_SUBJ_TYPE,
410 AUDIT_SUBJ_TYPE);
411 break;
412 case Opt_err:
Eric Paris2f1506c2010-04-20 10:21:30 -0400413 ima_log_string(ab, "UNKNOWN", p);
Eric Parise9d393b2010-04-20 10:21:13 -0400414 result = -EINVAL;
Mimi Zohar4af46622009-02-04 09:07:00 -0500415 break;
416 }
417 }
Eric Paris7b62e162010-04-20 10:21:01 -0400418 if (!result && (entry->action == UNKNOWN))
Mimi Zohar4af46622009-02-04 09:07:00 -0500419 result = -EINVAL;
420
Eric Parisb0d5de42012-02-14 17:11:07 -0500421 audit_log_format(ab, "res=%d", !result);
Mimi Zohar4af46622009-02-04 09:07:00 -0500422 audit_log_end(ab);
423 return result;
424}
425
426/**
427 * ima_parse_add_rule - add a rule to measure_policy_rules
428 * @rule - ima measurement policy rule
429 *
430 * Uses a mutex to protect the policy list from multiple concurrent writers.
Eric Paris6ccd0452010-04-20 10:20:54 -0400431 * Returns the length of the rule parsed, an error code on failure
Mimi Zohar4af46622009-02-04 09:07:00 -0500432 */
Eric Paris6ccd0452010-04-20 10:20:54 -0400433ssize_t ima_parse_add_rule(char *rule)
Mimi Zohar4af46622009-02-04 09:07:00 -0500434{
Mimi Zohar523979a2009-02-11 11:12:28 -0500435 const char *op = "update_policy";
Eric Paris6ccd0452010-04-20 10:20:54 -0400436 char *p;
Mimi Zohar4af46622009-02-04 09:07:00 -0500437 struct ima_measure_rule_entry *entry;
Eric Paris6ccd0452010-04-20 10:20:54 -0400438 ssize_t result, len;
Mimi Zohar4af46622009-02-04 09:07:00 -0500439 int audit_info = 0;
440
441 /* Prevent installed policy from changing */
442 if (ima_measure != &measure_default_rules) {
443 integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
444 NULL, op, "already exists",
445 -EACCES, audit_info);
446 return -EACCES;
447 }
448
449 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
450 if (!entry) {
451 integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
452 NULL, op, "-ENOMEM", -ENOMEM, audit_info);
453 return -ENOMEM;
454 }
455
456 INIT_LIST_HEAD(&entry->list);
457
Eric Paris6ccd0452010-04-20 10:20:54 -0400458 p = strsep(&rule, "\n");
459 len = strlen(p) + 1;
Eric Paris7233e3e2010-04-20 10:21:24 -0400460
461 if (*p == '#') {
462 kfree(entry);
463 return len;
464 }
465
Eric Paris6ccd0452010-04-20 10:20:54 -0400466 result = ima_parse_rule(p, entry);
Eric Paris7233e3e2010-04-20 10:21:24 -0400467 if (result) {
Mimi Zohar4af46622009-02-04 09:07:00 -0500468 kfree(entry);
Mimi Zohar523979a2009-02-11 11:12:28 -0500469 integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
470 NULL, op, "invalid policy", result,
471 audit_info);
Eric Paris7233e3e2010-04-20 10:21:24 -0400472 return result;
Mimi Zohar523979a2009-02-11 11:12:28 -0500473 }
Eric Paris7233e3e2010-04-20 10:21:24 -0400474
475 mutex_lock(&ima_measure_mutex);
476 list_add_tail(&entry->list, &measure_policy_rules);
477 mutex_unlock(&ima_measure_mutex);
478
479 return len;
Mimi Zohar4af46622009-02-04 09:07:00 -0500480}
481
482/* ima_delete_rules called to cleanup invalid policy */
James Morris64c61d82009-02-05 09:28:26 +1100483void ima_delete_rules(void)
Mimi Zohar4af46622009-02-04 09:07:00 -0500484{
485 struct ima_measure_rule_entry *entry, *tmp;
486
487 mutex_lock(&ima_measure_mutex);
488 list_for_each_entry_safe(entry, tmp, &measure_policy_rules, list) {
489 list_del(&entry->list);
490 kfree(entry);
491 }
492 mutex_unlock(&ima_measure_mutex);
493}