From: tanxiaofei <tanxiaofei@huawei.com>
To: <tj@kernel.org>, <jiangshanlai@gmail.com>,
<linux-kernel@vger.kernel.org>
Cc: Linuxarm <linuxarm@huawei.com>
Subject: [Question] null pointer risk of kernel workqueue
Date: Sat, 23 Sep 2017 17:04:24 +0800 [thread overview]
Message-ID: <59C62398.6040101@huawei.com> (raw)
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
.
next reply other threads:[~2017-09-23 9:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-23 9:04 tanxiaofei [this message]
2017-09-25 15:25 ` [Question] null pointer risk of kernel workqueue 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=59C62398.6040101@huawei.com \
--to=tanxiaofei@huawei.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox