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

From: Roberto Sassu

Date: Wed Dec 02 2026 - 06:51:23 EST


On Fri, 2026-11-27 at 14:29 +0700, Cong Nguyen wrote:
> 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>

Reviewed-by: Roberto Sassu <roberto.sassu@xxxxxxxxxx>

Thanks

Roberto

> ---
> 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);
> }