Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp840095pxb; Tue, 3 Nov 2020 14:04:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/oPuOUujI6PSqo8RgW0vu78GrBgrLyIt2PbCrfDLUG1o2xAFF2zsiDZ/7CS9ckFugJBaw X-Received: by 2002:a17:906:1159:: with SMTP id i25mr2283049eja.398.1604441083543; Tue, 03 Nov 2020 14:04:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604441083; cv=none; d=google.com; s=arc-20160816; b=sFe7oapoBO/l6hd6Zu2+JsG0kL2IE+wvHw82TtfQY7eBdkCongN4+YXDgUZLaspt0s Hii53herIxnQlwd9Jm9GOpcagIVc4djzLALSxNbz5Vo9yq2vzlZI+vqvn5RcN2Os26hw PVvarWL/paSCTWhvfL/gkHU1eKxRCszten2SD5OJHJDCuYpH+qUCJ21iToY8cwPVZE/p O5/DJikalfm9MaU5VBmyCM0moj3rixnINTIWppYRohQTplQEoSjT8FA5gpbudyCcmVFH thePKJct7GXG+AhoFxkEoxEoSeG7dx/aRMCi0z9B92Mlb5XWvS2Yz4LIcc9AhnqZ8e/S HOcA== 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=+eutUzXjoOA/ZVV8T2WK70Xw5glaLR6T7kLkesSlgls=; b=MRl/5JcibQbtiIcrVJyngQmGbWIRs04w76gfAGKLBFgRAQygXs6IfiZDlk5M7DMXHH ZO5uAV4PaE2a23ppekJ8AywTd3MnMaTBc4CFrjSqF5DYl8IjYQhXXv3qaTXofvgDNQRd p78cc1z5PvlrqvNks/vHnXV2Nx2YcIul2dh823of2J7xtu/o8fdhoCIoxcujGdSh4qXv UNAWOQvDKlRaUWuDgm9/AHGFHaXlS0280ssEvUbqHCuto8fe5KubLZfgGncEjHOBuJzG LUyqQbh/KwAATIxBgipvU0czhbU6ltskZkuL8ujgR4v8zXVWC9Nz6pVMe71Zoi30fYeu tMiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sXE28Z8w; 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 y41si13545920ede.192.2020.11.03.14.04.20; Tue, 03 Nov 2020 14:04:43 -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=sXE28Z8w; 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 S1730960AbgKCUoy (ORCPT + 99 others); Tue, 3 Nov 2020 15:44:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:60592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730951AbgKCUow (ORCPT ); Tue, 3 Nov 2020 15:44:52 -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 97821223BF; Tue, 3 Nov 2020 20:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436292; bh=bnFbbM/iTF0EpzIJJWqApOMmpoKGyKiVkoOqqqvnD94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sXE28Z8wkSHezEAz9ACLkvaZ06zdk3rP9tuFcdD7ylSQRlk5fy+SScje6LP/EQzBy wdme7yW08xkrOUEW7c2ySaOq2xn2up8sx5mW8pIuCRzTRchoVAWb9xcsB/DOQVCP9f Y62a/Z6Aul69Yf3wiaSBqx0D2DmksyZSqJfrWRq0= 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 5.9 179/391] nbd: make the config put is called before the notifying the waiter Date: Tue, 3 Nov 2020 21:33:50 +0100 Message-Id: <20201103203358.951326537@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@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 edf8b632e3d27..f46e26c9d9b3c 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -801,9 +801,9 @@ static void recv_work(struct work_struct *work) if (likely(!blk_should_fake_timeout(rq->q))) blk_mq_complete_request(rq); } + nbd_config_put(nbd); atomic_dec(&config->recv_threads); wake_up(&config->recv_wq); - nbd_config_put(nbd); kfree(args); } -- 2.27.0