From: Dmitry Vyukov <dvyukov@google.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Andrew Morton <akpm@linux-foundation.org>,
syzbot <syzbot+b437b5a429d680cf2217@syzkaller.appspotmail.com>,
"Darrick J. Wong" <darrick.wong@oracle.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Hugh Dickins <hughd@google.com>, Jan Kara <jack@suse.cz>,
josef@toxicpanda.com, Souptick Joarder <jrdr.linux@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux-MM <linux-mm@kvack.org>,
Stephen Rothwell <sfr@canb.auug.org.au>,
syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
Matthew Wilcox <willy@infradead.org>
Subject: Re: KASAN: use-after-free Read in filemap_fault
Date: Sat, 29 Dec 2018 07:38:08 +0100 [thread overview]
Message-ID: <CACT4Y+Ynm+LPupT0OM=E8AdF0bQDKc-arPy3M=V1D5V0tCmZ=g@mail.gmail.com> (raw)
Message-ID: <20181229063808.pSdyjRPwDaOwyPSO5Z7Xob0SwoqeBDGO7YW1g4Oc0eg@z> (raw)
In-Reply-To: <20181228235106.okk3oastsnpxusxs@kshutemo-mobl1>
On Sat, Dec 29, 2018 at 12:51 AM Kirill A. Shutemov
<kirill@shutemov.name> wrote:
>
> On Fri, Dec 28, 2018 at 01:09:38PM -0800, Andrew Morton wrote:
> > On Fri, 28 Dec 2018 12:51:04 -0800 syzbot <syzbot+b437b5a429d680cf2217@syzkaller.appspotmail.com> wrote:
> >
> > > Hello,
> > >
> > > syzbot found the following crash on:
> >
> > uh-oh. Josef, could you please take a look?
> >
> > : page = find_get_page(mapping, offset);
> > : if (likely(page) && !(vmf->flags & FAULT_FLAG_TRIED)) {
> > : /*
> > : * We found the page, so try async readahead before
> > : * waiting for the lock.
> > : */
> > : fpin = do_async_mmap_readahead(vmf, page);
> > : } else if (!page) {
> > : /* No page in the page cache at all */
> > : fpin = do_sync_mmap_readahead(vmf);
> > : count_vm_event(PGMAJFAULT);
> > : count_memcg_event_mm(vmf->vma->vm_mm, PGMAJFAULT);
> >
> > vmf->vma has been freed at this point.
> >
> > : ret = VM_FAULT_MAJOR;
> > : retry_find:
> > : page = pagecache_get_page(mapping, offset,
> > : FGP_CREAT|FGP_FOR_MMAP,
> > : vmf->gfp_mask);
> > : if (!page) {
> > : if (fpin)
> > : goto out_retry;
> > : return vmf_error(-ENOMEM);
> > : }
> > : }
> >
>
> Here's a fixup for "filemap: drop the mmap_sem for all blocking operations".
If you are going to squash this, please add:
Tested-by: syzbot+b437b5a429d680cf2217@syzkaller.appspotmail.com
> do_sync_mmap_readahead() drops mmap_sem now, so by the time of
> dereferencing vmf->vma for count_memcg_event_mm() the VMA can be gone.
>
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 00a9315f45d4..65c85c47bdb1 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2554,10 +2554,10 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
> fpin = do_async_mmap_readahead(vmf, page);
> } else if (!page) {
> /* No page in the page cache at all */
> - fpin = do_sync_mmap_readahead(vmf);
> count_vm_event(PGMAJFAULT);
> count_memcg_event_mm(vmf->vma->vm_mm, PGMAJFAULT);
> ret = VM_FAULT_MAJOR;
> + fpin = do_sync_mmap_readahead(vmf);
> retry_find:
> page = pagecache_get_page(mapping, offset,
> FGP_CREAT|FGP_FOR_MMAP,
> --
> Kirill A. Shutemov
>
> --
> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/20181228235106.okk3oastsnpxusxs%40kshutemo-mobl1.
> For more options, visit https://groups.google.com/d/optout.
next prev parent reply other threads:[~2018-12-29 6:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-28 20:51 KASAN: use-after-free Read in filemap_fault syzbot
2018-12-28 20:51 ` syzbot
2018-12-28 21:09 ` Andrew Morton
2018-12-28 23:51 ` Kirill A. Shutemov
2018-12-29 6:38 ` Dmitry Vyukov [this message]
2018-12-29 6:38 ` Dmitry Vyukov
2018-12-28 22:01 ` Kirill A. Shutemov
2018-12-28 22:08 ` Kirill A. Shutemov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACT4Y+Ynm+LPupT0OM=E8AdF0bQDKc-arPy3M=V1D5V0tCmZ=g@mail.gmail.com' \
--to=dvyukov@google.com \
--cc=akpm@linux-foundation.org \
--cc=darrick.wong@oracle.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=jack@suse.cz \
--cc=josef@toxicpanda.com \
--cc=jrdr.linux@gmail.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sfr@canb.auug.org.au \
--cc=syzbot+b437b5a429d680cf2217@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).