linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Jan Stancek <jstancek@redhat.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
	peterz@infradead.org, riel@surriel.com, mhocko@suse.com,
	ying.huang@intel.com, jrdr.linux@gmail.com, jglisse@redhat.com,
	aneesh.kumar@linux.ibm.com, david@redhat.com,
	aarcange@redhat.com, raquini@redhat.com, rientjes@google.com,
	kirill@shutemov.name, mgorman@techsingularity.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/memory.c: do_fault: avoid usage of stale vm_area_struct
Date: Sat, 2 Mar 2019 09:10:43 -0800	[thread overview]
Message-ID: <20190302171043.GP11592@bombadil.infradead.org> (raw)
In-Reply-To: <0b7a4604529e16ace8d65a42dac7c78582e7fb28.1551538524.git.jstancek@redhat.com>

On Sat, Mar 02, 2019 at 04:11:26PM +0100, Jan Stancek wrote:
> Problem is that "vmf->vma" used in do_fault() can become stale.
> Because mmap_sem may be released, other threads can come in,
> call munmap() and cause "vma" be returned to kmem cache, and
> get zeroed/re-initialized and re-used:

> This patch pins mm_struct and stores its value, to avoid using
> potentially stale "vma" when calling pte_free().

OK, we need to cache the mm_struct, but why do we need the extra atomic op?
There's surely no way the mm can be freed while the thread is in the middle
of handling a fault.

ie I would drop these lines:

> +	mmgrab(vm_mm);
> +
...
> +
> +	mmdrop(vm_mm);
> +


  reply	other threads:[~2019-03-02 17:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-02 15:11 [PATCH] mm/memory.c: do_fault: avoid usage of stale vm_area_struct Jan Stancek
2019-03-02 17:10 ` Matthew Wilcox [this message]
2019-03-02 18:00   ` Jan Stancek
2019-03-02 18:19   ` [PATCH v2] " Jan Stancek
2019-03-02 18:45     ` Peter Zijlstra
2019-03-02 18:51     ` Andrea Arcangeli
2019-03-03  7:27       ` Jan Stancek
2019-03-03  7:28       ` [PATCH v3] " Jan Stancek
2019-03-03 10:36         ` Matthew Wilcox
2019-03-04  0:13         ` Rafael Aquini
2019-03-04  8:10         ` Minchan Kim
2019-03-04  8:19         ` 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=20190302171043.GP11592@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=jglisse@redhat.com \
    --cc=jrdr.linux@gmail.com \
    --cc=jstancek@redhat.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=peterz@infradead.org \
    --cc=raquini@redhat.com \
    --cc=riel@surriel.com \
    --cc=rientjes@google.com \
    --cc=ying.huang@intel.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 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).