All of lore.kernel.org
 help / color / mirror / Atom feed
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] workqueue: Fix NULL pointer dereference
Date: Tue, 24 Oct 2017 07:45:46 -0700	[thread overview]
Message-ID: <20171024144546.GB8598@devbig577.frc2.facebook.com> (raw)
In-Reply-To: <1508807914-25402-1-git-send-email-huawei.libin@huawei.com>

On Tue, Oct 24, 2017 at 09:18:34AM +0800, Li Bin wrote:
> When queue_work() is used in irq handler, 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 irq context in current_wq_worker(), and
> if in irq 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.

Thanks.

-- 
tejun

  reply	other threads:[~2017-10-24 14:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-24  1:18 [PATCH] workqueue: Fix NULL pointer dereference Li Bin
2017-10-24 14:45 ` Tejun Heo [this message]
2017-10-26 15:55 ` Lai Jiangshan
2017-10-26 17:55   ` Tejun Heo
2017-10-27  5:24   ` 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=20171024144546.GB8598@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 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.