From: Ebru Akagunduz <ebru.akagunduz@gmail.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: dvyukov@google.com, akpm@linux-foundation.org, vbabka@suse.cz,
mgorman@techsingularity.net, hannes@cmpxchg.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
vegard.nossum@oracle.com, levinsasha928@gmail.com,
koct9i@gmail.com, ryabinin.a.a@gmail.com, gthelen@google.com,
suleiman@google.com, hughd@google.com, rientjes@google.com,
syzkaller@googlegroups.com, kcc@google.com, glider@google.com
Subject: Re: mm: use-after-free in collapse_huge_page
Date: Fri, 2 Sep 2016 15:50:25 +0300 [thread overview]
Message-ID: <20160902125025.GA5827@gmail.com> (raw)
In-Reply-To: <20160829124233.GA40092@black.fi.intel.com>
>
> @@ -898,13 +899,13 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm,
> /* do_swap_page returns VM_FAULT_RETRY with released mmap_sem */
> if (ret & VM_FAULT_RETRY) {
> down_read(&mm->mmap_sem);
> - if (hugepage_vma_revalidate(mm, address)) {
> + if (hugepage_vma_revalidate(mm, address, &vma)) {
> /* vma is no longer available, don't continue to swapin */
> trace_mm_collapse_huge_page_swapin(mm, swapped_in, referenced, 0);
> return false;
> }
> /* check if the pmd is still valid */
> - if (mm_find_pmd(mm, address) != pmd)
> + if (mm_find_pmd(mm, address) != pmd || vma != fe.vma)
> return false;
> }
> if (ret & VM_FAULT_ERROR) {
> @@ -923,7 +924,6 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm,
> static void collapse_huge_page(struct mm_struct *mm,
> unsigned long address,
> struct page **hpage,
> - struct vm_area_struct *vma,
> int node, int referenced)
> {
> pmd_t *pmd, _pmd;
> @@ -933,6 +933,7 @@ static void collapse_huge_page(struct mm_struct *mm,
> spinlock_t *pmd_ptl, *pte_ptl;
> int isolated = 0, result = 0;
> struct mem_cgroup *memcg;
> + struct vm_area_struct *vma;
> unsigned long mmun_start; /* For mmu_notifiers */
I could not realize, why we need to remove vma parameter and recreate it here?
> unsigned long mmun_end; /* For mmu_notifiers */
> gfp_t gfp;
> @@ -961,7 +962,7 @@ static void collapse_huge_page(struct mm_struct *mm,
> }
>
> down_read(&mm->mmap_sem);
And without fe.vma check, this patch seems work for me.
Andrea, I've just sent a fix patch for leaking mapped ptes.
Kind regards,
Ebru
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Ebru Akagunduz <ebru.akagunduz@gmail.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: dvyukov@google.com, akpm@linux-foundation.org, vbabka@suse.cz,
mgorman@techsingularity.net, hannes@cmpxchg.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
vegard.nossum@oracle.com, levinsasha928@gmail.com,
koct9i@gmail.com, ryabinin.a.a@gmail.com, gthelen@google.com,
suleiman@google.com, hughd@google.com, rientjes@google.com,
syzkaller@googlegroups.com, kcc@google.com, glider@google.com
Subject: Re: mm: use-after-free in collapse_huge_page
Date: Fri, 2 Sep 2016 15:50:25 +0300 [thread overview]
Message-ID: <20160902125025.GA5827@gmail.com> (raw)
In-Reply-To: <20160829124233.GA40092@black.fi.intel.com>
>
> @@ -898,13 +899,13 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm,
> /* do_swap_page returns VM_FAULT_RETRY with released mmap_sem */
> if (ret & VM_FAULT_RETRY) {
> down_read(&mm->mmap_sem);
> - if (hugepage_vma_revalidate(mm, address)) {
> + if (hugepage_vma_revalidate(mm, address, &vma)) {
> /* vma is no longer available, don't continue to swapin */
> trace_mm_collapse_huge_page_swapin(mm, swapped_in, referenced, 0);
> return false;
> }
> /* check if the pmd is still valid */
> - if (mm_find_pmd(mm, address) != pmd)
> + if (mm_find_pmd(mm, address) != pmd || vma != fe.vma)
> return false;
> }
> if (ret & VM_FAULT_ERROR) {
> @@ -923,7 +924,6 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm,
> static void collapse_huge_page(struct mm_struct *mm,
> unsigned long address,
> struct page **hpage,
> - struct vm_area_struct *vma,
> int node, int referenced)
> {
> pmd_t *pmd, _pmd;
> @@ -933,6 +933,7 @@ static void collapse_huge_page(struct mm_struct *mm,
> spinlock_t *pmd_ptl, *pte_ptl;
> int isolated = 0, result = 0;
> struct mem_cgroup *memcg;
> + struct vm_area_struct *vma;
> unsigned long mmun_start; /* For mmu_notifiers */
I could not realize, why we need to remove vma parameter and recreate it here?
> unsigned long mmun_end; /* For mmu_notifiers */
> gfp_t gfp;
> @@ -961,7 +962,7 @@ static void collapse_huge_page(struct mm_struct *mm,
> }
>
> down_read(&mm->mmap_sem);
And without fe.vma check, this patch seems work for me.
Andrea, I've just sent a fix patch for leaking mapped ptes.
Kind regards,
Ebru
next prev parent reply other threads:[~2016-09-02 12:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-28 10:42 mm: use-after-free in collapse_huge_page Dmitry Vyukov
2016-08-28 10:42 ` Dmitry Vyukov
2016-08-29 12:42 ` Kirill A. Shutemov
2016-08-29 12:42 ` Kirill A. Shutemov
2016-08-29 15:35 ` Andrea Arcangeli
2016-08-29 15:35 ` Andrea Arcangeli
2016-09-07 12:25 ` Kirill A. Shutemov
2016-09-07 12:25 ` Kirill A. Shutemov
2016-09-07 12:40 ` Andrea Arcangeli
2016-09-07 12:40 ` Andrea Arcangeli
2016-09-02 12:50 ` Ebru Akagunduz [this message]
2016-09-02 12:50 ` Ebru Akagunduz
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=20160902125025.GA5827@gmail.com \
--to=ebru.akagunduz@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=gthelen@google.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kcc@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=koct9i@gmail.com \
--cc=levinsasha928@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=rientjes@google.com \
--cc=ryabinin.a.a@gmail.com \
--cc=suleiman@google.com \
--cc=syzkaller@googlegroups.com \
--cc=vbabka@suse.cz \
--cc=vegard.nossum@oracle.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.