Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp839588lqp; Thu, 23 May 2024 01:12:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU1cTCnBVhkqtMl/7bXEeKzbpAWxf3jW7ulx8CluAnelDXs4NSjOCyuGzmBNYliC+hx3o8CCV1UzLpWp2BpIdKrnmb9g/YrD1w/r0nIEQ== X-Google-Smtp-Source: AGHT+IHnua24kY5893OfbOu8IxdRZmwK2iTtbi9vOBUBvdaueOP8p8EKmK3fCtD0rjVN3aD1CZtr X-Received: by 2002:a50:8e47:0:b0:572:7c97:6c58 with SMTP id 4fb4d7f45d1cf-57832a07e41mr2179548a12.5.1716451952975; Thu, 23 May 2024 01:12:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716451952; cv=pass; d=google.com; s=arc-20160816; b=K+wShZxyyfYKTDLn3k7yIbS/rmVDna6zYXp1jXUvjgXs5H7De5xT2zqlQ0CYjCJfAk fKQrOy+D1DgBrC5pQXv7yQEa053rc+0HJMKNDe949FhiKbdb/ssw8Inr9nlP+YdPQYSj k1eFeJFxTtcdtShTFYkOO7Tg7iNY2td2bdcVf4msA2shHD+RSg7jZ4xHs/XsN1JjR9hJ 9yYoNbH6M5HT30nt8uLDc5t6PrMoCcZpiGbII6PbGYlCRDUxb2g+hqYTxSw5UzkAzbWf asqmIh8Y7eiRuqf3f1fwTkMfDbFiSkISw0kQII45jgQK9uAoe9T/R6TSvNoXpBU1CK3E uh/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=+nmvI1N5/dsfnnCPTaR/JRU483xaWPYMY2l6Cs/Xqz8=; fh=u2NRCq1TV32Pq/Do1cvZqfgR4OSwtz0I/7GHBpfxvLE=; b=R2HDS2lZLMjeueDABvmQllw+VRscxOcyUaw4RA4klCSt7PMb/wj7rCc5m8o0p08tYx bK9BgLGx98fIVL3dOzwzWMd8HSNMaJvLb97V55Rpn4wR3zFQfp8IwtkTjj7YuRWZIDoG IGwpGdDoAEr2m4gRVHralJOapGGkzLtRoBUHOxLw32YiCwJ0tjAgtfBY9NjIuQ+akRWN hGIj/fOlViSEEyz+oBxBtR2+2Z0ZBNWnZSYCM3omyCcto9hY3uo3iCua3wtNxKBjkzUg aBBhkZeg46BqRgZ/XfKkByqJOIxIbuHP0E+X6oiTKmArPuGEQEz9TW9JyMRSWVOsZ6Yd q3JQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=lst.de); spf=pass (google.com: domain of linux-kernel+bounces-187169-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187169-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-574dfebfb5bsi11135178a12.472.2024.05.23.01.12.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 01:12:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187169-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=lst.de); spf=pass (google.com: domain of linux-kernel+bounces-187169-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187169-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1063D1F21EE5 for ; Thu, 23 May 2024 08:12:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E39D13CABE; Thu, 23 May 2024 08:12:16 +0000 (UTC) Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1CF912AAF0; Thu, 23 May 2024 08:12:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.95.11.211 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716451936; cv=none; b=fwMHYvBqqHslnfpuJ4cOEDbe9L8gK2mEYLus8jLNe3jAcRjqqfznN5rLGWbzR522nzsGiHoSFljoJ1MRzVvkaWqxlOyenHzI0ICJUpdn369nvavLXb0UQKPyfj8jx1lhu4XGSgY46P5Y7zYNPlYHyLQMK9mTSTNYuhBxS0WCov4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716451936; c=relaxed/simple; bh=yk/uOkB+LZYStOEPQkKIZcq0XqcYySnbilurHz1b0Co=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JBS2VfKZRCIe16w3z/P+5AUbZPXOjsETMa0TKQVJZNZFfTzoUqsuOYmPh2w+7JIavh90gMJcOU3PyDCEz0lr4e1xXH3jFzwVnK7Co8RYcZFW3y5OMPoDSzJmVmzmeUJwdL7nE79cziexqiddS71ihC018FvX+eaPBIR0zy6ULRk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=pass smtp.mailfrom=lst.de; arc=none smtp.client-ip=213.95.11.211 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lst.de Received: by verein.lst.de (Postfix, from userid 2407) id 352B268BFE; Thu, 23 May 2024 10:12:08 +0200 (CEST) Date: Thu, 23 May 2024 10:12:07 +0200 From: Christoph Hellwig To: Gulam Mohamed Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@kernel.dk, shinichiro.kawasaki@wdc.com, chaitanyak@nvidia.com, hch@lst.de Subject: Re: [PATCH V2 for-6.10/block 1/2] loop: Fix a race between loop detach and loop open Message-ID: <20240523081207.GB1086@lst.de> References: <20240521224249.7389-1-gulam.mohamed@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240521224249.7389-1-gulam.mohamed@oracle.com> User-Agent: Mutt/1.5.17 (2007-11-01) On Tue, May 21, 2024 at 10:42:48PM +0000, Gulam Mohamed wrote: > Description > =========== That's a weird way to format a patch. Between this and the odd subject not matching patch 2 I was tricked into thinking this was just a cover letter and patch 1 was missing for a while. Please take a look at other patches/commit and try to word it similarly. > V1->V2: > Added a test case, 010, in blktests in tests/loop/ These kind of patch revision changelogs belong after the --- so that they don't go into git history. Or even better into the cover letter, which is missing here. > Signed-off-by: Gulam Mohamed > --- > drivers/block/loop.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/drivers/block/loop.c b/drivers/block/loop.c > index 28a95fd366fe..9a235d8c062d 100644 > --- a/drivers/block/loop.c > +++ b/drivers/block/loop.c > @@ -1717,6 +1717,24 @@ static int lo_compat_ioctl(struct block_device *bdev, blk_mode_t mode, > } > #endif > > +static int lo_open(struct gendisk *disk, blk_mode_t mode) > +{ > + struct loop_device *lo = disk->private_data; > + int err; > + > + if (!lo) > + return -ENXIO; ->private_data is never cleared, so the NULL check here doesn't make sense. > + err = mutex_lock_killable(&lo->lo_mutex); > + if (err) > + return err; > + > + if (lo->lo_state == Lo_rundown) > + err = -ENXIO; > + mutex_unlock(&lo->lo_mutex); What if we race with setting Lo_rundown and that gets set right after we unlock here?