From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Xiaofei Tan <tanxiaofei@huawei.com>,
Li Bin <huawei.libin@huawei.com>,
Lai Jiangshan <jiangshanlai@gmail.com>, Tejun Heo <tj@kernel.org>
Subject: [PATCH 4.4 33/56] workqueue: Fix NULL pointer dereference
Date: Mon, 13 Nov 2017 13:55:57 +0100 [thread overview]
Message-ID: <20171113125601.894976754@linuxfoundation.org> (raw)
In-Reply-To: <20171113125557.613444087@linuxfoundation.org>
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Bin <huawei.libin@huawei.com>
commit cef572ad9bd7f85035ba8272e5352040e8be0152 upstream.
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>
Reviewed-by: Lai Jiangshan <jiangshanlai@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Fixes: 8d03ecfe4718 ("workqueue: reimplement is_chained_work() using current_wq_worker()")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/workqueue_internal.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/kernel/workqueue_internal.h
+++ b/kernel/workqueue_internal.h
@@ -9,6 +9,7 @@
#include <linux/workqueue.h>
#include <linux/kthread.h>
+#include <linux/preempt.h>
struct worker_pool;
@@ -59,7 +60,7 @@ struct worker {
*/
static inline struct worker *current_wq_worker(void)
{
- if (current->flags & PF_WQ_WORKER)
+ if (in_task() && (current->flags & PF_WQ_WORKER))
return kthread_data(current);
return NULL;
}
next prev parent reply other threads:[~2017-11-13 12:57 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-13 12:55 [PATCH 4.4 00/56] 4.4.98-stable review Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 02/56] video: fbdev: pmag-ba-fb: Remove bad `__init annotation Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 03/56] PCI: mvebu: Handle changes to the bridge windows while enabled Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 04/56] xen/netback: set default upper limit of tx/rx queues to 8 Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 05/56] ARM: dts: imx53-qsb-common: fix FEC pinmux config Greg Kroah-Hartman
2017-11-14 15:44 ` Ben Hutchings
2017-11-15 4:03 ` Patrick Brünn
2017-11-15 15:15 ` Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 06/56] dt-bindings: clockgen: Add compatible string for LS1012A Greg Kroah-Hartman
2017-11-14 15:46 ` Ben Hutchings
2017-11-15 15:16 ` Greg Kroah-Hartman
2017-11-15 15:19 ` Ben Hutchings
2017-11-15 15:51 ` Greg Kroah-Hartman
2017-11-15 15:25 ` Bhaskar Upadhaya
2017-11-15 15:52 ` Greg Kroah-Hartman
2017-11-15 15:55 ` Harninder Rai
2017-11-15 16:08 ` Greg Kroah-Hartman
2017-11-15 16:22 ` Harninder Rai
2017-11-17 5:57 ` Harninder Rai
2017-11-17 7:55 ` Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 08/56] KVM: PPC: Book 3S: XICS: correct the real mode ICP rejecting counter Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 09/56] iommu/arm-smmu-v3: Clear prior settings when updating STEs Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 10/56] powerpc/corenet: explicitly disable the SDHC controller on kmcoge4 Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 11/56] ARM: omap2plus_defconfig: Fix probe errors on UARTs 5 and 6 Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 12/56] crypto: vmx - disable preemption to enable vsx in aes_ctr.c Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 13/56] iio: trigger: free trigger resource correctly Greg Kroah-Hartman
2017-11-14 20:14 ` Ben Hutchings
2017-11-15 16:11 ` Greg Kroah-Hartman
2017-11-18 15:04 ` Jonathan Cameron
2017-11-13 12:55 ` [PATCH 4.4 14/56] dt-bindings: Add LEGO MINDSTORMS EV3 compatible specification Greg Kroah-Hartman
2017-11-14 20:15 ` Ben Hutchings
2017-11-15 15:08 ` Greg Kroah-Hartman
2017-11-15 15:14 ` Ben Hutchings
2017-11-15 15:50 ` Greg Kroah-Hartman
2017-11-15 16:29 ` alexander.levin
2017-11-13 12:55 ` [PATCH 4.4 15/56] dt-bindings: Add vendor prefix for LEGO Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 17/56] serial: sh-sci: Fix register offsets for the IRDA serial port Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 18/56] usb: hcd: initialize hcd->flags to 0 when rm hcd Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 19/56] netfilter: nft_meta: deal with PACKET_LOOPBACK in netdev family Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 20/56] IPsec: do not ignore crypto err in ah4 input Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 21/56] Input: mpr121 - handle multiple bits change of status register Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 22/56] Input: mpr121 - set missing event capability Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 23/56] IB/ipoib: Change list_del to list_del_init in the tx object Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 24/56] s390/qeth: issue STARTLAN as first IPA command Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 25/56] net: dsa: select NET_SWITCHDEV Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 28/56] KEYS: trusted: sanitize all key material Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 29/56] KEYS: trusted: fix writing past end of buffer in trusted_read() Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 32/56] x86/uaccess, sched/preempt: Verify access_ok() context Greg Kroah-Hartman
2017-11-13 12:55 ` Greg Kroah-Hartman [this message]
2017-11-13 12:55 ` [PATCH 4.4 34/56] crypto: x86/sha1-mb - fix panic due to unaligned access Greg Kroah-Hartman
2017-11-13 12:55 ` [PATCH 4.4 35/56] KEYS: fix NULL pointer dereference during ASN.1 parsing [ver #2] Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 36/56] ARM: 8720/1: ensure dump_instr() checks addr_limit Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 37/56] ALSA: seq: Fix OSS sysex delivery in OSS emulation Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 38/56] ALSA: seq: Avoid invalid lockdep class warning Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 39/56] MIPS: microMIPS: Fix incorrect mask in insn_table_MM Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 40/56] MIPS: Fix CM region target definitions Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 41/56] MIPS: SMP: Use a completion event to signal CPU up Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 42/56] MIPS: Fix race on setting and getting cpu_online_mask Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 43/56] MIPS: SMP: Fix deadlock & online race Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 44/56] test: firmware_class: report errors properly on failure Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 45/56] selftests: firmware: add empty string and async tests Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 46/56] selftests: firmware: send expected errors to /dev/null Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 47/56] tools: firmware: check for distro fallback udev cancel rule Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 48/56] MIPS: AR7: Defer registration of GPIO Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 49/56] MIPS: AR7: Ensure that serial ports are properly set up Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 50/56] Input: elan_i2c - add ELAN060C to the ACPI table Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 51/56] drm/vmwgfx: Fix Ubuntu 17.10 Wayland black screen issue Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 52/56] rbd: use GFP_NOIO for parent stat and data requests Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 53/56] can: sun4i: handle overrun in RX FIFO Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 55/56] x86/oprofile/ppro: Do not use __this_cpu*() in preemptible context Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.4 56/56] PKCS#7: fix unitialized boolean want Greg Kroah-Hartman
2017-11-13 21:51 ` [PATCH 4.4 00/56] 4.4.98-stable review Shuah Khan
2017-11-13 22:28 ` Guenter Roeck
2017-11-14 21:31 ` Tom Gall
2017-11-15 8:59 ` Greg Kroah-Hartman
2017-11-15 10:14 ` Milosz Wasilewski
2017-11-15 12:15 ` Naresh Kamboju
2017-11-15 15:17 ` Greg Kroah-Hartman
2017-11-15 16:22 ` Guenter Roeck
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=20171113125601.894976754@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=huawei.libin@huawei.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tanxiaofei@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;
as well as URLs for NNTP newsgroup(s).