From: Harry Yoo <harry.yoo@oracle.com>
To: syzbot <syzbot+5272541ccbbb14e2ec30@syzkaller.appspotmail.com>
Cc: Liam.Howlett@oracle.com, akpm@linux-foundation.org,
david@kernel.org, jannh@google.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, lorenzo.stoakes@oracle.com, riel@surriel.com,
syzkaller-bugs@googlegroups.com, vbabka@suse.cz
Subject: Re: [syzbot] [mm?] KASAN: slab-use-after-free Read in folio_remove_rmap_ptes
Date: Sat, 27 Dec 2025 16:18:46 +0900 [thread overview]
Message-ID: <aU-IVkmsD1IN2joN@hyeyoo> (raw)
In-Reply-To: <aU5dA6qq-h-0XszI@hyeyoo>
On Fri, Dec 26, 2025 at 07:01:39PM +0900, Harry Yoo wrote:
> On Thu, Dec 25, 2025 at 11:48:22PM -0800, syzbot wrote:
> > Last potentially related work creation:
> > kasan_save_stack+0x33/0x60 mm/kasan/common.c:56
> > kasan_record_aux_stack+0xa7/0xc0 mm/kasan/generic.c:556
> > slab_free_hook mm/slub.c:2501 [inline]
> > slab_free mm/slub.c:6670 [inline]
> > kmem_cache_free+0x15e/0x770 mm/slub.c:6781
> > anon_vma_free mm/rmap.c:136 [inline]
> > __put_anon_vma+0x114/0x3a0 mm/rmap.c:2780
> > put_anon_vma include/linux/rmap.h:117 [inline]
> > unlink_anon_vmas+0x58a/0x820 mm/rmap.c:443
> > dontunmap_complete mm/mremap.c:1265 [inline]
>
> And then (potentially) it was freed due to MREMAP_DONTUNMAP.
> If it's correct, now we know when the refcount has been dropped to zero!
>
> In dontunmap_complete():
> > if (new_vma != vrm_vma && start == old_start && end == old_end)
> > unlink_anon_vmas(vrm->vma)
>
> It calls unlink_anon_vmas() on the old VMA if the new range is not
> merged into the old VMA.
>
> Hmm I'm having difficult time understanding how the commit 1583aa278f5
> ("mm: mremap: unlink anon_vmas when mremap with MREMAP_DONTUNMAP success")
> is supposed to work when the new range is merged into an existing
> VMA (that is not the old VMA itself).
>
> The merge will succeed only if the other VMA doesn't have anon_vma
> or it has the same anon_vma... which means we're reusing anon_vma
> of the old vma, but we're calling put_anon_vma() on it?
Hmm, no. I tried to write a repro but it didn't work because we free
an anon_vma only when its root rb node is empty.
Looks like I'm still missing something; How can it be empty
when it's actually in use?
--
Cheers,
Harry / Hyeonggon
next prev parent reply other threads:[~2025-12-27 7:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-26 7:48 syzbot
2025-12-26 10:01 ` Harry Yoo
2025-12-27 7:18 ` Harry Yoo [this message]
2025-12-31 8:50 ` Harry Yoo
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=aU-IVkmsD1IN2joN@hyeyoo \
--to=harry.yoo@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=riel@surriel.com \
--cc=syzbot+5272541ccbbb14e2ec30@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=vbabka@suse.cz \
/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