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]
Date:	Fri, 7 Aug 2015 19:16:10 +0900
From:	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Joonsoo Kim <js1304@...il.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
	Minchan Kim <minchan@...nel.org>,
	Nitin Gupta <ngupta@...are.org>, linux-kernel@...r.kernel.org,
	Joonsoo Kim <iamjoonsoo.kim@....com>
Subject: Re: [PATCH] zram: fix possible race when checking idle_strm

On (08/07/15 18:37), Sergey Senozhatsky wrote:
[..]
> > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@....com>
> 
> Acked-by: Sergey Senozhatsky <sergey.senozhatsky@...il.com>

Andrew, my apologies, can we hold on a bit with my Acked-by. I
need more time to think about the issue -- do we actually have
one or we don't.

It seems that to be on a safe side this check is better be done
under the lock, but at the same time I sort of fail to convenience
myself that doing this check outside the lock introduces any danger.
Need some rest. May be Joonsoo and Minchan can add some bits
(that I currently miss) or thoughts.

	-ss

> > ---
> >  drivers/block/zram/zcomp.c | 15 +++++++++++++--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
> > index 80a62e7..837e9c3 100644
> > --- a/drivers/block/zram/zcomp.c
> > +++ b/drivers/block/zram/zcomp.c
> > @@ -76,6 +76,17 @@ static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp)
> >  	return zstrm;
> >  }
> >  
> > +static bool avail_idle_strm(struct zcomp_strm_multi *zs)
> > +{
> > +	int avail;
> > +
> > +	spin_lock(&zs->strm_lock);
> > +	avail = !list_empty(&zs->idle_strm);
> > +	spin_unlock(&zs->strm_lock);
> > +
> > +	return avail;
> > +}
> > +
> >  /*
> >   * get idle zcomp_strm or wait until other process release
> >   * (zcomp_strm_release()) one for us
> > @@ -97,7 +108,7 @@ static struct zcomp_strm *zcomp_strm_multi_find(struct zcomp *comp)
> >  		/* zstrm streams limit reached, wait for idle stream */
> >  		if (zs->avail_strm >= zs->max_strm) {
> >  			spin_unlock(&zs->strm_lock);
> > -			wait_event(zs->strm_wait, !list_empty(&zs->idle_strm));
> > +			wait_event(zs->strm_wait, avail_idle_strm(zs));
> >  			continue;
> >  		}
> >  		/* allocate new zstrm stream */
> > @@ -109,7 +120,7 @@ static struct zcomp_strm *zcomp_strm_multi_find(struct zcomp *comp)
> >  			spin_lock(&zs->strm_lock);
> >  			zs->avail_strm--;
> >  			spin_unlock(&zs->strm_lock);
> > -			wait_event(zs->strm_wait, !list_empty(&zs->idle_strm));
> > +			wait_event(zs->strm_wait, avail_idle_strm(zs));
> >  			continue;
> >  		}
> >  		break;
> > -- 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ