public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroup: fix unbalanced locking
@ 2014-09-18  9:28 Zefan Li
  2014-09-18 16:14 ` Cong Wang
  2014-09-18 16:34 ` Tejun Heo
  0 siblings, 2 replies; 3+ messages in thread
From: Zefan Li @ 2014-09-18  9:28 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Cgroups, LKML

cgroup_pidlist_start() holds cgrp->pidlist_mutex and then calls
pidlist_array_load(), and cgroup_pidlist_stop() releases the mutex.

It is wrong that we release the mutex in the failure path in
pidlist_array_load(), because cgroup_pidlist_stop() will be called
no matter if cgroup_pidlist_start() returns errno or not.

Fixes: 4bac00d16a8760eae7205e41d2c246477d42a210
Cc: <stable@vger.kernel.org> # 3.14+
Signed-off-by: Zefan Li <lizefan@huawei.com>
---
 kernel/cgroup.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 2332efd..de70b63 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3970,7 +3970,6 @@ static int pidlist_array_load(struct cgroup *cgrp, enum cgroup_filetype type,
 
 	l = cgroup_pidlist_find_create(cgrp, type);
 	if (!l) {
-		mutex_unlock(&cgrp->pidlist_mutex);
 		pidlist_free(array);
 		return -ENOMEM;
 	}
-- 
1.8.0.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cgroup: fix unbalanced locking
  2014-09-18  9:28 [PATCH] cgroup: fix unbalanced locking Zefan Li
@ 2014-09-18 16:14 ` Cong Wang
  2014-09-18 16:34 ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Cong Wang @ 2014-09-18 16:14 UTC (permalink / raw)
  To: Zefan Li; +Cc: Tejun Heo, Cgroups, LKML

On Thu, Sep 18, 2014 at 2:28 AM, Zefan Li <lizefan@huawei.com> wrote:
> cgroup_pidlist_start() holds cgrp->pidlist_mutex and then calls
> pidlist_array_load(), and cgroup_pidlist_stop() releases the mutex.
>
> It is wrong that we release the mutex in the failure path in
> pidlist_array_load(), because cgroup_pidlist_stop() will be called
> no matter if cgroup_pidlist_start() returns errno or not.
>

I found same thing yesterday and tried to analysis if this could
be the cause of the the NULL ptr def bug I saw, it seems not.

Anyway, this fix is definitely correct,

Acked-by: Cong Wang <xiyou.wangcong@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cgroup: fix unbalanced locking
  2014-09-18  9:28 [PATCH] cgroup: fix unbalanced locking Zefan Li
  2014-09-18 16:14 ` Cong Wang
@ 2014-09-18 16:34 ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2014-09-18 16:34 UTC (permalink / raw)
  To: Zefan Li; +Cc: Cgroups, LKML

On Thu, Sep 18, 2014 at 05:28:46PM +0800, Zefan Li wrote:
> cgroup_pidlist_start() holds cgrp->pidlist_mutex and then calls
> pidlist_array_load(), and cgroup_pidlist_stop() releases the mutex.
> 
> It is wrong that we release the mutex in the failure path in
> pidlist_array_load(), because cgroup_pidlist_stop() will be called
> no matter if cgroup_pidlist_start() returns errno or not.
> 
> Fixes: 4bac00d16a8760eae7205e41d2c246477d42a210
> Cc: <stable@vger.kernel.org> # 3.14+
> Signed-off-by: Zefan Li <lizefan@huawei.com>

Applied to cgroup/for-3.17-fixes.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-18 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-18  9:28 [PATCH] cgroup: fix unbalanced locking Zefan Li
2014-09-18 16:14 ` Cong Wang
2014-09-18 16:34 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox