public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [Question] null pointer risk of kernel workqueue
@ 2017-09-23  9:04 tanxiaofei
  2017-09-25 15:25 ` Tejun Heo
  0 siblings, 1 reply; 10+ messages in thread
From: tanxiaofei @ 2017-09-23  9:04 UTC (permalink / raw)
  To: tj, jiangshanlai, linux-kernel; +Cc: Linuxarm

Hi Tejun & Jiangshan,

I find an null pointer risk in the code of workqueue. Here is description:

If draining, __queue_work() will call the function is_chained_work() to do some checks.
In is_chained_work(), worker->current_pwq is used directly. It should be not safe.
http://elixir.free-electrons.com/linux/latest/source/kernel/workqueue.c#L1384

If you check the thread function of this worker, worker_thread(), you will find worker->current_pwq
is null when one work is done or ready to be processed.
This issue may happen only if we queue work during executing drain_workqueue().
http://elixir.free-electrons.com/linux/latest/source/kernel/workqueue.c#L2173

There are very few places to call drain_workqueue() in the whole linux kernel.
I think that's why no one noticed this risk.

Xiaofei Tan
_______________________________________________
linuxarm mailing list
linuxarm@huawei.com
http://rnd-openeuler.huawei.com/mailman/listinfo/linuxarm

.

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

end of thread, other threads:[~2017-10-24  0:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-23  9:04 [Question] null pointer risk of kernel workqueue tanxiaofei
2017-09-25 15:25 ` Tejun Heo
2017-09-27  9:17   ` tanxiaofei
2017-10-20  6:57     ` tanxiaofei
2017-10-21 15:35       ` Tejun Heo
2017-10-21 15:35         ` Tejun Heo
2017-10-23  1:34         ` Li Bin
2017-10-23  6:23           ` tanxiaofei
2017-10-23 14:03           ` Tejun Heo
2017-10-24  0:33             ` Li Bin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox