Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965106Ab1C3Vd3 (ORCPT ); Wed, 30 Mar 2011 17:33:29 -0400 Received: from mga14.intel.com ([143.182.124.37]:49299 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933271Ab1C3VIm (ORCPT ); Wed, 30 Mar 2011 17:08:42 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.63,270,1299484800"; d="scan'208";a="411278369" From: Andi Kleen References: <20110330203.501921634@firstfloor.org> In-Reply-To: <20110330203.501921634@firstfloor.org> To: hughd@google.com, torvalds@linux-foundation.org, ak@linux.intel.com, kerframil@gmail.com, gregkh@suse.de, linux-kernel@vger.kernel.org, stable@kernel.org, tim.bird@am.sony.com Subject: [PATCH] [177/275] mm: fix possible cause of a page_mapped BUG Message-Id: <20110330210700.17E2C3E1A05@tassilo.jf.intel.com> Date: Wed, 30 Mar 2011 14:07:00 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2083 Lines: 53 2.6.35-longterm review patch. If anyone has any objections, please let me know. ------------------ From: Hugh Dickins commit a3e8cc643d22d2c8ed36b9be7d9c9ca21efcf7f7 upstream. 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 Signed-off-by: Linus Torvalds Signed-off-by: Andi Kleen Cc: Kerin Millar Signed-off-by: Greg Kroah-Hartman --- mm/mremap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) Index: linux-2.6.35.y/mm/mremap.c =================================================================== --- linux-2.6.35.y.orig/mm/mremap.c 2011-03-29 22:50:52.769908168 -0700 +++ linux-2.6.35.y/mm/mremap.c 2011-03-29 23:03:01.920251035 -0700 @@ -91,9 +91,7 @@ */ 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/