提交 eed759eb 编写于 作者: Z zhengbin 提交者: Xie XiuQi

blk-mq: move cancel of requeue_work to the front of blk_exit_queue

[ Upstream commit e26cc08265dda37d2acc8394604f220ef412299d ]

blk_exit_queue will free elevator_data, while blk_mq_requeue_work
will access it. Move cancel of requeue_work to the front of
blk_exit_queue to avoid use-after-free.

blk_exit_queue                blk_mq_requeue_work
  __elevator_exit               blk_mq_run_hw_queues
    blk_mq_exit_sched             blk_mq_run_hw_queue
      dd_exit_queue                 blk_mq_hctx_has_pending
        kfree(elevator_data)          blk_mq_sched_has_work
                                        dd_has_work

Fixes: fbc2a15e3433 ("blk-mq: move cancel of requeue_work into blk_mq_release")
Cc: stable@vger.kernel.org
Reviewed-by: NMing Lei <ming.lei@redhat.com>
Signed-off-by: Nzhengbin <zhengbin13@huawei.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Conflicts:
  block/blk-mq.c
[yyl: adjust context]
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 ebcd39ed
...@@ -2529,8 +2529,6 @@ void blk_mq_release(struct request_queue *q) ...@@ -2529,8 +2529,6 @@ void blk_mq_release(struct request_queue *q)
struct blk_mq_hw_ctx *hctx, *next; struct blk_mq_hw_ctx *hctx, *next;
int i; int i;
cancel_delayed_work_sync(&q->requeue_work);
queue_for_each_hw_ctx(q, hctx, i) queue_for_each_hw_ctx(q, hctx, i)
WARN_ON_ONCE(hctx && list_empty(&hctx->hctx_list)); WARN_ON_ONCE(hctx && list_empty(&hctx->hctx_list));
......
...@@ -836,6 +836,9 @@ static void __blk_release_queue(struct work_struct *work) ...@@ -836,6 +836,9 @@ static void __blk_release_queue(struct work_struct *work)
blk_free_queue_stats(q->stats); blk_free_queue_stats(q->stats);
if (q->mq_ops)
cancel_delayed_work_sync(&q->requeue_work);
blk_exit_rl(q, &q->root_rl); blk_exit_rl(q, &q->root_rl);
if (q->queue_tags) if (q->queue_tags)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册