All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] workqueue: unregister wq lockdep on error path in alloc_workqueue()
@ 2019-03-08  7:37 Kefeng Wang
  2019-03-08 14:45 ` Bart Van Assche
  0 siblings, 1 reply; 3+ messages in thread
From: Kefeng Wang @ 2019-03-08  7:37 UTC (permalink / raw)
  To: Bart Van Assche, Ingo Molnar, Tejun Heo, linux-kernel
  Cc: Kefeng Wang, syzbot+17335689e239ce135d8b

syzkaller report an issue "KASAN: use-after-free Read in alloc_workqueue",

alloc_workqueue
 - kzalloc wq
 - wq_init_lockdep(wq);
   - lockdep_register_key(&wq->key);  // add to hlist
 - kfree wq

But forget to call wq_unregister_lockdep()->lockdep_unregister_key(), it
will delete the entry from hlist.

Reported-by: syzbot+17335689e239ce135d8b@syzkaller.appspotmail.com
Fixes: 669de8bda87b ("kernel/workqueue: Use dynamic lockdep keys for workqueues")
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 kernel/workqueue.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 7abbeed13421..9209d25dfade 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4291,6 +4291,7 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
 	return wq;
 
 err_free_wq:
+	wq_unregister_lockdep(wq);
 	free_workqueue_attrs(wq->unbound_attrs);
 	kfree(wq);
 	return NULL;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-09  4:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-08  7:37 [PATCH] workqueue: unregister wq lockdep on error path in alloc_workqueue() Kefeng Wang
2019-03-08 14:45 ` Bart Van Assche
2019-03-09  4:13   ` Kefeng Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.