Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933661AbYAaWBy (ORCPT ); Thu, 31 Jan 2008 17:01:54 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760826AbYAaWBq (ORCPT ); Thu, 31 Jan 2008 17:01:46 -0500 Received: from netops-testserver-3-out.sgi.com ([192.48.171.28]:39926 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757582AbYAaWBq (ORCPT ); Thu, 31 Jan 2008 17:01:46 -0500 Date: Thu, 31 Jan 2008 14:01:43 -0800 (PST) From: Christoph Lameter X-X-Sender: clameter@schroedinger.engr.sgi.com To: Andrea Arcangeli cc: Robin Holt , Avi Kivity , Izik Eidus , kvm-devel@lists.sourceforge.net, Peter Zijlstra , steiner@sgi.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, daniel.blueman@quadrics.com Subject: mmu_notifier: close hole in fork In-Reply-To: <20080131123118.GK7185@v2.random> Message-ID: References: <20080131045750.855008281@sgi.com> <20080131045812.785269387@sgi.com> <20080131123118.GK7185@v2.random> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1651 Lines: 46 Talking to Robin and Jack we found taht we still have a hole during fork. Fork may set a pte writeprotect. At that point the remote pte are not marked readonly(!). Remote writes may occur to pages that are marked readonly locally without this patch. mmu_notifier: Provide invalidate_range on fork On fork we change ptes in cow mappings to readonly. This means we must invalidate the ptes so that they are reestablished later with proper permission. Signed-off-by: Christoph Lameter --- mm/memory.c | 6 ++++++ 1 file changed, 6 insertions(+) Index: linux-2.6/mm/memory.c =================================================================== --- linux-2.6.orig/mm/memory.c 2008-01-31 13:42:35.000000000 -0800 +++ linux-2.6/mm/memory.c 2008-01-31 13:47:31.000000000 -0800 @@ -602,6 +602,9 @@ int copy_page_range(struct mm_struct *ds if (is_vm_hugetlb_page(vma)) return copy_hugetlb_page_range(dst_mm, src_mm, vma); + if (is_cow_mapping(vma->vm_flags)) + mmu_notifier(invalidate_range_begin, src_mm, addr, end, 0); + dst_pgd = pgd_offset(dst_mm, addr); src_pgd = pgd_offset(src_mm, addr); do { @@ -612,6 +615,9 @@ int copy_page_range(struct mm_struct *ds vma, addr, next)) return -ENOMEM; } while (dst_pgd++, src_pgd++, addr = next, addr != end); + + if (is_cow_mapping(vma->vm_flags)) + mmu_notifier(invalidate_range_end, src_mm, 0); return 0; } -- 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/