Re: KASAN: use-after-free Read in do_madvise

From: Andrew Morton
Date: Fri Aug 21 2020 - 16:03:41 EST


On Fri, 21 Aug 2020 10:15:45 -0700 Yang Shi <shy828301@xxxxxxxxx> wrote:

> It looks the vma is gone. The below patch should be able to fix it:
>
> diff --git a/mm/madvise.c b/mm/madvise.c
> index dd1d43cf026d..d4aa5f776543 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
> @@ -289,9 +289,9 @@ static long madvise_willneed(struct vm_area_struct *vma,
> */
> *prev = NULL; /* tell sys_madvise we drop mmap_lock */
> get_file(file);
> - mmap_read_unlock(current->mm);
> offset = (loff_t)(start - vma->vm_start)
> + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
> + mmap_read_unlock(current->mm);
> vfs_fadvise(file, offset, end - start, POSIX_FADV_WILLNEED);
> fput(file);
> mmap_read_lock(current->mm);

Oh geeze. Can you please send this along as a real patch, cc:stable,
Fixes: 692fe62433d4c? Please cc Jan!