blob: d45061d02feec0d8b3e55f356d81df41580ad506 [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},
Eric Paris75834fc2009-05-18 10:26:10 -040065 {.action = DONT_MEASURE,.fsmagic = SECURITYFS_MAGIC,.flags = IMA_FSMAGIC},
66 {.action = DONT_MEASURE,.fsmagic = SELINUX_MAGIC,.flags = IMA_FSMAGIC},
Mimi Zohar3323eec2009-02-04 09:06:58 -050067 {.action = MEASURE,.func = FILE_MMAP,.mask = MAY_EXEC,
68 .flags = IMA_FUNC | IMA_MASK},
69 {.action = MEASURE,.func = BPRM_CHECK,.mask = MAY_EXEC,
70 .flags = IMA_FUNC | IMA_MASK},
Mimi Zohar1e93d002010-01-26 17:02:41 -050071 {.action = MEASURE,.func = FILE_CHECK,.mask = MAY_READ,.uid = 0,
Eric Paris5789ba32009-05-21 15:47:06 -040072 .flags = IMA_FUNC | IMA_MASK | IMA_UID},
Mimi Zohar3323eec2009-02-04 09:06:58 -050073};
74
75static LIST_HEAD(measure_default_rules);
Mimi Zohar4af46622009-02-04 09:07:00 -050076static LIST_HEAD(measure_policy_rules);
Mimi Zohar3323eec2009-02-04 09:06:58 -050077static struct list_head *ima_measure;
78
Mimi Zohar4af46622009-02-04 09:07:00 -050079static DEFINE_MUTEX(ima_measure_mutex);
80
Eric Paris5789ba32009-05-21 15:47:06 -040081static bool ima_use_tcb __initdata;
82static int __init default_policy_setup(char *str)
83{
84 ima_use_tcb = 1;
85 return 1;
86}
87__setup("ima_tcb", default_policy_setup);
88
Mimi Zohar3323eec2009-02-04 09:06:58 -050089/**
90 * ima_match_rules - determine whether an inode matches the measure rule.
91 * @rule: a pointer to a rule
92 * @inode: a pointer to an inode
93 * @func: LIM hook identifier
94 * @mask: requested action (MAY_READ | MAY_WRITE | MAY_APPEND | MAY_EXEC)
95 *
96 * Returns true on rule match, false on failure.
97 */
98static bool ima_match_rules(struct ima_measure_rule_entry *rule,
99 struct inode *inode, enum ima_hooks func, int mask)
100{
101 struct task_struct *tsk = current;
Mimi Zohar3db59dd2012-01-17 22:11:28 -0500102 const struct cred *cred = current_cred();
Mimi Zohar4af46622009-02-04 09:07:00 -0500103 int i;
Mimi Zohar3323eec2009-02-04 09:06:58 -0500104
105 if ((rule->flags & IMA_FUNC) && rule->func != func)
106 return false;
107 if ((rule->flags & IMA_MASK) && rule->mask != mask)
108 return false;
109 if ((rule->flags & IMA_FSMAGIC)
110 && rule->fsmagic != inode->i_sb->s_magic)
111 return false;
Mimi Zohar3db59dd2012-01-17 22:11:28 -0500112 if ((rule->flags & IMA_UID) && rule->uid != cred->uid)
Mimi Zohar3323eec2009-02-04 09:06:58 -0500113 return false;
Mimi Zohar4af46622009-02-04 09:07:00 -0500114 for (i = 0; i < MAX_LSM_RULES; i++) {
Mimi Zohar53fc0e22009-05-05 13:12:48 -0400115 int rc = 0;
Mimi Zohar4af46622009-02-04 09:07:00 -0500116 u32 osid, sid;
117
118 if (!rule->lsm[i].rule)
119 continue;
120
121 switch (i) {
122 case LSM_OBJ_USER:
123 case LSM_OBJ_ROLE:
124 case LSM_OBJ_TYPE:
125 security_inode_getsecid(inode, &osid);
126 rc = security_filter_rule_match(osid,
127 rule->lsm[i].type,
Mimi Zohar53fc0e22009-05-05 13:12:48 -0400128 Audit_equal,
Mimi Zohar4af46622009-02-04 09:07:00 -0500129 rule->lsm[i].rule,
130 NULL);
131 break;
132 case LSM_SUBJ_USER:
133 case LSM_SUBJ_ROLE:
134 case LSM_SUBJ_TYPE:
135 security_task_getsecid(tsk, &sid);
136 rc = security_filter_rule_match(sid,
137 rule->lsm[i].type,
Mimi Zohar53fc0e22009-05-05 13:12:48 -0400138 Audit_equal,
Mimi Zohar4af46622009-02-04 09:07:00 -0500139 rule->lsm[i].rule,
140 NULL);
141 default:
142 break;
143 }
144 if (!rc)
145 return false;
146 }
Mimi Zohar3323eec2009-02-04 09:06:58 -0500147 return true;
148}
149
150/**
151 * ima_match_policy - decision based on LSM and other conditions
152 * @inode: pointer to an inode for which the policy decision is being made
153 * @func: IMA hook identifier
154 * @mask: requested action (MAY_READ | MAY_WRITE | MAY_APPEND | MAY_EXEC)
155 *
156 * Measure decision based on func/mask/fsmagic and LSM(subj/obj/type)
157 * conditions.
158 *
159 * (There is no need for locking when walking the policy list,
160 * as elements in the list are never deleted, nor does the list
161 * change.)
162 */
163int ima_match_policy(struct inode *inode, enum ima_hooks func, int mask)
164{
165 struct ima_measure_rule_entry *entry;
166
167 list_for_each_entry(entry, ima_measure, list) {
168 bool rc;
169
170 rc = ima_match_rules(entry, inode, func, mask);
171 if (rc)
172 return entry->action;
173 }
174 return 0;
175}
176
177/**
178 * ima_init_policy - initialize the default measure rules.
179 *
Mimi Zohar3323eec2009-02-04 09:06:58 -0500180 * ima_measure points to either the measure_default_rules or the
Mimi Zohar4af46622009-02-04 09:07:00 -0500181 * the new measure_policy_rules.
Mimi Zohar3323eec2009-02-04 09:06:58 -0500182 */
Eric Paris932995f2009-05-21 15:43:32 -0400183void __init ima_init_policy(void)
Mimi Zohar3323eec2009-02-04 09:06:58 -0500184{
Eric Paris5789ba32009-05-21 15:47:06 -0400185 int i, entries;
Mimi Zohar3323eec2009-02-04 09:06:58 -0500186
Eric Paris5789ba32009-05-21 15:47:06 -0400187 /* if !ima_use_tcb set entries = 0 so we load NO default rules */
188 if (ima_use_tcb)
189 entries = ARRAY_SIZE(default_rules);
190 else
191 entries = 0;
192
193 for (i = 0; i < entries; i++)
Mimi Zohar3323eec2009-02-04 09:06:58 -0500194 list_add_tail(&default_rules[i].list, &measure_default_rules);
195 ima_measure = &measure_default_rules;
196}
Mimi Zohar4af46622009-02-04 09:07:00 -0500197
198/**
199 * ima_update_policy - update default_rules with new measure rules
200 *
201 * Called on file .release to update the default rules with a complete new
202 * policy. Once updated, the policy is locked, no additional rules can be
203 * added to the policy.
204 */
205void ima_update_policy(void)
206{
207 const char *op = "policy_update";
208 const char *cause = "already exists";
209 int result = 1;
210 int audit_info = 0;
211
212 if (ima_measure == &measure_default_rules) {
213 ima_measure = &measure_policy_rules;
214 cause = "complete";
215 result = 0;
216 }
217 integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
218 NULL, op, cause, result, audit_info);
219}
220
221enum {
222 Opt_err = -1,
223 Opt_measure = 1, Opt_dont_measure,
224 Opt_obj_user, Opt_obj_role, Opt_obj_type,
225 Opt_subj_user, Opt_subj_role, Opt_subj_type,
226 Opt_func, Opt_mask, Opt_fsmagic, Opt_uid
227};
228
229static match_table_t policy_tokens = {
230 {Opt_measure, "measure"},
231 {Opt_dont_measure, "dont_measure"},
232 {Opt_obj_user, "obj_user=%s"},
233 {Opt_obj_role, "obj_role=%s"},
234 {Opt_obj_type, "obj_type=%s"},
235 {Opt_subj_user, "subj_user=%s"},
236 {Opt_subj_role, "subj_role=%s"},
237 {Opt_subj_type, "subj_type=%s"},
238 {Opt_func, "func=%s"},
239 {Opt_mask, "mask=%s"},
240 {Opt_fsmagic, "fsmagic=%s"},
241 {Opt_uid, "uid=%s"},
242 {Opt_err, NULL}
243};
244
245static int ima_lsm_rule_init(struct ima_measure_rule_entry *entry,
246 char *args, int lsm_rule, int audit_type)
247{
248 int result;
249
Eric Paris7b62e162010-04-20 10:21:01 -0400250 if (entry->lsm[lsm_rule].rule)
251 return -EINVAL;
252
Mimi Zohar4af46622009-02-04 09:07:00 -0500253 entry->lsm[lsm_rule].type = audit_type;
254 result = security_filter_rule_init(entry->lsm[lsm_rule].type,
Mimi Zohar53fc0e22009-05-05 13:12:48 -0400255 Audit_equal, args,
Mimi Zohar4af46622009-02-04 09:07:00 -0500256 &entry->lsm[lsm_rule].rule);
Mimi Zohar867c2022011-01-03 14:59:10 -0800257 if (!entry->lsm[lsm_rule].rule)
258 return -EINVAL;
Mimi Zohar4af46622009-02-04 09:07:00 -0500259 return result;
260}
261
Eric Paris2f1506c2010-04-20 10:21:30 -0400262static void ima_log_string(struct audit_buffer *ab, char *key, char *value)
263{
264 audit_log_format(ab, "%s=", key);
265 audit_log_untrustedstring(ab, value);
266 audit_log_format(ab, " ");
267}
268
Mimi Zohar4af46622009-02-04 09:07:00 -0500269static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)
270{
271 struct audit_buffer *ab;
272 char *p;
273 int result = 0;
274
Mimi Zohar523979a2009-02-11 11:12:28 -0500275 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_INTEGRITY_RULE);
Mimi Zohar4af46622009-02-04 09:07:00 -0500276
Eric Paris7b62e162010-04-20 10:21:01 -0400277 entry->uid = -1;
Eric Parisb9035b12010-04-20 10:21:07 -0400278 entry->action = UNKNOWN;
Eric Paris28ef4002010-04-20 10:21:18 -0400279 while ((p = strsep(&rule, " \t")) != NULL) {
Mimi Zohar4af46622009-02-04 09:07:00 -0500280 substring_t args[MAX_OPT_ARGS];
281 int token;
282 unsigned long lnum;
283
284 if (result < 0)
285 break;
Eric Paris28ef4002010-04-20 10:21:18 -0400286 if ((*p == '\0') || (*p == ' ') || (*p == '\t'))
287 continue;
Mimi Zohar4af46622009-02-04 09:07:00 -0500288 token = match_token(p, policy_tokens, args);
289 switch (token) {
290 case Opt_measure:
Eric Paris2f1506c2010-04-20 10:21:30 -0400291 ima_log_string(ab, "action", "measure");
Eric Paris7b62e162010-04-20 10:21:01 -0400292
293 if (entry->action != UNKNOWN)
294 result = -EINVAL;
295
Mimi Zohar4af46622009-02-04 09:07:00 -0500296 entry->action = MEASURE;
297 break;
298 case Opt_dont_measure:
Eric Paris2f1506c2010-04-20 10:21:30 -0400299 ima_log_string(ab, "action", "dont_measure");
Eric Paris7b62e162010-04-20 10:21:01 -0400300
301 if (entry->action != UNKNOWN)
302 result = -EINVAL;
303
Mimi Zohar4af46622009-02-04 09:07:00 -0500304 entry->action = DONT_MEASURE;
305 break;
306 case Opt_func:
Eric Paris2f1506c2010-04-20 10:21:30 -0400307 ima_log_string(ab, "func", args[0].from);
Eric Paris7b62e162010-04-20 10:21:01 -0400308
309 if (entry->func)
310 result = -EINVAL;
311
Mimi Zohar1e93d002010-01-26 17:02:41 -0500312 if (strcmp(args[0].from, "FILE_CHECK") == 0)
313 entry->func = FILE_CHECK;
314 /* PATH_CHECK is for backwards compat */
315 else if (strcmp(args[0].from, "PATH_CHECK") == 0)
316 entry->func = FILE_CHECK;
Mimi Zohar4af46622009-02-04 09:07:00 -0500317 else if (strcmp(args[0].from, "FILE_MMAP") == 0)
318 entry->func = FILE_MMAP;
319 else if (strcmp(args[0].from, "BPRM_CHECK") == 0)
320 entry->func = BPRM_CHECK;
321 else
322 result = -EINVAL;
323 if (!result)
324 entry->flags |= IMA_FUNC;
325 break;
326 case Opt_mask:
Eric Paris2f1506c2010-04-20 10:21:30 -0400327 ima_log_string(ab, "mask", args[0].from);
Eric Paris7b62e162010-04-20 10:21:01 -0400328
329 if (entry->mask)
330 result = -EINVAL;
331
Mimi Zohar4af46622009-02-04 09:07:00 -0500332 if ((strcmp(args[0].from, "MAY_EXEC")) == 0)
333 entry->mask = MAY_EXEC;
334 else if (strcmp(args[0].from, "MAY_WRITE") == 0)
335 entry->mask = MAY_WRITE;
336 else if (strcmp(args[0].from, "MAY_READ") == 0)
337 entry->mask = MAY_READ;
338 else if (strcmp(args[0].from, "MAY_APPEND") == 0)
339 entry->mask = MAY_APPEND;
340 else
341 result = -EINVAL;
342 if (!result)
343 entry->flags |= IMA_MASK;
344 break;
345 case Opt_fsmagic:
Eric Paris2f1506c2010-04-20 10:21:30 -0400346 ima_log_string(ab, "fsmagic", args[0].from);
Eric Paris7b62e162010-04-20 10:21:01 -0400347
348 if (entry->fsmagic) {
349 result = -EINVAL;
350 break;
351 }
352
Mimi Zohar4af46622009-02-04 09:07:00 -0500353 result = strict_strtoul(args[0].from, 16,
354 &entry->fsmagic);
355 if (!result)
356 entry->flags |= IMA_FSMAGIC;
357 break;
358 case Opt_uid:
Eric Paris2f1506c2010-04-20 10:21:30 -0400359 ima_log_string(ab, "uid", args[0].from);
Eric Paris7b62e162010-04-20 10:21:01 -0400360
361 if (entry->uid != -1) {
362 result = -EINVAL;
363 break;
364 }
365
Mimi Zohar4af46622009-02-04 09:07:00 -0500366 result = strict_strtoul(args[0].from, 10, &lnum);
367 if (!result) {
368 entry->uid = (uid_t) lnum;
369 if (entry->uid != lnum)
370 result = -EINVAL;
371 else
372 entry->flags |= IMA_UID;
373 }
374 break;
375 case Opt_obj_user:
Eric Paris2f1506c2010-04-20 10:21:30 -0400376 ima_log_string(ab, "obj_user", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500377 result = ima_lsm_rule_init(entry, args[0].from,
378 LSM_OBJ_USER,
379 AUDIT_OBJ_USER);
380 break;
381 case Opt_obj_role:
Eric Paris2f1506c2010-04-20 10:21:30 -0400382 ima_log_string(ab, "obj_role", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500383 result = ima_lsm_rule_init(entry, args[0].from,
384 LSM_OBJ_ROLE,
385 AUDIT_OBJ_ROLE);
386 break;
387 case Opt_obj_type:
Eric Paris2f1506c2010-04-20 10:21:30 -0400388 ima_log_string(ab, "obj_type", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500389 result = ima_lsm_rule_init(entry, args[0].from,
390 LSM_OBJ_TYPE,
391 AUDIT_OBJ_TYPE);
392 break;
393 case Opt_subj_user:
Eric Paris2f1506c2010-04-20 10:21:30 -0400394 ima_log_string(ab, "subj_user", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500395 result = ima_lsm_rule_init(entry, args[0].from,
396 LSM_SUBJ_USER,
397 AUDIT_SUBJ_USER);
398 break;
399 case Opt_subj_role:
Eric Paris2f1506c2010-04-20 10:21:30 -0400400 ima_log_string(ab, "subj_role", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500401 result = ima_lsm_rule_init(entry, args[0].from,
402 LSM_SUBJ_ROLE,
403 AUDIT_SUBJ_ROLE);
404 break;
405 case Opt_subj_type:
Eric Paris2f1506c2010-04-20 10:21:30 -0400406 ima_log_string(ab, "subj_type", args[0].from);
Mimi Zohar4af46622009-02-04 09:07:00 -0500407 result = ima_lsm_rule_init(entry, args[0].from,
408 LSM_SUBJ_TYPE,
409 AUDIT_SUBJ_TYPE);
410 break;
411 case Opt_err:
Eric Paris2f1506c2010-04-20 10:21:30 -0400412 ima_log_string(ab, "UNKNOWN", p);
Eric Parise9d393b2010-04-20 10:21:13 -0400413 result = -EINVAL;
Mimi Zohar4af46622009-02-04 09:07:00 -0500414 break;
415 }
416 }
Eric Paris7b62e162010-04-20 10:21:01 -0400417 if (!result && (entry->action == UNKNOWN))
Mimi Zohar4af46622009-02-04 09:07:00 -0500418 result = -EINVAL;
419
Eric Paris6ccd0452010-04-20 10:20:54 -0400420 audit_log_format(ab, "res=%d", !!result);
Mimi Zohar4af46622009-02-04 09:07:00 -0500421 audit_log_end(ab);
422 return result;
423}
424
425/**
426 * ima_parse_add_rule - add a rule to measure_policy_rules
427 * @rule - ima measurement policy rule
428 *
429 * Uses a mutex to protect the policy list from multiple concurrent writers.
Eric Paris6ccd0452010-04-20 10:20:54 -0400430 * Returns the length of the rule parsed, an error code on failure
Mimi Zohar4af46622009-02-04 09:07:00 -0500431 */
Eric Paris6ccd0452010-04-20 10:20:54 -0400432ssize_t ima_parse_add_rule(char *rule)
Mimi Zohar4af46622009-02-04 09:07:00 -0500433{
Mimi Zohar523979a2009-02-11 11:12:28 -0500434 const char *op = "update_policy";
Eric Paris6ccd0452010-04-20 10:20:54 -0400435 char *p;
Mimi Zohar4af46622009-02-04 09:07:00 -0500436 struct ima_measure_rule_entry *entry;
Eric Paris6ccd0452010-04-20 10:20:54 -0400437 ssize_t result, len;
Mimi Zohar4af46622009-02-04 09:07:00 -0500438 int audit_info = 0;
439
440 /* Prevent installed policy from changing */
441 if (ima_measure != &measure_default_rules) {
442 integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
443 NULL, op, "already exists",
444 -EACCES, audit_info);
445 return -EACCES;
446 }
447
448 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
449 if (!entry) {
450 integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
451 NULL, op, "-ENOMEM", -ENOMEM, audit_info);
452 return -ENOMEM;
453 }
454
455 INIT_LIST_HEAD(&entry->list);
456
Eric Paris6ccd0452010-04-20 10:20:54 -0400457 p = strsep(&rule, "\n");
458 len = strlen(p) + 1;
Eric Paris7233e3e2010-04-20 10:21:24 -0400459
460 if (*p == '#') {
461 kfree(entry);
462 return len;
463 }
464
Eric Paris6ccd0452010-04-20 10:20:54 -0400465 result = ima_parse_rule(p, entry);
Eric Paris7233e3e2010-04-20 10:21:24 -0400466 if (result) {
Mimi Zohar4af46622009-02-04 09:07:00 -0500467 kfree(entry);
Mimi Zohar523979a2009-02-11 11:12:28 -0500468 integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
469 NULL, op, "invalid policy", result,
470 audit_info);
Eric Paris7233e3e2010-04-20 10:21:24 -0400471 return result;
Mimi Zohar523979a2009-02-11 11:12:28 -0500472 }
Eric Paris7233e3e2010-04-20 10:21:24 -0400473
474 mutex_lock(&ima_measure_mutex);
475 list_add_tail(&entry->list, &measure_policy_rules);
476 mutex_unlock(&ima_measure_mutex);
477
478 return len;
Mimi Zohar4af46622009-02-04 09:07:00 -0500479}
480
481/* ima_delete_rules called to cleanup invalid policy */
James Morris64c61d82009-02-05 09:28:26 +1100482void ima_delete_rules(void)
Mimi Zohar4af46622009-02-04 09:07:00 -0500483{
484 struct ima_measure_rule_entry *entry, *tmp;
485
486 mutex_lock(&ima_measure_mutex);
487 list_for_each_entry_safe(entry, tmp, &measure_policy_rules, list) {
488 list_del(&entry->list);
489 kfree(entry);
490 }
491 mutex_unlock(&ima_measure_mutex);
492}