The patch titled mm: fix a race condition under SMC + COW has been added to the -mm tree. Its filename is mm-fix-a-race-condition-under-smc-cow.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: mm: fix a race condition under SMC + COW From: "Siddha, Suresh B" <suresh.b.siddha@xxxxxxxxx> Failing context is a multi threaded process context and the failing sequence is as follows. One thread T0 doing self modifying code on page X on processor P0 and another thread T1 doing COW (breaking the COW setup as part of just happened fork() in another thread T2) on the same page X on processor P1. T0 doing SMC can endup modifying the new page Y (allocated by the T1 doing COW on P1) but because of different I/D TLB's, P0 ITLB will not see the new mapping till the flush TLB IPI from P1 is received. During this interval, if T0 executes the code created by SMC it can result in an app error (as ITLB still points to old page X and endup executing the content in page X rather than using the content in page Y). Fix this issue by first clearing the PTE and flushing it, before updating it with new entry. Signed-off-by: Suresh Siddha <suresh.b.siddha@xxxxxxxxx> Acked-by: "David S. Miller" <davem@xxxxxxxxxxxxx> Cc: Hugh Dickins <hugh@xxxxxxxxxxx> Cc: Nick Piggin <nickpiggin@xxxxxxxxxxxx> Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- mm/memory.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff -puN mm/memory.c~mm-fix-a-race-condition-under-smc-cow mm/memory.c --- a/mm/memory.c~mm-fix-a-race-condition-under-smc-cow +++ a/mm/memory.c @@ -1585,7 +1585,14 @@ gotten: entry = mk_pte(new_page, vma->vm_page_prot); entry = maybe_mkwrite(pte_mkdirty(entry), vma); lazy_mmu_prot_update(entry); - ptep_establish(vma, address, page_table, entry); + /* + * Clear the pte entry and flush it first, before updating the + * pte with the new entry. This will avoid a race condition + * seen in the presence of one thread doing SMC and another + * thread doing COW. + */ + ptep_clear_flush(vma, address, page_table); + set_pte_at(mm, address, page_table, entry); update_mmu_cache(vma, address, entry); lru_cache_add_active(new_page); page_add_new_anon_rmap(new_page, vma, address); _ Patches currently in -mm which might be from suresh.b.siddha@xxxxxxxxx are origin.patch mm-fix-a-race-condition-under-smc-cow.patch sched-remove-unnecessary-sched-group-allocations.patch sched-remove-unnecessary-sched-group-allocations-fix.patch sched-introduce-child-field-in-sched_domain.patch sched-cleanup-sched_group-cpu_power-setup.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html