Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4488296ivc; Tue, 3 Nov 2020 13:21:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcsEid/+TNyI4IdZ8p+Cfb7Z4hgGh+EbeWh7F5J2UEDprTeoE0RkTdtD5+Sht/GKHEGK4B X-Received: by 2002:a17:906:d285:: with SMTP id ay5mr21647739ejb.84.1604438512074; Tue, 03 Nov 2020 13:21:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604438512; cv=none; d=google.com; s=arc-20160816; b=s4pqZQZTQ1+1MvGnDF/ygtDTCiHcZ7kXChTlGmNx3orEGpzzm0B1FpXJNfkhhIN9T5 7V7SQWY31ANkvUn6O7hkxXP+jgS8L9i1zu7npwRejGD8ePGAG6zOtUXHTtKUHEFQD752 xd85O1NVtJ+3fuM8ZMblB+vy2oqfJ1Xte8Jr21NA8XfJIAgPabphsqbo8pBcpfiAq1cl ne6uATev0NvQcny1c8BE8PsIT++DJqOWcKIHOXLMDp8Sjp2ndy2WfAAiFJ6kkPvYMz3x J91/Rka8An9j4mcteG344OpqusZhbrMS9A0ibChL3VtwLkh8OPFVcB1aYHNBgipd+YAj oepg== 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=wQ3QWU8aS705ecray9uPb4F15yKjoIUbgTeNS+MGNeo=; b=sjfv+Jkr298fYWbHlwWSrpkOGHqyu4sIyYeK+5XHyB/XMQ97jmtV/bREXiO4rQVv1o CpWLpseJ5T0QcR0WCn36AWB1Yr/UtvXL09d9OPcOa+l/uO9wdRs1DQfFeLnLjfi3Sey2 pvaoQrAxKKPkMzcgvbsikFPM5xgHoI3QdIqWByOBLW2NJSVd+z1e14DM6BnEvyqzEYYZ KvSyJnOHFVKWVwtPfA3IcmQh5E8gqUJx8ribxspeXRIMCFit3z3v7c/MZM7cx9tZEHbT qsdwGRLK3ry46Q23iOHibrSn8ri78yd9VEhUbp8+5tNjZcimCy8RRt1thSfAU9OsdyUW SSnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xS2Fqoqs; 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=fail (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 a25si3629720edx.171.2020.11.03.13.21.29; Tue, 03 Nov 2020 13:21:52 -0800 (PST) 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=@kernel.org header.s=default header.b=xS2Fqoqs; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388978AbgKCVQw (ORCPT + 99 others); Tue, 3 Nov 2020 16:16:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:52082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388782AbgKCVKv (ORCPT ); Tue, 3 Nov 2020 16:10:51 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B985B205ED; Tue, 3 Nov 2020 21:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437851; bh=3hMGAx5cl3J9r3hhWcF3oOq1fS9krPCO+1IrkgH8BuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xS2FqoqsPYkCweE3GGolr5u1Pvqdw42UVc2vvmDKpF5jPsp5fyLfuZHYEnTozQAKx /OcgvmyqsxzUg88bMhwD3U3lJUjID79eiINjaRSYoz7SCg48PBECJ/0atCTDikRDwm 1yBai1s4Y9NLkSlKwMkqdHIJripZEZWrbllt/Un8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiubo Li , Josef Bacik , Jens Axboe , Sasha Levin Subject: [PATCH 4.14 058/125] nbd: make the config put is called before the notifying the waiter Date: Tue, 3 Nov 2020 21:37:15 +0100 Message-Id: <20201103203205.370701418@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203156.372184213@linuxfoundation.org> References: <20201103203156.372184213@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: Xiubo Li [ Upstream commit 87aac3a80af5cbad93e63250e8a1e19095ba0d30 ] There has one race case for ceph's rbd-nbd tool. When do mapping it may fail with EBUSY from ioctl(nbd, NBD_DO_IT), but actually the nbd device has already unmaped. It dues to if just after the wake_up(), the recv_work() is scheduled out and defers calling the nbd_config_put(), though the map process has exited the "nbd->recv_task" is not cleared. Signed-off-by: Xiubo Li Reviewed-by: Josef Bacik Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index f22fad977c913..cdf62fb94fb15 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -725,9 +725,9 @@ static void recv_work(struct work_struct *work) blk_mq_complete_request(blk_mq_rq_from_pdu(cmd)); } + nbd_config_put(nbd); atomic_dec(&config->recv_threads); wake_up(&config->recv_wq); - nbd_config_put(nbd); kfree(args); } -- 2.27.0