Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753072AbZI2DL2 (ORCPT ); Mon, 28 Sep 2009 23:11:28 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752803AbZI2DL1 (ORCPT ); Mon, 28 Sep 2009 23:11:27 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:59538 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752707AbZI2DL1 (ORCPT ); Mon, 28 Sep 2009 23:11:27 -0400 X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.3.1 Date: Tue, 29 Sep 2009 12:09:08 +0900 From: KAMEZAWA Hiroyuki To: Li Zefan Cc: linux-kernel@vger.kernel.org, "akpm@linux-foundation.org" , mingo@elte.hu, "balbir@linux.vnet.ibm.com" , "nishimura@mxp.nes.nec.co.jp" , "menage@google.com" Subject: [PATCH][rc1] cgroup: catch bad css refcnt at css_put v2 Message-Id: <20090929120908.cf3147ae.kamezawa.hiroyu@jp.fujitsu.com> In-Reply-To: <4AC159D9.8020900@cn.fujitsu.com> References: <200909252158.n8PLwFhG024011@imap1.linux-foundation.org> <20090928154213.8e873dec.kamezawa.hiroyu@jp.fujitsu.com> <20090928180649.b6b7eea9.kamezawa.hiroyu@jp.fujitsu.com> <20090928181310.9492a8a2.kamezawa.hiroyu@jp.fujitsu.com> <4AC159D9.8020900@cn.fujitsu.com> Organization: FUJITSU Co. LTD. X-Mailer: Sylpheed 2.5.0 (GTK+ 2.10.14; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1374 Lines: 43 __css_put() doesn't check a buggy case as refcnt goes to minus. This patch adds a check for it. Changelog: - using WARN_ON_ONCE() instead of WARN_ON() Acked-by: Paul Menage Acked-by: Li Zefan Signed-off-by: KAMEZAWA Hiroyuki --- kernel/cgroup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) Index: linux-2.6.32-rc1/kernel/cgroup.c =================================================================== --- linux-2.6.32-rc1.orig/kernel/cgroup.c +++ linux-2.6.32-rc1/kernel/cgroup.c @@ -3708,8 +3708,10 @@ static void check_for_release(struct cgr void __css_put(struct cgroup_subsys_state *css) { struct cgroup *cgrp = css->cgroup; + int val; rcu_read_lock(); - if (atomic_dec_return(&css->refcnt) == 1) { + val = atomic_dec_return(&css->refcnt); + if (val == 1) { if (notify_on_release(cgrp)) { set_bit(CGRP_RELEASABLE, &cgrp->flags); check_for_release(cgrp); @@ -3717,6 +3719,7 @@ void __css_put(struct cgroup_subsys_stat cgroup_wakeup_rmdir_waiter(cgrp); } rcu_read_unlock(); + WARN_ON_ONCE(val < 1); } /* -- 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/