From: Carsten Otte <carsteno@de.ibm.com>
To: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org, npiggin@suse.de
Cc: jaredeh@gmail.com, Martin Schwidefsky <schwidefsky@de.ibm.com>,
stable@kernel.org
Subject: [PATCH mm/filemap_xip.c] Fix race condition in xip_file_fault
Date: Thu, 15 Jul 2010 18:20:24 +0200 [thread overview]
Message-ID: <4C3F3548.8010708@de.ibm.com> (raw)
Reported-by: David Sadler <dsadler@us.ibm.com>
This patch fixes a race condition that shows in conjunction with
xip_file_fault
when two threads of the same user process fault on the same memory page.
In this
case, the race winner will install the page table entry, and the unlucky
loser
will cause an oops:
xip_file_fault calls vm_insert_pfn (via vm_insert_mixed) which drops out at
this check:
retval = -EBUSY;
if (!pte_none(*pte))
goto out_unlock;
The resulting -EBUSY return value will trigger a BUG_ON() in xip_file_fault.
This fix simply considers the fault as fixed in this case, because the
race winner has successfully installed the pte.
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
---
mm/filemap_xip.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/mm/filemap_xip.c
+++ b/mm/filemap_xip.c
@@ -263,7 +263,10 @@ found:
xip_pfn);
if (err == -ENOMEM)
return VM_FAULT_OOM;
- BUG_ON(err);
+ /* err == -EBUSY is fine, we've raced against another thread
+ that faulted-in the same page */
+ if (err != -EBUSY)
+ BUG_ON(err);
return VM_FAULT_NOPAGE;
} else {
int err, ret = VM_FAULT_OOM;
--
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:[~2010-07-15 16:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4C3F3548.8010708@de.ibm.com \
--to=carsteno@de.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=jaredeh@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=npiggin@suse.de \
--cc=schwidefsky@de.ibm.com \
--cc=stable@kernel.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).