Linux-Security-Module Archive mirror
 help / color / mirror / Atom feed
From: John Johansen <john.johansen@canonical.com>
To: Fedor Pchelkin <pchelkin@ispras.ru>
Cc: Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	William Hua <william.hua@canonical.com>,
	apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org,
	Alexey Khoroshilov <khoroshilov@ispras.ru>,
	stable@vger.kernel.org
Subject: Re: [PATCH] apparmor: use kvfree_sensitive to free data->data
Date: Fri, 10 May 2024 08:36:28 -0700	[thread overview]
Message-ID: <2a9553a9-47b9-4eb9-ae55-a77bdd14e8c4@canonical.com> (raw)
In-Reply-To: <20240201142450.30510-1-pchelkin@ispras.ru>

On 2/1/24 06:24, Fedor Pchelkin wrote:
> Inside unpack_profile() data->data is allocated using kvmemdup() so it
> should be freed with the corresponding kvfree_sensitive().
> 
> Also add missing data->data release for rhashtable insertion failure path
> in unpack_profile().
> 
> Found by Linux Verification Center (linuxtesting.org).
> 
> Fixes: e025be0f26d5 ("apparmor: support querying extended trusted helper extra data")
> Cc: stable@vger.kernel.org
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>

Acked-by: John Johansen <john.johansen@canonical.com>

I have pulled this into my tree

> ---
>   security/apparmor/policy.c        | 2 +-
>   security/apparmor/policy_unpack.c | 1 +
>   2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
> index 957654d253dd..14df15e35695 100644
> --- a/security/apparmor/policy.c
> +++ b/security/apparmor/policy.c
> @@ -225,7 +225,7 @@ static void aa_free_data(void *ptr, void *arg)
>   {
>   	struct aa_data *data = ptr;
>   
> -	kfree_sensitive(data->data);
> +	kvfree_sensitive(data->data, data->size);
>   	kfree_sensitive(data->key);
>   	kfree_sensitive(data);
>   }
> diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
> index 5e578ef0ddff..75452acd0e35 100644
> --- a/security/apparmor/policy_unpack.c
> +++ b/security/apparmor/policy_unpack.c
> @@ -1071,6 +1071,7 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
>   
>   			if (rhashtable_insert_fast(profile->data, &data->head,
>   						   profile->data->p)) {
> +				kvfree_sensitive(data->data, data->size);
>   				kfree_sensitive(data->key);
>   				kfree_sensitive(data);
>   				info = "failed to insert data to table";


      reply	other threads:[~2024-05-10 15:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 14:24 [PATCH] apparmor: use kvfree_sensitive to free data->data Fedor Pchelkin
2024-05-10 15:36 ` 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=2a9553a9-47b9-4eb9-ae55-a77bdd14e8c4@canonical.com \
    --to=john.johansen@canonical.com \
    --cc=apparmor@lists.ubuntu.com \
    --cc=jmorris@namei.org \
    --cc=khoroshilov@ispras.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=paul@paul-moore.com \
    --cc=pchelkin@ispras.ru \
    --cc=serge@hallyn.com \
    --cc=stable@vger.kernel.org \
    --cc=william.hua@canonical.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).