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: <20190605123253.GZ15290@suse.cz>
Date:   Wed, 5 Jun 2019 14:32:53 +0200
From:   David Sterba <dsterba@...e.cz>
To:     Andrew Morton <akpm@...ux-foundation.org>,
        Maninder Singh <maninder1.s@...sung.com>,
        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,
        Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
        David Sterba <dsterba@...e.com>, linux-btrfs@...r.kernel.org,
        terrelln@...com
Subject: Re: [PATCH 1/4] zstd: pass pointer rathen than structure to functions

On Wed, Jun 05, 2019 at 01:57:03PM +0200, David Sterba wrote:
> On Tue, Jun 04, 2019 at 03:43:26PM -0700, Andrew Morton wrote:
> > 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
> > > ....
> > > 
> > > Signed-off-by: Maninder Singh <maninder1.s@...sung.com>
> > > Signed-off-by: Vaneet Narang <v.narang@...sung.com>
> > > 
> > 
> > You missed btrfs.  This needs review, please - particularly the
> > kernel-wide static ZSTD_parameters in zstd_get_btrfs_parameters().
> 
> > 
> > The base patch is here:
> > 
> > http://lkml.kernel.org/r/1559552526-4317-2-git-send-email-maninder1.s@samsung.com  
> > 
> > --- a/fs/btrfs/zstd.c~zstd-pass-pointer-rathen-than-structure-to-functions-fix
> > +++ a/fs/btrfs/zstd.c
> > @@ -27,15 +27,17 @@
> >  /* 307s to avoid pathologically clashing with transaction commit */
> >  #define ZSTD_BTRFS_RECLAIM_JIFFIES (307 * HZ)
> >  
> > -static ZSTD_parameters zstd_get_btrfs_parameters(unsigned int level,
> > +static ZSTD_parameters *zstd_get_btrfs_parameters(unsigned int level,
> >  						 size_t src_len)
> >  {
> > -	ZSTD_parameters params = ZSTD_getParams(level, src_len, 0);
> > +	static ZSTD_parameters params;
> 
> > +
> > +	params = ZSTD_getParams(level, src_len, 0);
> 
> No thats' broken, the params can't be static as it depends on level and
> src_len. What happens if there are several requests in parallel with
> eg. different levels?
> 
> Would be really great if the mailinglist is CCed when the code is
> changed in a non-trivial way.

So this does not compile fs/btrfs/zstd.o which Andrew probably found
too, otherwise btrfs is the only in-tree user of the function outside of
lib/ and crypto/.

I think that Nick Terrell should have been CCed too, as he ported zstd
to linux.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ