Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761908AbXEKJIb (ORCPT ); Fri, 11 May 2007 05:08:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757414AbXEKJG7 (ORCPT ); Fri, 11 May 2007 05:06:59 -0400 Received: from ogre.sisk.pl ([217.79.144.158]:58480 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755598AbXEKJGz convert rfc822-to-8bit (ORCPT ); Fri, 11 May 2007 05:06:55 -0400 From: "Rafael J. Wysocki" To: Andrew Morton Subject: [PATCH 6/7] Freezer: Fix PF_NOFREEZE vs freezeable race Date: Fri, 11 May 2007 00:43:14 +0200 User-Agent: KMail/1.9.5 Cc: Gautham R Shenoy , Linus Torvalds , LKML , Oleg Nesterov , Pavel Machek , "Eric W. Biederman" References: <200705110035.32229.rjw@sisk.pl> In-Reply-To: <200705110035.32229.rjw@sisk.pl> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 8BIT Content-Disposition: inline Message-Id: <200705110043.15694.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1495 Lines: 43 From: Gautham R Shenoy This patch fixes the race pointed out by Oleg Nesterov. * Freezer marks a thread as freezeable. * The thread now marks itself PF_NOFREEZE, but it will be frozen on ? on calling try_to_freeze(). Thus the task is frozen, even though it doesn't ? want to. * Subsequent thaw_processes() will also fail to thaw the task since it is ? marked PF_NOFREEZE. Avoid this problem by checking the task's PF_NOFREEZE status in frozen_processes() before marking the task as frozen. Signed-off-by: Gautham R Shenoy Signed-off-by: Rafael J. Wysocki --- include/linux/freezer.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Index: linux-2.6/include/linux/freezer.h =================================================================== --- linux-2.6.orig/include/linux/freezer.h 2007-05-10 21:44:36.000000000 +0200 +++ linux-2.6/include/linux/freezer.h 2007-05-10 21:44:47.000000000 +0200 @@ -63,8 +63,10 @@ static inline int thaw_process(struct ta */ static inline void frozen_process(struct task_struct *p) { - p->flags |= PF_FROZEN; - wmb(); + if (!unlikely(p->flags & PF_NOFREEZE)) { + p->flags |= PF_FROZEN; + wmb(); + } clear_tsk_thread_flag(p, TIF_FREEZE); } - 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/