Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752045Ab1BXFjw (ORCPT ); Thu, 24 Feb 2011 00:39:52 -0500 Received: from smtp-out.google.com ([74.125.121.67]:31594 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751537Ab1BXFjv (ORCPT ); Thu, 24 Feb 2011 00:39:51 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=date:from:x-x-sender:to:cc:subject:message-id:user-agent :mime-version:content-type; b=KPo51OptEL7ipbDeOik7dRFp8/6WufVMGTeOTp8lzm9wnnkZWZrNpfHM3RFQJxnDzB ANsOJysVqWD4syVrbMBg== Date: Wed, 23 Feb 2011 21:39:49 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@sister.anvils To: Andrew Morton cc: Linus Torvalds , Robert Swiecki , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] mm: fix possible cause of a page_mapped BUG Message-ID: User-Agent: Alpine 2.00 (LSU 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-System-Of-Record: true Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1606 Lines: 40 Robert Swiecki reported a BUG_ON(page_mapped) from a fuzzer, punching a hole with madvise(,, MADV_REMOVE). That path is under mutex, and cannot be explained by lack of serialization in unmap_mapping_range(). Reviewing the code, I found one place where vm_truncate_count handling should have been updated, when I switched at the last minute from one way of managing the restart_addr to another: mremap move changes the virtual addresses, so it ought to adjust the restart_addr. But rather than exporting the notion of restart_addr from memory.c, or converting to restart_pgoff throughout, simply reset vm_truncate_count to 0 to force a rescan if mremap move races with preempted truncation. We have no confirmation that this fixes Robert's BUG, but it is a fix that's worth making anyway. Signed-off-by: Hugh Dickins --- mm/mremap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- 2.6.38-rc6/mm/mremap.c 2011-01-18 22:04:56.000000000 -0800 +++ linux/mm/mremap.c 2011-02-23 15:29:52.000000000 -0800 @@ -94,9 +94,7 @@ static void move_ptes(struct vm_area_str */ mapping = vma->vm_file->f_mapping; spin_lock(&mapping->i_mmap_lock); - if (new_vma->vm_truncate_count && - new_vma->vm_truncate_count != vma->vm_truncate_count) - new_vma->vm_truncate_count = 0; + new_vma->vm_truncate_count = 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/