linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Deepanshu Kartikey <kartikey406@gmail.com>,
	akpm@linux-foundation.org, cl@gentwo.org, rientjes@google.com,
	roman.gushchin@linux.dev, harry.yoo@oracle.com, ast@kernel.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	syzbot+7a25305a76d872abcfa1@syzkaller.appspotmail.com
Subject: Re: [PATCH] mm/slub: reset KASAN tag in defer_free() before accessing freed memory
Date: Wed, 10 Dec 2025 13:58:02 +0100	[thread overview]
Message-ID: <aaf80bb6-ad8a-4d11-b8bf-a91168ae6a08@suse.cz> (raw)
In-Reply-To: <20251210022024.3255826-1-kartikey406@gmail.com>

On 12/10/25 03:20, Deepanshu Kartikey wrote:
> When CONFIG_SLUB_TINY is enabled, kfree_nolock() calls kasan_slab_free()
> before defer_free(). On ARM64 with MTE (Memory Tagging Extension),
> kasan_slab_free() poisons the memory and changes the tag from the
> original (e.g., 0xf3) to a poison tag (0xfe).
> 
> When defer_free() then tries to write to the freed object to build the
> deferred free list via llist_add(), the pointer still has the old tag,
> causing a tag mismatch and triggering a KASAN use-after-free report:
> 
>   BUG: KASAN: slab-use-after-free in defer_free+0x3c/0xbc mm/slub.c:6537
>   Write at addr f3f000000854f020 by task kworker/u8:6/983
>   Pointer tag: [f3], memory tag: [fe]
> 
> Fix this by calling kasan_reset_tag() before accessing the freed memory.
> This is safe because defer_free() is part of the allocator itself and is
> expected to manipulate freed memory for bookkeeping purposes.
> 
> Fixes: af92793e52c3 ("slab: Introduce kmalloc_nolock() and kfree_nolock().")
> Reported-by: syzbot+7a25305a76d872abcfa1@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=7a25305a76d872abcfa1
> Tested-by: syzbot+7a25305a76d872abcfa1@syzkaller.appspotmail.com
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>

Thanks, added cc: stable and pushed to slab/for-next-fixes

> ---
>  mm/slub.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index e6a330e24145..46959c6da2cf 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -6534,6 +6534,8 @@ static void defer_free(struct kmem_cache *s, void *head)
>  
>  	guard(preempt)();
>  
> +	head = kasan_reset_tag(head);
> +
>  	df = this_cpu_ptr(&defer_free_objects);
>  	if (llist_add(head + s->offset, &df->objects))
>  		irq_work_queue(&df->work);



      parent reply	other threads:[~2025-12-10 12:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-10  2:20 Deepanshu Kartikey
2025-12-10  7:05 ` Alexei Starovoitov
2025-12-10 12:58 ` Vlastimil Babka [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=aaf80bb6-ad8a-4d11-b8bf-a91168ae6a08@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=cl@gentwo.org \
    --cc=harry.yoo@oracle.com \
    --cc=kartikey406@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=syzbot+7a25305a76d872abcfa1@syzkaller.appspotmail.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