lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: 
 <IA1PR10MB7240F50A15D30D77DA7DAE8298F42@IA1PR10MB7240.namprd10.prod.outlook.com>
Date: Thu, 23 May 2024 18:39:10 +0000
From: Gulam Mohamed <gulam.mohamed@...cle.com>
To: Christoph Hellwig <hch@....de>
CC: "linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "axboe@...nel.dk" <axboe@...nel.dk>,
        "shinichiro.kawasaki@....com"
	<shinichiro.kawasaki@....com>,
        "chaitanyak@...dia.com"
	<chaitanyak@...dia.com>
Subject: RE: [PATCH V2 for-6.10/block 1/2] loop: Fix a race between loop
 detach and loop open

Hi,

> -----Original Message-----
> From: Christoph Hellwig <hch@....de>
> Sent: Thursday, May 23, 2024 1:42 PM
> To: Gulam Mohamed <gulam.mohamed@...cle.com>
> Cc: linux-block@...r.kernel.org; linux-kernel@...r.kernel.org;
> axboe@...nel.dk; shinichiro.kawasaki@....com; chaitanyak@...dia.com;
> hch@....de
> Subject: Re: [PATCH V2 for-6.10/block 1/2] loop: Fix a race between loop
> detach and loop open
> 
> 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.
I will take care of this in the next version.
> 
> > 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.
> 
Sure. I will take care of this in the next version.
> > Signed-off-by: Gulam Mohamed <gulam.mohamed@...cle.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?
Similar race was mentioned by Kuai in his comments. We think these race conditions can be resolved by bringing back the "lo->refcnt" ,
by reverting the commit a0e286b6a5b61d4da01bdf865071c4da417046d6 plus the above Lo_rundown check in lo_open.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ