linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: linux-mm@kvack.org,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Mike Rapoport <rppt@linux.vnet.ibm.com>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Hillf Danton <hillf.zj@alibaba-inc.com>
Subject: Re: [PATCH 1/1] userfaultfd: shmem: handle coredumping in handle_userfault()
Date: Thu, 15 Jun 2017 15:58:49 -0700	[thread overview]
Message-ID: <20170615155849.c0bde2722026855dabe1c8b9@linux-foundation.org> (raw)
In-Reply-To: <20170615225231.GB11676@redhat.com>

On Fri, 16 Jun 2017 00:52:31 +0200 Andrea Arcangeli <aarcange@redhat.com> wrote:

> > Can we please get that description into the changelog so that others
> > can decide which kernel(s) need the fix?
> 
> Only 4.11 is affected, pre-4.11 anon memory holes are skipped in
> __get_user_pages by checking FOLL_DUMP explicitly against empty
> pagetables (mm/gup.c:no_page_table()).
> 
> Should I re-submit with this detail?

Is OK thanks, I updated the changelog and queued it for 4.12.


From: Andrea Arcangeli <aarcange@redhat.com>
Subject: userfaultfd: shmem: handle coredumping in handle_userfault()

Anon and hugetlbfs handle FOLL_DUMP set by get_dump_page() internally to
__get_user_pages().

shmem as opposed has no special FOLL_DUMP handling there so
handle_mm_fault() is invoked without mmap_sem and ends up calling
handle_userfault() that isn't expecting to be invoked without mmap_sem
held.

This makes handle_userfault() fail immediately if invoked through
shmem_vm_ops->fault during coredumping and solves the problem.

The side effect is a BUG_ON with no lock held triggered by the coredumping
process which exits.  Only 4.11 is affected, pre-4.11 anon memory holes
are skipped in __get_user_pages by checking FOLL_DUMP explicitly against
empty pagetables (mm/gup.c:no_page_table()).

It's zero cost as we already had a check for current->flags to prevent
futex to trigger userfaults during exit (PF_EXITING).

Link: http://lkml.kernel.org/r/20170615214838.27429-1-aarcange@redhat.com
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: <stable@vger.kernel.org>	[4.11+]

--
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>

      reply	other threads:[~2017-06-15 22:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15 21:48 Andrea Arcangeli
2017-06-15 21:54 ` Andrew Morton
2017-06-15 22:52   ` Andrea Arcangeli
2017-06-15 22:58     ` Andrew Morton [this message]

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=20170615155849.c0bde2722026855dabe1c8b9@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=aarcange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=hillf.zj@alibaba-inc.com \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=rppt@linux.vnet.ibm.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