All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Gulam Mohamed <gulam.mohamed@oracle.com>
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
Date: Thu, 23 May 2024 10:12:07 +0200	[thread overview]
Message-ID: <20240523081207.GB1086@lst.de> (raw)
In-Reply-To: <20240521224249.7389-1-gulam.mohamed@oracle.com>

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 <gulam.mohamed@oracle.com>
> ---
>  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?


  parent reply	other threads:[~2024-05-23  8:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 22:42 [PATCH V2 for-6.10/block 1/2] loop: Fix a race between loop detach and loop open Gulam Mohamed
2024-05-21 22:42 ` [PATCH 2/2] loop: Test to detect a race condition between loop detach and open Gulam Mohamed
2024-05-23  8:12   ` Christoph Hellwig
2024-05-23 11:14   ` Shinichiro Kawasaki
2024-05-27  9:56     ` [PATCH blktests] " Gulam Mohamed
2024-05-22  1:39 ` [PATCH V2 for-6.10/block 1/2] loop: Fix a race between loop detach and loop open Jens Axboe
2024-05-22  2:31   ` Yu Kuai
2024-05-22 19:12     ` Gulam Mohamed
2024-05-23  1:13       ` Yu Kuai
2024-05-22 19:11   ` Gulam Mohamed
2024-05-23  8:12 ` Christoph Hellwig [this message]
2024-05-23 18:39   ` Gulam Mohamed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240523081207.GB1086@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=chaitanyak@nvidia.com \
    --cc=gulam.mohamed@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shinichiro.kawasaki@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.