lkml.org 
[lkml]   [2006]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] Fix COW D-cache aliasing on fork
Ralf Baechle wrote:
> From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
>
> Problem:
>
> 1. There is a process containing two thread (T1 and T2). The
> thread T1 calls fork(). Then dup_mmap() function called on T1 context.
>
> static inline int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
> ...
> flush_cache_mm(current->mm);
> ... /* A */
> (write-protect all Copy-On-Write pages)
> ... /* B */
> flush_tlb_mm(current->mm);
> ...
>
> 2. When preemption happens between A and B (or on SMP kernel), the
> thread T2 can run and modify data on COW pages without page fault
> (modified data will stay in cache).
>
> 3. Some time after fork() completed, the thread T2 may cause a page
> fault by write-protect on a COW page.
>
> 4. Then data of the COW page will be copied to newly allocated
> physical page (copy_cow_page()). It reads data via kernel mapping.
> The kernel mapping can have different 'color' with user space
> mapping of the thread T2 (dcache aliasing). Therefore
> copy_cow_page() will copy stale data. Then the modified data in
> cache will be lost.

What about if you just flush the caches after write protecting all
COW pages? Would that work? Simpler? Better performance? (I don't know)

--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-10-19 19:49    [W:0.203 / U:0.360 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site