[PATCH] ima: free the rule label list in ima_free_rule()

From: Cong Nguyen

Date: Fri Nov 27 2026 - 02:29:46 EST


ima_parse_rule() allocates entry->label as an option list, like
entry->keyrings, but ima_free_rule() only frees entry->keyrings. The label
list is leaked when a rule is freed, for example when a policy write
containing "label=" is rejected.

Free entry->label next to the keyrings list.

Fixes: 47d76a484050 ("IMA: limit critical data measurement based on a label")
Signed-off-by: Cong Nguyen <congnt264@xxxxxxxxx>
---
security/integrity/ima/ima_policy.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index 2dc1d93aa768..c3c4faa99f5f 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -410,6 +410,7 @@ static void ima_free_rule(struct ima_rule_entry *entry)
kfree(entry->fsname);
kfree(entry->fs_subtype);
ima_free_rule_opt_list(entry->keyrings);
+ ima_free_rule_opt_list(entry->label);
ima_lsm_free_rule(entry);
kfree(entry);
}
--
2.25.1