]> git.baikalelectronics.ru Git - kernel.git/commit
workqueue: Make sure struct worker is accessible for wq_worker_comm()
authorTejun Heo <tj@kernel.org>
Mon, 21 May 2018 15:04:35 +0000 (08:04 -0700)
committerTejun Heo <tj@kernel.org>
Mon, 21 May 2018 15:04:35 +0000 (08:04 -0700)
commitcade6633a490e8bc70764121d81d507db9bf101d
treec2656102606350b4398c233866cd1e6b93e7caa6
parent58f2cfa82ea74938db0d16a5192cd24515a7a6d0
workqueue: Make sure struct worker is accessible for wq_worker_comm()

The worker struct could already be freed when wq_worker_comm() tries
to access it for reporting.  This patch protects PF_WQ_WORKER
modifications with wq_pool_attach_mutex and makes wq_worker_comm()
test the flag before dereferencing worker from kthread_data(), which
ensures that it only dereferences when the worker struct is valid.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Lai Jiangshan <jiangshanlai@gmail.com>
Fixes: 58f2cfa82ea7 ("workqueue: Show the latest workqueue name in /proc/PID/{comm,stat,status}")
kernel/workqueue.c