From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
Dongsu Park <dongsu.park@profitbricks.com>,
Ming Lei <ming.lei@canonical.com>, Jens Axboe <axboe@fb.com>
Subject: [PATCH 4.0 24/60] blk-mq: fix race between timeout and CPU hotplug
Date: Fri, 15 May 2015 16:14:25 -0700 [thread overview]
Message-ID: <20150515231019.551018068@linuxfoundation.org> (raw)
In-Reply-To: <20150515231018.815421141@linuxfoundation.org>
4.0-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <ming.lei@canonical.com>
commit f054b56c951bf1731ba7314a4c7f1cc0b2977cc9 upstream.
Firstly during CPU hotplug, even queue is freezed, timeout
handler still may come and access hctx->tags, which may cause
use after free, so this patch deactivates timeout handler
inside CPU hotplug notifier.
Secondly, tags can be shared by more than one queues, so we
have to check if the hctx has been unmapped, otherwise
still use-after-free on tags can be triggered.
Reported-by: Dongsu Park <dongsu.park@profitbricks.com>
Tested-by: Dongsu Park <dongsu.park@profitbricks.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
block/blk-mq.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -675,8 +675,11 @@ static void blk_mq_rq_timer(unsigned lon
data.next = blk_rq_timeout(round_jiffies_up(data.next));
mod_timer(&q->timeout, data.next);
} else {
- queue_for_each_hw_ctx(q, hctx, i)
- blk_mq_tag_idle(hctx);
+ queue_for_each_hw_ctx(q, hctx, i) {
+ /* the hctx may be unmapped, so check it here */
+ if (blk_mq_hw_queue_mapped(hctx))
+ blk_mq_tag_idle(hctx);
+ }
}
}
@@ -2075,9 +2078,16 @@ static int blk_mq_queue_reinit_notify(st
*/
list_for_each_entry(q, &all_q_list, all_q_node)
blk_mq_freeze_queue_start(q);
- list_for_each_entry(q, &all_q_list, all_q_node)
+ list_for_each_entry(q, &all_q_list, all_q_node) {
blk_mq_freeze_queue_wait(q);
+ /*
+ * timeout handler can't touch hw queue during the
+ * reinitialization
+ */
+ del_timer_sync(&q->timeout);
+ }
+
list_for_each_entry(q, &all_q_list, all_q_node)
blk_mq_queue_reinit(q);
next prev parent reply other threads:[~2015-05-15 23:20 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-15 23:14 [PATCH 4.0 00/60] 4.0.4-stable review Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 01/60] x86/spinlocks: Fix regression in spinlock contention detection Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 02/60] ACPI / SBS: Add 5 us delay to fix SBS hangs on MacBook Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 03/60] x86/PCI/ACPI: Make all resources except [io 0xcf8-0xcff] available on PCI bus Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 04/60] ACPI / PNP: add two IDs to list for PNPACPI device enumeration Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 05/60] ocfs2: dlm: fix race between purge and get lock resource Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 06/60] rtc: armada38x: fix concurrency access in armada38x_rtc_set_time Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 07/60] nilfs2: fix sanity check of btree level in nilfs_btree_root_broken() Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 08/60] RDMA/CMA: Canonize IPv4 on IPV6 sockets properly Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 09/60] gpio: sysfs: fix memory leaks and device hotplug Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 10/60] mnt: Fix fs_fully_visible to verify the root directory is visible Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 11/60] mm/memory-failure: call shake_page() when error hits thp tail page Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 12/60] path_openat(): fix double fput() Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 13/60] writeback: use |1 instead of +1 to protect against div by zero Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 14/60] mm: soft-offline: fix num_poisoned_pages counting on concurrent events Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 15/60] [media] marvell-ccic: fix YCbCr ordering Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 16/60] vfio: Fix runaway interruptible timeout Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 17/60] xen/events: Clear cpu_evtchn_mask before resuming Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 18/60] xen/xenbus: Update xenbus event channel on resume Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 19/60] xen/console: Update console " Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 20/60] xen/events: Set irq_info->evtchn before binding the channel to CPU in __startup_pirq() Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 21/60] xen-pciback: Add name prefix to global permissive variable Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 22/60] Revert "dm crypt: fix deadlock when async crypto algorithm returns -EBUSY" Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 23/60] block: destroy bdi before blockdev is unregistered Greg Kroah-Hartman
2015-05-15 23:14 ` Greg Kroah-Hartman [this message]
2015-05-15 23:14 ` [PATCH 4.0 25/60] blk-mq: fix CPU hotplug handling Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 26/60] ARM: dts: OMAP3-N900: Add microphone bias voltages Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 27/60] ARM: dts: imx25: Add #pwm-cells to pwm4 Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 28/60] ARM: dts: imx6: phyFLEX: USB VBUS control is active-high Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 29/60] ARM: dts: imx28: Fix AUART4 TX-DMA interrupt name Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 30/60] ARM: dts: imx23-olinuxino: Fix dr_mode of usb0 Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 31/60] ARM: dts: imx23-olinuxino: Fix polarity of LED GPIO Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 32/60] ARM: mvebu: armada-xp-openblocks-ax3-4: Disable internal RTC Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 33/60] ARM: OMAP2+: Fix omap off idle power consumption creeping up Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 34/60] ARM: net fix emit_udiv() for BPF_ALU | BPF_DIV | BPF_K intruction Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 35/60] ARM: ux500: Move GPIO regulator for SD-card into board DTSs Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 36/60] ARM: ux500: Enable GPIO regulator for SD-card for HREF boards Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 37/60] ARM: ux500: Enable GPIO regulator for SD-card for snowball Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 40/60] drm/i915: Add missing MacBook Pro models with dual channel LVDS Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 41/60] drm/i915/dp: there is no audio on port A Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 42/60] drm/amdkfd: allow unregister process with queues Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 43/60] drm/amdkfd: Initialize sdma vm when creating sdma queue Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 45/60] drm/radeon: dont setup audio on asics that dont support it Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 50/60] pinctrl: Dont just pretend to protect pinctrl_maps, do it for real Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 51/60] mmc: card: Dont access RPMB partitions for normal read/write Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 52/60] mmc: core: add missing pm event in mmc_pm_notify to fix hib restore Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 53/60] mmc: sh_mmcif: Fix timeout value for command request Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 54/60] ARM: 8307/1: psci: move psci firmware calls out of line Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 55/60] sound/oss: fix deadlock in sequencer_ioctl(SNDCTL_SEQ_OUTOFBAND) Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 56/60] coredump: accept any write method Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 57/60] ACPICA: Tables: Change acpi_find_root_pointer() to use acpi_physical_address Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 58/60] ACPICA: Utilities: Cleanup to enforce ACPI_PHYSADDR_TO_PTR()/ACPI_PTR_TO_PHYSADDR() Greg Kroah-Hartman
2015-05-15 23:15 ` [PATCH 4.0 59/60] ACPICA: Utilities: Cleanup to convert physical address printing formats Greg Kroah-Hartman
2015-05-15 23:15 ` [PATCH 4.0 60/60] ACPICA: Utilities: Cleanup to remove useless ACPI_PRINTF/FORMAT_xxx helpers Greg Kroah-Hartman
2015-05-16 3:16 ` [PATCH 4.0 00/60] 4.0.4-stable review Guenter Roeck
2015-05-16 15:26 ` Greg Kroah-Hartman
2015-05-16 3:16 ` Shuah Khan
2015-05-16 15:27 ` Greg Kroah-Hartman
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=20150515231019.551018068@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=axboe@fb.com \
--cc=dongsu.park@profitbricks.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@canonical.com \
--cc=stable@vger.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).