linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: Do not call flush_cache_user_range with mmap_sem held
Date: Wed, 16 Nov 2011 23:50:24 +0000	[thread overview]
Message-ID: <20111116235024.GH9581@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CAOesGMhWxEKUe7C4A+Xqv3RjN_u1t4k8eHWSZE4qMoBPD9=1qw@mail.gmail.com>

On Wed, Nov 16, 2011 at 01:23:02PM -0800, Olof Johansson wrote:
> Agreed. Russell, please consider picking this up -- the bug is very
> real and it sounds like the objection is vague.

No, it isn't.  It's creating an unsafe situation.  If we're going to do
this, we might as well give up on architecture correctness because we're
throwing out locking correctness.

1. We look up the VMA.
2. We pass the VMA to the cache operation.
3. The cache operation dereferences the VMA to obtain the VMA flags.

If something else happens to modify the VMA (eg, a concurrent mremap or
munmap) then without locking, we could end up dereferencing something
that is no longer the VMA we thought we had.

Plus, consider that the VMA list is modifyable while the mmap_sem is not
held - do we really want to see the effects of having find_vma() being
preempted having loaded a vm_next pointer, another thread coming in,
modifying the VMA list (possibly deleting the next vma), that memory being
reallocated to something else, and then we resume and fall off the VMA
list and possibly OOPS because we've accessed what we thought was the
next vm_next pointer but it wasn't?

While we can say "an application should not do that" that's not a reason
to ignore this problem and just delete all the locking in the hope that
we'll always have well behaving applications.

So, it's *totally* unsafe to delete the locking here.

The requirement is that the mmap_sem must be held while you expect to
hold any reference to a vm_area_struct.  There's no exceptions to that.

One solution to this is to use pagefault_disable()...pagefault_enable()
around the cache operation, so that faults just cause us to skip to the
next page.  The down-side to that is that pagefault_disable() makes us
non-preemptible while performing the cache operation.  However, we can
work around that by performing the cache handling in appropriately sized
chunks.

  reply	other threads:[~2011-11-16 23:50 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-07 17:33 [PATCH] ARM: Do not call flush_cache_user_range with mmap_sem held Catalin Marinas
2011-11-16 21:23 ` Olof Johansson
2011-11-16 23:50   ` Russell King - ARM Linux [this message]
2011-11-17  0:16     ` Olof Johansson
2011-11-17  0:20       ` Olof Johansson
2011-11-17 10:26       ` Catalin Marinas
2011-11-17 10:49         ` Russell King - ARM Linux
2011-11-17 10:45       ` Russell King - ARM Linux
2011-11-20 17:54         ` Olof Johansson
2011-11-17 10:22     ` Catalin Marinas
2011-11-17 10:42       ` Russell King - ARM Linux
2011-11-17 10:59         ` Catalin Marinas
2011-11-17 11:03           ` Russell King - ARM Linux
2011-11-17 11:25             ` Catalin Marinas
2012-04-09  5:58               ` Dirk Behme
2012-04-09 14:24                 ` Olof Johansson
2012-04-10 17:17                   ` Will Deacon
2012-04-18 15:05                     ` Will Deacon
2012-04-18 15:27                       ` Russell King - ARM Linux
2012-04-18 16:27                         ` Will Deacon
2012-04-18 17:15                         ` Catalin Marinas
2012-04-18  8:40                   ` Catalin Marinas
  -- strict thread matches above, loose matches on Subject: below --
2010-04-28  7:32 [PATCH] [ARM] " Dima Zavin
2010-04-28  7:35 ` Dima Zavin
2010-04-29 13:00 ` Russell King - ARM Linux
2010-04-29 18:16   ` Jamie Lokier
2010-04-29 18:24     ` Russell King - ARM Linux
2010-04-29 19:23       ` Dima Zavin
2010-05-04  4:07         ` Dima Zavin
2010-05-04  7:40           ` Russell King - ARM Linux
2010-05-06 15:08 ` Catalin Marinas

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=20111116235024.GH9581@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.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).