All of lore.kernel.org
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Luis Henriques <luis.henriques@canonical.com>,
	Nitin Gupta <ngupta@vflare.org>,
	linux-kernel@vger.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: Re: [PATCH] zram: don't copy invalid compression algorithms
Date: Tue, 8 Sep 2015 10:14:43 +0900	[thread overview]
Message-ID: <20150908011443.GB19776@bbox> (raw)
In-Reply-To: <20150907235635.GA6896@swordfish>

Hey Sergey,

On Tue, Sep 08, 2015 at 08:56:35AM +0900, Sergey Senozhatsky wrote:
> On (09/07/15 21:48), Luis Henriques wrote:
> > Validate the new compression algorithm before copying it into the zram
> > 'compressor' field, keeping the old one if it's invalid.
> > 
> 
> NACK.
> 
> This is intentional. We haven't returned 'invalid compression algorithm'
> error from comp_algorithm_store() historically, so someone's script can
> simply ignore it. However, the script will fail to init the device and
> user will be able to figure out the root cause, because zram will report
> to syslog an actually requested alg name.
> 
> Example
> 
> [ 1669.473296] zram: Cannot initialise llzo compressing backend

I don't understand your concern. To me, this patch makes sense to me.
Could you explain your point clearly, again?

Thanks.
> 
> 
> 	-ss
> 
> > The error path code is also slightly refactored.
> > 
> > Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
> > ---
> >  drivers/block/zram/zram_drv.c | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> > index 9c01f5bfa33f..33551ec9e7f5 100644
> > --- a/drivers/block/zram/zram_drv.c
> > +++ b/drivers/block/zram/zram_drv.c
> > @@ -367,10 +367,15 @@ static ssize_t comp_algorithm_store(struct device *dev,
> >  
> >  	down_write(&zram->init_lock);
> >  	if (init_done(zram)) {
> > -		up_write(&zram->init_lock);
> >  		pr_info("Can't change algorithm for initialized device\n");
> > -		return -EBUSY;
> > +		len = -EBUSY;
> > +		goto out;
> > +	}
> > +	if (!zcomp_available_algorithm(buf)) {
> > +		len = -EINVAL;
> > +		goto out;
> >  	}
> > +
> >  	strlcpy(zram->compressor, buf, sizeof(zram->compressor));
> >  
> >  	/* ignore trailing newline */
> > @@ -378,9 +383,7 @@ static ssize_t comp_algorithm_store(struct device *dev,
> >  	if (sz > 0 && zram->compressor[sz - 1] == '\n')
> >  		zram->compressor[sz - 1] = 0x00;
> >  
> > -	if (!zcomp_available_algorithm(zram->compressor))
> > -		len = -EINVAL;
> > -
> > +out:
> >  	up_write(&zram->init_lock);
> >  	return len;
> >  }
> > 

  reply	other threads:[~2015-09-08  1:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-07 20:48 [PATCH] zram: don't copy invalid compression algorithms Luis Henriques
2015-09-07 23:56 ` Sergey Senozhatsky
2015-09-08  1:14   ` Minchan Kim [this message]
2015-09-08  1:33     ` Sergey Senozhatsky
2015-09-08  1:58       ` Sergey Senozhatsky
2015-09-08  4:50         ` Minchan Kim
2015-09-08  5:04           ` Sergey Senozhatsky
2015-09-08  8:16             ` Minchan Kim
2015-09-08  9:54               ` Sergey Senozhatsky
2015-09-08 13:33                 ` Minchan Kim
2015-09-08 13:44                   ` Sergey Senozhatsky
2015-09-08 14:21                     ` Minchan Kim
2015-09-08 15:35                       ` Sergey Senozhatsky
2015-09-08 10:08               ` Luis Henriques
2015-09-08 12:20                 ` Sergey Senozhatsky
2015-09-08  5:15           ` Sergey Senozhatsky

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=20150908011443.GB19776@bbox \
    --to=minchan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luis.henriques@canonical.com \
    --cc=ngupta@vflare.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.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.