Skip to content

Commit 2b270e2

Browse files
GoodLuck612jrjohansen
authored andcommitted
security/apparmor: use kfree_sensitive() in unpack_secmark()
The unpack_secmark() function currently uses kfree() to release memory allocated for secmark structures and their labels. However, if a failure occurs after partially parsing secmark, sensitive data may remain in memory, posing a security risk. To mitigate this, replace kfree() with kfree_sensitive() for freeing secmark structures and their labels, aligning with the approach used in free_ruleset(). I am submitting this as an RFC to seek freedback on whether this change is appropriate and aligns with the subsystem's expectations. If confirmed to be helpful, I will send a formal patch. Signed-off-by: Zilin Guan <zilin@seu.edu.cn> Signed-off-by: John Johansen <john.johansen@canonical.com>
1 parent 3e45553 commit 2b270e2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

security/apparmor/policy_unpack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,8 @@ static bool unpack_secmark(struct aa_ext *e, struct aa_ruleset *rules)
599599
fail:
600600
if (rules->secmark) {
601601
for (i = 0; i < size; i++)
602-
kfree(rules->secmark[i].label);
603-
kfree(rules->secmark);
602+
kfree_sensitive(rules->secmark[i].label);
603+
kfree_sensitive(rules->secmark);
604604
rules->secmark_count = 0;
605605
rules->secmark = NULL;
606606
}

0 commit comments

Comments
 (0)