[PATCH 2/4] blk-mq: fix q->mq_map access race
From: Akinobu Mita
Date: Sun Jun 21 2015 - 09:53:13 EST
CPU hotplug handling for blk-mq (blk_mq_queue_reinit) updates q->mq_map
by blk_mq_update_queue_map() for all request queues in all_q_list.
On the other hand, q->mq_map is released and set to NULL before
deleting the queue from all_q_list.
So if cpu hotplug event occurs in the window, invalid memory access
can happen. Fix it by deleting the queue from all_q_list earlier
than destroyng q->mq_map.
Signed-off-by: Akinobu Mita <akinobu.mita@xxxxxxxxx>
Cc: Jens Axboe <axboe@xxxxxxxxx>
---
block/blk-mq.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index ec94258..6487710 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2038,6 +2038,10 @@ void blk_mq_free_queue(struct request_queue *q)
{
struct blk_mq_tag_set *set = q->tag_set;
+ mutex_lock(&all_q_mutex);
+ list_del_init(&q->all_q_node);
+ mutex_unlock(&all_q_mutex);
+
blk_mq_del_queue_tag_set(q);
blk_mq_exit_hw_queues(q, set, set->nr_hw_queues);
@@ -2048,10 +2052,6 @@ void blk_mq_free_queue(struct request_queue *q)
kfree(q->mq_map);
q->mq_map = NULL;
-
- mutex_lock(&all_q_mutex);
- list_del_init(&q->all_q_node);
- mutex_unlock(&all_q_mutex);
}
/* Basically redo blk_mq_init_queue with queue frozen */
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at http://www.tux.org/lkml/