tux3: Support mmap write: Fix race of mmap write with write(2) on delta boundary

Clear writable to protect oldpage from following mmap write race.

       cpu0                          cpu1                   cpu2
                                                          [mmap write]
                                                          mmap write(old)
                                                              page fault
                                    [backend]                 dirty old
                                    delta++
   [page_fault]
   page fork
       [*A]
                                                          mmap write(old)
                                                              no page fault
       copy_page(new, old)                                    modify page
       replace_pte(new, old)
                                    flusher
                                    page_mkclean(old)

There is delay between delta++ and page_mkclean() for I/O. So,
while cpu0 copying data on page by pagefork, another cpu (cpu2)
can change data on the same page. If this race happens, new and old
page can have different data.

To fix this race, we should make PTE read-only before start pagefork
at [*A] place.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
1 file changed