]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
blk-iocost: ioc_pd_free() shouldn't assume irq disabled
authorTejun Heo <tj@kernel.org>
Tue, 1 Sep 2020 18:52:31 +0000 (14:52 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Sep 2020 17:12:35 +0000 (19:12 +0200)
commit 5aeac7c4b16069aae49005f0a8d4526baa83341b upstream.

ioc_pd_free() grabs irq-safe ioc->lock without ensuring that irq is disabled
when it can be called with irq disabled or enabled. This has a small chance
of causing A-A deadlocks and triggers lockdep splats. Use irqsave operations
instead.

Signed-off-by: Tejun Heo <tj@kernel.org>
Fixes: 7caa47151ab2 ("blkcg: implement blk-iocost")
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
block/blk-iocost.c

index dcc6685d5beccea7936bc48e2a659f13d3b9e47b..ef287c33d6d97d3face310afe2ea979fc2de7010 100644 (file)
@@ -2074,14 +2074,15 @@ static void ioc_pd_free(struct blkg_policy_data *pd)
 {
        struct ioc_gq *iocg = pd_to_iocg(pd);
        struct ioc *ioc = iocg->ioc;
+       unsigned long flags;
 
        if (ioc) {
-               spin_lock(&ioc->lock);
+               spin_lock_irqsave(&ioc->lock, flags);
                if (!list_empty(&iocg->active_list)) {
                        propagate_active_weight(iocg, 0, 0);
                        list_del_init(&iocg->active_list);
                }
-               spin_unlock(&ioc->lock);
+               spin_unlock_irqrestore(&ioc->lock, flags);
 
                hrtimer_cancel(&iocg->waitq_timer);
                hrtimer_cancel(&iocg->delay_timer);