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:	Thu, 15 Oct 2015 09:29:03 +0900
From:	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
To:	Joonsoo Kim <js1304@...il.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Minchan Kim <minchan@...nel.org>,
	Nitin Gupta <ngupta@...are.org>,
	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
	Herbert Xu <herbert@...dor.apana.org.au>,
	"David S. Miller" <davem@...emloft.net>,
	Stephan Mueller <smueller@...onox.de>,
	linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org,
	Joonsoo Kim <iamjoonsoo.kim@....com>
Subject: Re: [PATCH v4 8/8] zram: enable contextless compression alg in zram

Hi,

On (10/14/15 16:38), Joonsoo Kim wrote:
[..]
>  static const char * const backends[] = {
>  	"lzo",
> -#ifdef CONFIG_ZRAM_LZ4_COMPRESS
>  	"lz4",
> -#endif
>  	NULL
>  };
>  
>  static const char *find_backend(const char *compress)
>  {
> -	int i = 0;
> -	while (backends[i]) {
> -		if (sysfs_streq(compress, backends[i]) &&
> -			crypto_has_comp(backends[i], 0, 0))
> -			break;
> -		i++;
> -	}
> -	return backends[i];
> +	if (crypto_has_comp(compress, 0, 0))
> +		return compress;
> +
> +	return NULL;
>  }
>  
>  static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm)
> @@ -277,6 +271,9 @@ ssize_t zcomp_available_show(const char *comp, char *buf)
>  	int i = 0;
>  
>  	while (backends[i]) {
> +		if (!crypto_has_comp(backends[i], 0, 0))
> +			continue;
> +

hm... this sort of looks a bit `unnatural' to me. we have two _independent_
sets -- what zram supports and what crypto supports. that's why you have
to do extra work and consult crypto. can we return back the old scheme:
use ifdef CONFIG in backends, but replace CONFIG_ZRAM with CONFIG_CRYPTO?

e.g.

	static const char * const backends[] = {
		"lzo",
	#ifdef CONFIG_CRYPTO_LZ4
		"lz4",
	#endif
		NULL
	};


so you can remove `crypto_has_comp(backends[i], 0, 0)' from
zcomp_available_show(), because zram will support *only* what
crypto supports.

	-ss


>  		if (!strcmp(comp, backends[i]))
>  			sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2,
>  					"[%s] ", backends[i]);
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 6f04fb2..6b4cf85 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -352,6 +352,7 @@ static ssize_t comp_algorithm_show(struct device *dev,
>  	size_t sz;
>  	struct zram *zram = dev_to_zram(dev);
>  
> +	deprecated_attr_warn("comp_algorithm");
>  	down_read(&zram->init_lock);
>  	sz = zcomp_available_show(zram->compressor, buf);
>  	up_read(&zram->init_lock);
> -- 
> 1.9.1
> 
--
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