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: <20190603144132.7611b8fe3cf6928d8391a24a@linux-foundation.org>
Date:   Mon, 3 Jun 2019 14:41:32 -0700
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Maninder Singh <maninder1.s@...sung.com>
Cc:     herbert@...dor.apana.org.au, davem@...emloft.net,
        keescook@...omium.org, gustavo@...eddedor.com, joe@...ches.com,
        linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
        a.sahrawat@...sung.com, pankaj.m@...sung.com, v.narang@...sung.com
Subject: Re: [PATCH 1/4] zstd: pass pointer rathen than structure to
 functions

On Mon,  3 Jun 2019 14:32:03 +0530 Maninder Singh <maninder1.s@...sung.com> wrote:

> currently params structure is passed in all functions, which increases
> stack usage in all the function and lead to stack overflow on target like
> ARM with kernel stack size of 8 KB so better to pass pointer.
> 
> Checked for ARM:
> 
>                                 Original               Patched
> Call FLow Size:                  1264                   1040
> ....
> (HUF_sort)                      -> 296
> (HUF_buildCTable_wksp)          -> 144
> (HUF_compress4X_repeat)         -> 88
> (ZSTD_compressBlock_internal)   -> 200
> (ZSTD_compressContinue_internal)-> 136                  -> 88
> (ZSTD_compressCCtx)             -> 192                  -> 64
> (zstd_compress)                 -> 144                  -> 96
> (crypto_compress)               -> 32
> (zcomp_compress)                -> 32
> ....
> 
> ...
>
> --- a/crypto/zstd.c
> +++ b/crypto/zstd.c
> @@ -162,7 +162,7 @@ static int __zstd_compress(const u8 *src, unsigned int slen,
>  	struct zstd_ctx *zctx = ctx;
>  	const ZSTD_parameters params = zstd_params();
>  
> -	out_len = ZSTD_compressCCtx(zctx->cctx, dst, *dlen, src, slen, params);
> +	out_len = ZSTD_compressCCtx(zctx->cctx, dst, *dlen, src, slen, &params);
>  	if (ZSTD_isError(out_len))
>  		return -EINVAL;
>  	*dlen = out_len;
> diff --git a/include/linux/zstd.h b/include/linux/zstd.h
> index 249575e..5103efa 100644
> --- a/include/linux/zstd.h
> +++ b/include/linux/zstd.h
> @@ -254,7 +254,7 @@ ZSTD_CCtx *ZSTD_initCCtx(void *workspace, size_t workspaceSize);
>   *               ZSTD_isError().
>   */
>  size_t ZSTD_compressCCtx(ZSTD_CCtx *ctx, void *dst, size_t dstCapacity,
> -	const void *src, size_t srcSize, ZSTD_parameters params);
> +	const void *src, size_t srcSize, const ZSTD_parameters *params);

Making the params poniter const made review a lot easier ;)

But struct ZSTD_CCtx_s.params is still a copied structure.  Could we
make it `const ZSTD_parameters *params'?  Probably not, due to lifetime
issues?


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ