Skip to content

Commit 9ff8a61

Browse files
tyhicksmimizohar
authored andcommitted
ima: Have the LSM free its audit rule
Ask the LSM to free its audit rule rather than directly calling kfree(). Both AppArmor and SELinux do additional work in their audit_rule_free() hooks. Fix memory leaks by allowing the LSMs to perform necessary work. Fixes: b169424 ("ima: use the lsm policy update notifier") Signed-off-by: Tyler Hicks <[email protected]> Cc: Janne Karhunen <[email protected]> Cc: Casey Schaufler <[email protected]> Reviewed-by: Mimi Zohar <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 34e980b commit 9ff8a61

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

security/integrity/ima/ima.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ static inline void ima_free_modsig(struct modsig *modsig)
420420
#ifdef CONFIG_IMA_LSM_RULES
421421

422422
#define security_filter_rule_init security_audit_rule_init
423+
#define security_filter_rule_free security_audit_rule_free
423424
#define security_filter_rule_match security_audit_rule_match
424425

425426
#else
@@ -430,6 +431,10 @@ static inline int security_filter_rule_init(u32 field, u32 op, char *rulestr,
430431
return -EINVAL;
431432
}
432433

434+
static inline void security_filter_rule_free(void *lsmrule)
435+
{
436+
}
437+
433438
static inline int security_filter_rule_match(u32 secid, u32 field, u32 op,
434439
void *lsmrule)
435440
{

security/integrity/ima/ima_policy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static void ima_lsm_free_rule(struct ima_rule_entry *entry)
258258
int i;
259259

260260
for (i = 0; i < MAX_LSM_RULES; i++) {
261-
kfree(entry->lsm[i].rule);
261+
security_filter_rule_free(entry->lsm[i].rule);
262262
kfree(entry->lsm[i].args_p);
263263
}
264264
kfree(entry);

0 commit comments

Comments
 (0)