linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Johansen <john.johansen@canonical.com>
To: Danila Chernetsov <listdansp@mail.ru>
Cc: Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org
Subject: Re: [PATCH] apparmor: fix missing error check for rhashtable_insert_fast
Date: Sun, 9 Apr 2023 16:29:16 -0700	[thread overview]
Message-ID: <3dc8b96b-db8c-428f-fc70-4df0e11f0d60@canonical.com> (raw)
In-Reply-To: <20230404190549.18257-1-listdansp@mail.ru>

On 4/4/23 12:05, Danila Chernetsov wrote:
>   rhashtable_insert_fast() could return err value when memory allocation is
>   failed. but unpack_profile() do not check values and this always returns
>   success value. This patch just adds error check code.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: e025be0f26d5 ("apparmor: support querying extended trusted helper extra data")
> 
> Signed-off-by: Danila Chernetsov <listdansp@mail.ru>

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

thanks, I have pulled this into the apparmor tree


> ---
>   security/apparmor/policy_unpack.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
> index cf2ceec40b28..4d8adb21732c 100644
> --- a/security/apparmor/policy_unpack.c
> +++ b/security/apparmor/policy_unpack.c
> @@ -1046,8 +1046,13 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
>   				goto fail;
>   			}
>   
> -			rhashtable_insert_fast(profile->data, &data->head,
> -					       profile->data->p);
> +			if(rhashtable_insert_fast(profile->data, &data->head,
> +						profile->data->p)) {
> +				kfree_sensitive(data->key);
> +				kfree_sensitive(data);
> +				info = "failed to insert data to table";
> +				goto fail;
> +			}
>   		}
>   
>   		if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) {


      reply	other threads:[~2023-04-09 23:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-04 19:05 [PATCH] apparmor: fix missing error check for rhashtable_insert_fast Danila Chernetsov
2023-04-09 23:29 ` 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=3dc8b96b-db8c-428f-fc70-4df0e11f0d60@canonical.com \
    --to=john.johansen@canonical.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=listdansp@mail.ru \
    --cc=lvc-project@linuxtesting.org \
    --cc=paul@paul-moore.com \
    --cc=serge@hallyn.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 NNTP newsgroup(s).