From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx133.postini.com [74.125.245.133]) by kanga.kvack.org (Postfix) with SMTP id 7C9A16B004A for ; Wed, 29 Feb 2012 15:31:22 -0500 (EST) Date: Wed, 29 Feb 2012 12:31:20 -0800 From: Andrew Morton Subject: Re: [RFC][PATCH] fix move/migrate_pages() race on task struct Message-Id: <20120229123120.127e21fd.akpm@linux-foundation.org> In-Reply-To: References: <20120223180740.C4EC4156@kernel> <4F468F09.5050200@linux.vnet.ibm.com> <4F469BC7.50705@linux.vnet.ibm.com> <4F47BF56.6010602@linux.vnet.ibm.com> <4F47C800.4090903@linux.vnet.ibm.com> <87sjhzun47.fsf@xmission.com> <87d390janv.fsf@xmission.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Christoph Lameter Cc: "Eric W. Biederman" , Dave Hansen , linux-kernel@vger.kernel.org, linux-mm@kvack.org On Tue, 28 Feb 2012 13:30:19 -0600 (CST) Christoph Lameter wrote: > Migration functions perform the rcu_read_unlock too early. As a result the > task pointed to may change from under us. > > The following patch extend the period of the rcu_read_lock until after the > permissions checks are done. We also take a refcount so that the task > reference is stable when calling security check functions and performing > cpuset node validation (which takes a mutex). > > The refcount is dropped before actual page migration occurs so there is no > change to the refcounts held during page migration. > > Also move the determination of the mm of the task struct to immediately > before the do_migrate*() calls so that it is clear that we switch from > handling the task during permission checks to the mm for the actual > migration. Since the determination is only done once and we then no longer > use the task_struct we can be sure that we operate on a specific address > space that will not change from under us. What was the user-visible impact of the bug? Please always include info this in bug fix changelogs - it helps me and others to decide which kernel version(s) the patch should be merged into. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org