lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACVXFVNQLvrgxGxNwQ58pdP0sHuBaGkcMoc2pTrjiqCV6EJ3qw@mail.gmail.com>
Date:	Wed, 8 Jul 2015 19:53:21 +0800
From:	Ming Lei <tom.leiming@...il.com>
To:	Akinobu Mita <akinobu.mita@...il.com>
Cc:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Jens Axboe <axboe@...nel.dk>
Subject: Re: [PATCH v2 3/6] blk-mq: fix q->mq_usage_counter access race

On Thu, Jul 2, 2015 at 10:29 PM, Akinobu Mita <akinobu.mita@...il.com> wrote:
> CPU hotplug handling for blk-mq (blk_mq_queue_reinit) accesses
> q->mq_usage_counter while freezing all request queues in all_q_list.
> On the other hand, q->mq_usage_counter is deinitialized in
> blk_mq_free_queue() before deleting the queue from all_q_list.
>
> So if CPU hotplug event occurs in the window, percpu_ref_kill() is
> called with q->mq_usage_counter which has already been marked dead,
> and it triggers warning.  Fix it by deleting the queue from all_q_list
> earlier than destroying q->mq_usage_counter.
>
> Signed-off-by: Akinobu Mita <akinobu.mita@...il.com>
> Cc: Jens Axboe <axboe@...nel.dk>
> Cc: Ming Lei <tom.leiming@...il.com>

Reviewed-by: Ming Lei <tom.leiming@...il.com>

> ---
>  block/blk-mq.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index c5da908..ff72e18 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2070,15 +2070,16 @@ 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);
>         blk_mq_free_hw_queues(q, set);
>
>         percpu_ref_exit(&q->mq_usage_counter);
> -       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
>



-- 
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ