Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4144916pxb; Mon, 27 Sep 2021 10:17:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzic51PCuRd/RESNfG7O0gkWDxUxaxyLc/mwVhXUJ7V7ncTmYRtFvOB/tax66a9Z2k4p4MX X-Received: by 2002:a17:902:c086:b0:13e:2b52:29e1 with SMTP id j6-20020a170902c08600b0013e2b5229e1mr1090468pld.8.1632763067066; Mon, 27 Sep 2021 10:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632763067; cv=none; d=google.com; s=arc-20160816; b=0FOG489ebwrHfGnjz0p/YQEfgBq1t9mz2vTF1K+vZ7z45Zv+imTWiYFob5g1SGR/5S ONBpy5QJU+cDaZYrTBI+CuDPPZ+YRNCCBVvpQnDd/vrjnwMKss8Xohmnf/SZar0UxIZD u0lcysDc8bsnluL09VJFnH4frbXhezkZ+M1SzEckPxHFCm1TMU5ASHqlQs5jnm338RCe bRT8NW4LT5WLiJS0wQBysf5PoO6EFPqCsMBwq7+SYFcDQw+LAqXc+nNzWNqtBL2Wzj8V 1mAHgaTOl1+BP0A93RhtkGhdH/MbstcnZ9eM2Bk064L2ogEAe5b7Xmg4d6c70zPtANOy sDQg== 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=K1meAwtK2pPQTJ7EUrLKRCyr5DzSYAIJAQuJDBxqaqY=; b=VXAE5zByMdbaFqTRmME9DnSGzW+amMBQ+J7GRjgxug7MKAedAj9n+4fuTDPA//SqHx jNEM5R793F1SqqF82yoa8Ml0BhU/5RXcBeCXyzD6pT6C3fcpRfXpxE9Zb654fTRFBB7H 6+SAAKrM5P103zQS43MJF0jDPfXNaQ4z/Dx5QvOaiL0kqpKF97yw6w+livz/n+dl3Lnx EhabfTq+6wZeFQimNSdNo2fuwlz/fRmLDPK7C6u4jxSoCc8muSSjNL25RgTTwSs8Qs7Y qlwnxBWVxeUTYOXxfYjSZ1LgFm5abuMHNoXGPMl6a0BLPuhlnAn6JSErazjBew8eaEJL jXmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y7kmKKMn; 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 qe18si153186pjb.29.2021.09.27.10.17.33; Mon, 27 Sep 2021 10:17:47 -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=Y7kmKKMn; 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 S236750AbhI0RRh (ORCPT + 99 others); Mon, 27 Sep 2021 13:17:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:56176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237287AbhI0ROa (ORCPT ); Mon, 27 Sep 2021 13:14:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 969A56113A; Mon, 27 Sep 2021 17:10:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632762610; bh=Z+h5UCQ1pHGq30LcDVJRyF4/ArN7q2q2X4cNJCzUbT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y7kmKKMnxLvaGCYZUMc9kOo4YGkkc9gmgYIr7SQL0IkrfgZ4HI49cs7GWRCMYy0c4 /KxtLzqhPaI+oLCiPftIx39fTzmtppZQiY/ryW6DBI3ZuPOP4U6wvH7gRhIrIvdsa9 9Sk+7iuBXI4flMbP0GHiVYOmSOXR1AIke0Jue/IM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lihong Kou , Christoph Hellwig , Sagi Grimberg , Jens Axboe , Sasha Levin Subject: [PATCH 5.10 087/103] block: flush the integrity workqueue in blk_integrity_unregister Date: Mon, 27 Sep 2021 19:02:59 +0200 Message-Id: <20210927170228.778902306@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927170225.702078779@linuxfoundation.org> References: <20210927170225.702078779@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: Lihong Kou [ Upstream commit 3df49967f6f1d2121b0c27c381ca1c8386b1dab9 ] When the integrity profile is unregistered there can still be integrity reads queued up which could see a NULL verify_fn as shown by the race window below: CPU0 CPU1 process_one_work nvme_validate_ns bio_integrity_verify_fn nvme_update_ns_info nvme_update_disk_info blk_integrity_unregister ---set queue->integrity as 0 bio_integrity_process --access bi->profile->verify_fn(bi is a pointer of queue->integity) Before calling blk_integrity_unregister in nvme_update_disk_info, we must make sure that there is no work item in the kintegrityd_wq. Just call blk_flush_integrity to flush the work queue so the bug can be resolved. Signed-off-by: Lihong Kou [hch: split up and shortened the changelog] Signed-off-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Link: https://lore.kernel.org/r/20210914070657.87677-3-hch@lst.de Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-integrity.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index e9f943de377a..9e83159f5a52 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -430,6 +430,9 @@ void blk_integrity_unregister(struct gendisk *disk) if (!bi->profile) return; + + /* ensure all bios are off the integrity workqueue */ + blk_flush_integrity(); blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, disk->queue); memset(bi, 0, sizeof(*bi)); } -- 2.33.0