Re: [PATCH v9 28/69] mm/mmap: reorganize munmap to use maple states
From: Liam Howlett
Date: Mon Jun 06 2022 - 12:20:28 EST
* Qian Cai <quic_qiancai@xxxxxxxxxxx> [220606 08:09]:
> On Wed, May 04, 2022 at 01:13:53AM +0000, Liam Howlett wrote:
> > From: "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx>
> >
> > Remove __do_munmap() in favour of do_munmap(), do_mas_munmap(), and
> > do_mas_align_munmap().
> >
> > do_munmap() is a wrapper to create a maple state for any callers that have
> > not been converted to the maple tree.
> >
> > do_mas_munmap() takes a maple state to mumap a range. This is just a
> > small function which checks for error conditions and aligns the end of the
> > range.
> >
> > do_mas_align_munmap() uses the aligned range to mumap a range.
> > do_mas_align_munmap() starts with the first VMA in the range, then finds
> > the last VMA in the range. Both start and end are split if necessary.
> > Then the VMAs are removed from the linked list and the mm mlock count is
> > updated at the same time. Followed by a single tree operation of
> > overwriting the area in with a NULL. Finally, the detached list is
> > unmapped and freed.
> >
> > By reorganizing the munmap calls as outlined, it is now possible to avoid
> > extra work of aligning pre-aligned callers which are known to be safe,
> > avoid extra VMA lookups or tree walks for modifications.
> >
> > detach_vmas_to_be_unmapped() is no longer used, so drop this code.
> >
> > vm_brk_flags() can just call the do_mas_munmap() as it checks for
> > intersecting VMAs directly.
> >
> > Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>
> ...
..
> Running a syscall fuzzer for a while could trigger those.
Thanks.
>
> WARNING: CPU: 95 PID: 1329067 at mm/slub.c:3643 kmem_cache_free_bulk
> CPU: 95 PID: 1329067 Comm: trinity-c32 Not tainted 5.18.0-next-20220603 #137
> pstate: 10400009 (nzcV daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> pc : kmem_cache_free_bulk
> lr : mt_destroy_walk
> sp : ffff80005ed66bf0
Does your syscall fuzzer create a reproducer? This looks like arm64
and says 5.18.0-next-20220603 again. Was this bisected to the patch
above?
Regards,
Liam