]> git.baikalelectronics.ru Git - kernel.git/commit
workqueue: fix a possible race condition between rescuer and pwq-release
authorLai Jiangshan <laijs@cn.fujitsu.com>
Fri, 18 Apr 2014 15:04:16 +0000 (11:04 -0400)
committerTejun Heo <tj@kernel.org>
Fri, 18 Apr 2014 16:33:29 +0000 (12:33 -0400)
commit3842eb8bbfbe081c1b771e54c49b9bd0064761ee
tree689828b6f65983dff2ddface82a41bea2bb1adec
parent4aa390597e8c6ef1303f7a04684b2044f9c16285
workqueue: fix a possible race condition between rescuer and pwq-release

There is a race condition between rescuer_thread() and
pwq_unbound_release_workfn().

Even after a pwq is scheduled for rescue, the associated work items
may be consumed by any worker.  If all of them are consumed before the
rescuer gets to them and the pwq's base ref was put due to attribute
change, the pwq may be released while still being linked on
@wq->maydays list making the rescuer dereference already freed pwq
later.

Make send_mayday() pin the target pwq until the rescuer is done with
it.

tj: Updated comment and patch description.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org # v3.10+
kernel/workqueue.c