diff options
| author | Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> | 2019-01-22 19:44:12 -0500 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2019-01-25 10:28:29 -0500 |
| commit | 4d43d395fed124631ca02356c711facb90185175 (patch) | |
| tree | 6c8e59bb96496aa1a19d3e8b96779b7731a258a2 /kernel/workqueue.c | |
| parent | d73aba1115cf40630cc8b4b7aed049ed8117b458 (diff) | |
workqueue: Try to catch flush_work() without INIT_WORK().
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>
Diffstat (limited to 'kernel/workqueue.c')
| -rw-r--r-- | kernel/workqueue.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 392be4b252f6..a503ad9d0aec 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
| @@ -2908,6 +2908,9 @@ static bool __flush_work(struct work_struct *work, bool from_cancel) | |||
| 2908 | if (WARN_ON(!wq_online)) | 2908 | if (WARN_ON(!wq_online)) |
| 2909 | return false; | 2909 | return false; |
| 2910 | 2910 | ||
| 2911 | if (WARN_ON(!work->func)) | ||
| 2912 | return false; | ||
| 2913 | |||
| 2911 | if (!from_cancel) { | 2914 | if (!from_cancel) { |
| 2912 | lock_map_acquire(&work->lockdep_map); | 2915 | lock_map_acquire(&work->lockdep_map); |
| 2913 | lock_map_release(&work->lockdep_map); | 2916 | lock_map_release(&work->lockdep_map); |
