Re: [syzbot] KASAN: use-after-free Read in __oom_reap_task_mm

Suren Baghdasaryan
2022-02-15T20:30:27Z

On Tue, Feb 15, 2022 at 11:43 AM Suren Baghdasaryan <surenb@google.com> wrote:
>
> On Tue, Feb 15, 2022 at 11:36 AM Michal Hocko <mhocko@suse.com> wrote:
> >
> > On Tue 15-02-22 10:10:53, Suren Baghdasaryan wrote:
> > > On Tue, Feb 15, 2022 at 9:53 AM Yang Shi <shy828301@gmail.com> wrote:
> > [...]
> > > > Isn't the below race possible?
> > > >
> > > > CPU A CPU B
> > > > exiting:
> > > > mmap_write_lock
> > > > remove_vma()
> > > > mmap_write_unlock
> > > > process_mrelease:
> > > > mmap_read_lock
> > > > __oom_reap_task_mm
> > > > mmap_read_unlock
> > > >
> > >
> > > Sure, that sequence (would not call it a race) is possible but in this
> > > case __oom_reap_task_mm will find no vmas in the mm because exit_mmap
> > > freed and removed all of them.
> >
> > I didn't really have chance to have a closer look but I do not see
> > exit_mmap doing mm->mmap = NULL so the pointer can be a freed vma unless
> > I am missing something. I thought we've had it in your patches? Has this
> > got lost somewhere in the process?
>
> Doh! Yes, it looks like I completely missed the actual pointer. That
> must be it since I don't see any other possibility. Will post a patch
> shortly.

Fix posted at https://lore.kernel.org/all/20220215201922.1908156-1-surenb@google.com/

> Thanks!
>
> > --
> > Michal Hocko
> > SUSE Labs