summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>2019-01-23 09:44:12 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-02 10:02:49 +0200
commit8fe1600c91f9ba41990c35a0f817bd58d8a3c1d1 (patch)
treed499d69775ca547d200950a3b806951217a9763b /kernel
parentabcbf3078130bf3151bca846f0b710e83a6623c4 (diff)
downloadlinux-stable-8fe1600c91f9ba41990c35a0f817bd58d8a3c1d1.tar.gz
linux-stable-8fe1600c91f9ba41990c35a0f817bd58d8a3c1d1.tar.bz2
linux-stable-8fe1600c91f9ba41990c35a0f817bd58d8a3c1d1.zip
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>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/workqueue.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index fc5d23d752a5..e94d2b6bee7f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2931,6 +2931,9 @@ static bool __flush_work(struct work_struct *work, bool from_cancel)
if (WARN_ON(!wq_online))
return false;
+ if (WARN_ON(!work->func))
+ return false;
+
if (!from_cancel) {
lock_map_acquire(&work->lockdep_map);
lock_map_release(&work->lockdep_map);