[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zh4AJiHFQBkD1J_F@casper.infradead.org>
Date: Tue, 16 Apr 2024 05:35:50 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Vishal Moola <vishal.moola@...il.com>
Cc: syzbot <syzbot+ad1b592fc4483655438b@...kaller.appspotmail.com>,
akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, muchun.song@...ux.dev,
syzkaller-bugs@...glegroups.com
Subject: Re: [syzbot] [mm?] KASAN: slab-use-after-free Read in
__vma_reservation_common
On Mon, Apr 15, 2024 at 04:02:48PM -0700, Vishal Moola wrote:
> On Mon, Apr 15, 2024 at 3:15 PM Matthew Wilcox <willy@...radead.org> wrote:
> >
> > On Mon, Apr 15, 2024 at 03:05:44PM -0700, Vishal Moola wrote:
> > > Commit 9acad7ba3e25 ("hugetlb: use vmf_anon_prepare() instead of
> > > anon_vma_prepare()") may bailout after allocating a folio if we do not
> > > hold the mmap lock. When this occurs, vmf_anon_prepare() will release the
> > > vma lock. Hugetlb then attempts to call restore_reserve_on_error(),
> > > which depends on the vma lock being held.
> > >
> > > We can move vmf_anon_prepare() prior to the folio allocation in order to
> > > avoid calling restore_reserve_on_error() without the vma lock.
> >
> > But now you're calling vmf_anon_prepare() in the wrong place -- before
> > we've determined that we need an anon folio. So we'll create an
> > anon_vma even when we don't need one for this vma.
>
> That's true. Though that can be addressed through something like:
>
> if (!(vma->vm_flags & VM_MAYSHARE)) {
> ret = vmf_anon_prepare(vmf);
> if (unlikely(ret))
> goto out;
> }
Why does hugetlbfs use VM_MAYSHARE while regular faults use VM_SHARED?
Powered by blists - more mailing lists