mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Johansen <john.johansen@canonical.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>
Cc: linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] apparmor: Use struct_size() helper in kmalloc()
Date: Wed, 26 Jan 2022 01:30:54 -0800	[thread overview]
Message-ID: <87f35305-324e-6f7a-69a6-710db05c6e7c@canonical.com> (raw)
In-Reply-To: <20220125015606.GA28243@embeddedor>

On 1/24/22 17:56, Gustavo A. R. Silva wrote:
> Make use of the struct_size() helper instead of an open-coded version,
> in order to avoid any potential type mistakes or integer overflows that,
> in the worst scenario, could lead to heap overflows.
> 
> Also, address the following sparse warnings:
> security/apparmor/lib.c:139:23: warning: using sizeof on a flexible structure
> 
> Link: https://github.com/KSPP/linux/issues/174
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

thanks, I have pulled this into my tree
Acked-by: John Johansen <john.johansen@canonical.com>

> ---
>  security/apparmor/lib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/security/apparmor/lib.c b/security/apparmor/lib.c
> index fa49b81eb54c..5eda003c0d45 100644
> --- a/security/apparmor/lib.c
> +++ b/security/apparmor/lib.c
> @@ -136,7 +136,7 @@ __counted char *aa_str_alloc(int size, gfp_t gfp)
>  {
>  	struct counted_str *str;
>  
> -	str = kmalloc(sizeof(struct counted_str) + size, gfp);
> +	str = kmalloc(struct_size(str, name, size), gfp);
>  	if (!str)
>  		return NULL;
>  


      reply	other threads:[~2022-01-26  9:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25  1:56 Gustavo A. R. Silva
2022-01-26  9:30 ` 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=87f35305-324e-6f7a-69a6-710db05c6e7c@canonical.com \
    --to=john.johansen@canonical.com \
    --cc=gustavoars@kernel.org \
    --cc=jmorris@namei.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®