lkml.org 
[lkml]   [2014]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] workqueue: sanity check pool->cpu in wq_worker_sleeping()
On Tue, Jun 03, 2014 at 03:33:08PM +0800, Lai Jiangshan wrote:
> In theory, pool->cpu is equals to @cpu in wq_worker_sleeping() after
> worker->flags is checked.
>
> And "pool->cpu != cpu" sanity check will help us if something wrong.
>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> ---
> kernel/workqueue.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 9f53abd..61381a2 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -843,7 +843,7 @@ struct task_struct *wq_worker_sleeping(struct task_struct *task, int cpu)
> pool = worker->pool;
>
> /* this can only happen on the local cpu */
> - if (WARN_ON_ONCE(cpu != raw_smp_processor_id()))
> + if (WARN_ON_ONCE(cpu != raw_smp_processor_id() || pool->cpu != cpu))

Hmmm... yeah, this can catch work functions hijacking and binding
per-cpu worker to another cpu.

Applied to wq/for-3.17.

Thanks.

--
tejun


\
 
 \ /
  Last update: 2014-06-19 19:41    [W:0.342 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site