From: Tejun Heo <tj@kernel.org>
To: Li Bin <huawei.libin@huawei.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>,
linux-kernel@vger.kernel.org, tanxiaofei@huawei.com,
guohanjun@huawei.com
Subject: Re: [PATCH v2] workqueue: Fix NULL pointer dereference
Date: Mon, 30 Oct 2017 07:59:36 -0700 [thread overview]
Message-ID: <20171030145936.GC3252168@devbig577.frc2.facebook.com> (raw)
In-Reply-To: <1509160048-34939-1-git-send-email-huawei.libin@huawei.com>
On Sat, Oct 28, 2017 at 11:07:28AM +0800, Li Bin wrote:
> When queue_work() is used in irq (not in task context), there is
> a potential case that trigger NULL pointer dereference.
> ----------------------------------------------------------------
> worker_thread()
> |-spin_lock_irq()
> |-process_one_work()
> |-worker->current_pwq = pwq
> |-spin_unlock_irq()
> |-worker->current_func(work)
> |-spin_lock_irq()
> |-worker->current_pwq = NULL
> |-spin_unlock_irq()
>
> //interrupt here
> |-irq_handler
> |-__queue_work()
> //assuming that the wq is draining
> |-is_chained_work(wq)
> |-current_wq_worker()
> //Here, 'current' is the interrupted worker!
> |-current->current_pwq is NULL here!
> |-schedule()
> ----------------------------------------------------------------
>
> Avoid it by checking for task context in current_wq_worker(), and
> if not in task context, we shouldn't use the 'current' to check the
> condition.
>
> Reported-by: Xiaofei Tan <tanxiaofei@huawei.com>
> Signed-off-by: Li Bin <huawei.libin@huawei.com>
Applied to wq/for-4.14-fixes w/ -stable cc'd.
Thanks.
--
tejun
prev parent reply other threads:[~2017-10-30 14:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-28 3:07 [PATCH v2] workqueue: Fix NULL pointer dereference Li Bin
2017-10-29 14:48 ` Lai Jiangshan
2017-10-30 14:59 ` Tejun Heo [this message]
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=20171030145936.GC3252168@devbig577.frc2.facebook.com \
--to=tj@kernel.org \
--cc=guohanjun@huawei.com \
--cc=huawei.libin@huawei.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tanxiaofei@huawei.com \
/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