From: nfortino@nvidia.com (Nickolas Fortino)
To: linux-arm-kernel@lists.infradead.org
Subject: preempted dup_mm misses TLB invalidate
Date: Mon, 15 Jul 2013 11:19:23 -0700 [thread overview]
Message-ID: <51E43D2B.9090709@nvidia.com> (raw)
I?ve noticed an issue in simulation where the Linux kernel is executing
a user process when the page tables and TLBs have gotten out of sync.
The page tables have a page marked as user read only, but the TLB has
the page marked as user read/write.
I?ve traced the issue back to the handling of copy on write pages
generated from the ?do_fork?, ?copy_process?, ?dup_mm?, ?dup_mmap? call
stack. If run without interruption, ?dup_mmap? calls
?flush_tlb_mm(oldmm)? on completion, avoiding any issues. In this case,
however, about 4 million instructions after ?dup_mm? is called,
?copy_pte_range? yields to another thread via __cond_resched. About 20
million instructions later, a user process with the ASID of the source
mm is scheduled. This process performs a store to a page modified from
read/write to read only in the copy on write logic of ?copy_one_pte?.
Because the TLB was not invalidated, the store hits on a TLB entry with
read/write permissions and succeeds without a fault.
What invariant in the Linux kernel is supposed to prevent this from
happening? Note I have not observed user visible corruption, but it
seems very unlikely a successful store to a page marked as read only in
the kernel is safe.
For reference, this issue was found with the Linux 3.7 kernel coming
from the Linaro 12.12 release available at
http://releases.linaro.org/12.12/android/vexpress
next reply other threads:[~2013-07-15 18:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-15 18:19 Nickolas Fortino [this message]
2013-07-17 19:27 ` preempted dup_mm misses TLB invalidate Catalin Marinas
2013-07-17 19:52 ` Stephen Warren
2013-07-17 20:01 ` Russell King - ARM Linux
2013-07-17 20:11 ` Stephen Warren
2013-07-17 20:09 ` Nickolas Fortino
2013-07-17 20:34 ` Russell King - ARM Linux
2013-07-17 21:03 ` Nickolas Fortino
2013-07-17 21:21 ` Russell King - ARM Linux
2013-07-18 1:48 ` Nickolas Fortino
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=51E43D2B.9090709@nvidia.com \
--to=nfortino@nvidia.com \
--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 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.