Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4479494ivc; Tue, 3 Nov 2020 13:06:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVYivVvcnIAGJINIgS8q1HbZMMJk9dTi9vl4GVzGwPS459Jzv7tUVh11Eci2eJyl2sVDqn X-Received: by 2002:a50:8acf:: with SMTP id k15mr23817417edk.351.1604437617318; Tue, 03 Nov 2020 13:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437617; cv=none; d=google.com; s=arc-20160816; b=muVq8cxJ0lNI54FfpezbWUjkPrihD+Vhu083LClO8/eCJqvXSU7+V7tgHyUyAWx7FH pz+SA7yjpLSay3rkac3e/Vdv35lOcxvReMpY6bvqyfGFE8bFmGTjfz9MHJpsT3se24Ju OKMlRmxlQfyuEFk/24UKuszkbsNyfq2ccB8OUkJP6dq8XXMsgq64N514MQrWHhHrEYM4 gQFZTA+DBT+Diw25H8E7tvyrBbu5ffUuO8br2VR4a7x+afNKGLo22V7QNFGSKJzRqn2I +CmiI77WWRAggge5eppGQEXarmFXy/SBp7naNGR8BPJ/CGvXxweockBhx9jNMnYszvYU ri0Q== 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=gnfNYQ4n/uAFl71gAl6TtaQakFymQaMjgLG/6EAekuo=; b=VyAqBFgvLw4uecYwqWbuUao6DKMqpO1PmENTbjU2E4Gc4F0i5QY8ZLdtz5Ykl0QhSA fcPZ006MVIHCnBKDKPLIlpu/MdF2yctFnvEU4yfO1opiJaTsJjR1IRuahljypkU3TTVW uWiXNdHtyknQMWp/0NlZZ9L0v7FMZrWFtqA+Nv8vmxiJtWZTM95i5NXMMSqm9i8XIvGy MARTW2r9HdfxHkF2Un4rqVL0Ufq5jMvq0AwUV4pxCgd8FAhJB0vTgpCGCg+892mwmICF Tzt6bNkBJXSDBpAJW37xYQJnim/wcFwrMeTxlvXCLtL9lJPyr97zLrv4C0SpKJFQ2+BM usZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cLdcu9zg; 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 k16si5664eja.59.2020.11.03.13.06.34; Tue, 03 Nov 2020 13:06:57 -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=cLdcu9zg; 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 S1731629AbgKCVFU (ORCPT + 99 others); Tue, 3 Nov 2020 16:05:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:43684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387743AbgKCVFO (ORCPT ); Tue, 3 Nov 2020 16:05:14 -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 06FB7205ED; Tue, 3 Nov 2020 21:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437514; bh=jrRtNSCNVrksncJAZyQSt7kVNwPnXNwSAdxIsmN4yJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cLdcu9zgw2MCpRl1iAm19rkam9hMgAIIuZRTb9F9GeKPfj1snTWBn9JTMRXyv62WD X4YuGlAYyCzwDbDv0fzS7qqHXX6dYgt0HjC6lc7dmBA7NAs2tFnqGueKKzlIBuEjam OiVHox6aEQdLg1KZKK5Buho28C2n8D/dxpVKh2Ik= 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.19 109/191] nbd: make the config put is called before the notifying the waiter Date: Tue, 3 Nov 2020 21:36:41 +0100 Message-Id: <20201103203243.735216554@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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 d7c7232e438c9..52e1e71e81241 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -740,9 +740,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