From: John Johansen <john.johansen@canonical.com>
To: Zilin Guan <zilin@seu.edu.cn>
Cc: paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com,
apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn
Subject: Re: [RFC PATCH] security/apparmor: use kfree_sensitive() in unpack_secmark()
Date: Mon, 28 Apr 2025 12:19:20 -0700 [thread overview]
Message-ID: <8fda1ea3-4349-4a15-a1ea-8c2c63d355e2@canonical.com> (raw)
In-Reply-To: <20250418045250.1262935-1-zilin@seu.edu.cn>
On 4/17/25 21:52, Zilin Guan wrote:
> 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>
sorry I am super behind on the backlog, I will get this in to my tree today
Acked-by: John Johansen <john.johansen@canonical.com>
> ---
> security/apparmor/policy_unpack.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
> index 992b74c50..610e09c76 100644
> --- a/security/apparmor/policy_unpack.c
> +++ b/security/apparmor/policy_unpack.c
> @@ -598,8 +598,8 @@ static bool unpack_secmark(struct aa_ext *e, struct aa_ruleset *rules)
> fail:
> if (rules->secmark) {
> for (i = 0; i < size; i++)
> - kfree(rules->secmark[i].label);
> - kfree(rules->secmark);
> + kfree_sensitive(rules->secmark[i].label);
> + kfree_sensitive(rules->secmark);
> rules->secmark_count = 0;
> rules->secmark = NULL;
> }
prev parent reply other threads:[~2025-04-28 19:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-18 4:52 Zilin Guan
2025-04-25 3:09 ` Zilin Guan
2025-04-28 19:19 ` John Johansen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8fda1ea3-4349-4a15-a1ea-8c2c63d355e2@canonical.com \
--to=john.johansen@canonical.com \
--cc=apparmor@lists.ubuntu.com \
--cc=jianhao.xu@seu.edu.cn \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
--cc=zilin@seu.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®