cgroup: fix unbalanced locking
PATCH 1/1 cgroup: fix unbalanced locking
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.
--- kernel/cgroup.c | 1 - 1 file changed, 1 deletion(-)
kernel/cgroup.c +0 -1
@@ -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 ; }
Signature · 1 line
1.8.0.2
Quoted 7 lines · Zefan Li
cgroup_pidlist_start()holdscgrp->pidlist_mutexand then callspidlist_array_load(), andcgroup_pidlist_stop()releases the mutex.It is wrong that we release the mutex in the failure path in
pidlist_array_load(), becausecgroup_pidlist_stop()will be called no matter ifcgroup_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,
Quoted 10 lines · Zefan Li
cgroup_pidlist_start()holdscgrp->pidlist_mutexand then callspidlist_array_load(), andcgroup_pidlist_stop()releases the mutex.It is wrong that we release the mutex in the failure path in
pidlist_array_load(), becausecgroup_pidlist_stop()will be called no matter ifcgroup_pidlist_start()returns errno or not.Fixes 4bac00d16a8760eae7205e41d2c246477d42a210Cc <[email protected]> # 3.14+Signed-off-by Zefan Li <[email protected]>
Applied to cgroup/for-3.17-fixes.
Thanks.
Signature · 1 line
tejun