workqueue: Try to catch flush_work() without INIT_WORK().
authorTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Wed, 23 Jan 2019 00:44:12 +0000 (09:44 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 May 2019 07:58:56 +0000 (09:58 +0200)
commit8c37f7c23c02f6ac020ffdc746026c2363b23a5a
tree28ec5a33401fa362ec9ba1e4c13b08b811ff44d0
parent4d476a00b3f98334fd8a680dc0d813f4d82a5f3d
workqueue: Try to catch flush_work() without INIT_WORK().

commit 4d43d395fed124631ca02356c711facb90185175 upstream.

syzbot found a flush_work() caller who forgot to call INIT_WORK()
because that work_struct was allocated by kzalloc() [1]. But the message

  INFO: trying to register non-static key.
  the code is fine but needs lockdep annotation.
  turning off the locking correctness validator.

by lock_map_acquire() is failing to tell that INIT_WORK() is missing.

Since flush_work() without INIT_WORK() is a bug, and INIT_WORK() should
set ->func field to non-zero, let's warn if ->func field is zero.

[1] https://syzkaller.appspot.com/bug?id=a5954455fcfa51c29ca2ab55b203076337e1c770

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/workqueue.c