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

Michal Hocko
2022-02-15T19:36:17Z

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?
--
Michal Hocko
SUSE Labs