aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap_xip.c
diff options
context:
space:
mode:
authorCarsten Otte <carsteno@de.ibm.com>2012-02-03 15:37:14 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-13 11:06:07 -0800
commitc713decb179258db83fd048c09ec55d521d864d4 (patch)
tree21af250aa052d081215e7ebfe16ebaa7420a2c52 /mm/filemap_xip.c
parent73632d80356dcadfcacc8e20a319850b112abb9b (diff)
downloadkernel_samsung_smdk4412-c713decb179258db83fd048c09ec55d521d864d4.zip
kernel_samsung_smdk4412-c713decb179258db83fd048c09ec55d521d864d4.tar.gz
kernel_samsung_smdk4412-c713decb179258db83fd048c09ec55d521d864d4.tar.bz2
mm/filemap_xip.c: fix race condition in xip_file_fault()
commit 99f02ef1f18631eb0a4e0ea0a3d56878dbcb4b90 upstream. Fix 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. [akpm@linux-foundation.org: use conventional (and consistent) comment layout] Reported-by: David Sadler <dsadler@us.ibm.com> Signed-off-by: Carsten Otte <cotte@de.ibm.com> Reported-by: Louis Alex Eisner <leisner@cs.ucsd.edu> Cc: Hugh Dickins <hughd@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm/filemap_xip.c')
-rw-r--r--mm/filemap_xip.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c
index 93356cd..dee9429 100644
--- a/mm/filemap_xip.c
+++ b/mm/filemap_xip.c
@@ -263,7 +263,12 @@ 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;