Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2273961pxb; Fri, 8 Oct 2021 04:43:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHiO5kHrlhw87q4CZ2fnws+FY0f0ZhiAVuG6r4mLsB9QoCIWuzWQhuzAJABfLgfiNOOU/X X-Received: by 2002:a17:90b:4c0f:: with SMTP id na15mr11279705pjb.200.1633693382268; Fri, 08 Oct 2021 04:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633693382; cv=none; d=google.com; s=arc-20160816; b=nyV6KaTuIFcibDiQ0MKbR9XtjUP88wGlxgEQY3QW2x9DRUgyTcfczkKu7Z0Tz/8n9n PQF1hYEKl9oQN6bQWA7oNRQlK1+tAfkD6BD5Bc93jfbKscoGNEh6dzSP4srXYQeoTRN+ hguVwWLkJwaC/iQ4jyZwwY2KaM9Ozfo6Oot9PnbQeL733QatUoatSJKYNQklIiOp6r3L XboX3PkXv5XAfPJQBbaZ9wlMaQhE4y1j2wurCRuuqGC5/LXRV2qV8398UVvv54ueGjCa yTibGyIOrKM7+PdU+ShAMTVGJMq5LfVtlvJZBv17Bp3Amk91pIJW8+Q5ZkD+6Yywxy8E Qy8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QLWUN3IUbLxbtnk4Zg6Yf7MmE+jO9RwTk5eXFBvneHk=; b=ViaUIxQrfaE+WCYCHgfl050BMT6SvQ2bXbdcLpLqgwNttMRhHnk6KHAyau6U7MvjSe 8KLIv6WOIvlaWWpARRmq0ljColgihi/wW41UeTpNPr9Ja3srSffN4Ozf3sN7IXK83dFB WvT06S2/6EpA6yBpX/wQpYu9CBmmpMLjenESMLrnbanDLpan6DKzK9KcxIAq5nv7FUwt NeWUlhFAieQtDRpN2z2IBx1YwV3OAxn6tZIUD+Bi5M7/tcQukjMRLE7W64s0CkYAniCn XlocPDTOhfwI1xBo7uAsNjF6gLm5Xd7f7FOPcgxlKkPyB9JoxAxBstCiMFzkj/kYu/1U VH7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UocTBchs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bb12si2653133plb.359.2021.10.08.04.42.49; Fri, 08 Oct 2021 04:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UocTBchs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242479AbhJHLmp (ORCPT + 99 others); Fri, 8 Oct 2021 07:42:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:39492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243266AbhJHLjH (ORCPT ); Fri, 8 Oct 2021 07:39:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2F5FA61555; Fri, 8 Oct 2021 11:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633692801; bh=QiUPzBAK7jBE8jLKyJk8nUc0GTtaiCmv0Beg7KyTHoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UocTBchsqe3k00PqVHHG8XHFM/vUr8odCZYtCfUcYpAzySCwu/ITBMDrC2pPqFA1d 25lzcj/ZitN911en/dUzwFWiGCDtqsHmJSydIvZ7rgKoLQ4r0+Lrnaa/fMNhnUjb+f UTzaEEKO+isacFbzj1EAWN9SmCYxlv24U1bX8M6Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yu Kuai , tj@kernel.org, Ming Lei , Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 5.14 37/48] block: dont call rq_qos_ops->done_bio if the bio isnt tracked Date: Fri, 8 Oct 2021 13:28:13 +0200 Message-Id: <20211008112721.273391677@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008112720.008415452@linuxfoundation.org> References: <20211008112720.008415452@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei [ Upstream commit a647a524a46736786c95cdb553a070322ca096e3 ] rq_qos framework is only applied on request based driver, so: 1) rq_qos_done_bio() needn't to be called for bio based driver 2) rq_qos_done_bio() needn't to be called for bio which isn't tracked, such as bios ended from error handling code. Especially in bio_endio(): 1) request queue is referred via bio->bi_bdev->bd_disk->queue, which may be gone since request queue refcount may not be held in above two cases 2) q->rq_qos may be freed in blk_cleanup_queue() when calling into __rq_qos_done_bio() Fix the potential kernel panic by not calling rq_qos_ops->done_bio if the bio isn't tracked. This way is safe because both ioc_rqos_done_bio() and blkcg_iolatency_done_bio() are nop if the bio isn't tracked. Reported-by: Yu Kuai Cc: tj@kernel.org Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig Acked-by: Tejun Heo Link: https://lore.kernel.org/r/20210924110704.1541818-1-ming.lei@redhat.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index d95e3456ba0c..52548c487883 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1396,7 +1396,7 @@ again: if (!bio_integrity_endio(bio)) return; - if (bio->bi_bdev) + if (bio->bi_bdev && bio_flagged(bio, BIO_TRACKED)) rq_qos_done_bio(bio->bi_bdev->bd_disk->queue, bio); if (bio->bi_bdev && bio_flagged(bio, BIO_TRACE_COMPLETION)) { -- 2.33.0