All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org, David Dgien <dgienda125@gmail.com>
Subject: Re: [PATCH] fixup! tlsf: Add tracking of added tlsf memory pools
Date: Fri, 11 Apr 2025 09:14:13 +0200	[thread overview]
Message-ID: <Z_jBRTDkCMP_swb5@pengutronix.de> (raw)
In-Reply-To: <20250410104625.2500755-1-a.fatoum@pengutronix.de>

On Thu, Apr 10, 2025 at 12:46:25PM +0200, Ahmad Fatoum wrote:
> tlsf: fix KASAN poisoning of TLSF pool
> 
> By poisoning all of the heap after the first malloc, new_pool_entry
> becomes a pointer to poisoned memory, which causes a KASAN error right
> away at startup.
> 
> Move the kasan_poison_shadow call directly after tlsf_add_pool to
> fix this.
> 
> Cc: David Dgien <dgienda125@gmail.com>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  common/tlsf_malloc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/common/tlsf_malloc.c b/common/tlsf_malloc.c
> index 4acf1c1c5071..6e9d48af26bb 100644
> --- a/common/tlsf_malloc.c
> +++ b/common/tlsf_malloc.c
> @@ -115,12 +115,12 @@ void *malloc_add_pool(void *mem, size_t bytes)
>  	if (!new_pool)
>  		return NULL;
>  
> +	kasan_poison_shadow(mem, bytes, KASAN_TAG_INVALID);
> +
>  	new_pool_entry = malloc(sizeof(*new_pool_entry));
>  	if (!new_pool_entry)
>  		return NULL;
>  
> -	kasan_poison_shadow(mem, bytes, KASAN_TAG_INVALID);
> -
>  	new_pool_entry->pool = new_pool;
>  	list_add(&new_pool_entry->list, &mem_pool_list);
>  
> -- 
> 2.39.5
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2025-04-11  7:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 10:46 [PATCH] fixup! tlsf: Add tracking of added tlsf memory pools Ahmad Fatoum
2025-04-11  7:14 ` Sascha Hauer [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=Z_jBRTDkCMP_swb5@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=dgienda125@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.