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: <CAKv+Gu8nds6WgE5UWj8iy=fr7AOmCsaQsrE4Dcj0oiNOXkkt6g@mail.gmail.com>
Date:   Fri, 22 Mar 2019 17:21:10 +0100
From:   Ard Biesheuvel <ard.biesheuvel@...aro.org>
To:     Joe Perches <joe@...ches.com>
Cc:     Herbert Xu <herbert@...dor.apana.org.au>,
        "David S. Miller" <davem@...emloft.net>,
        "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" 
        <linux-crypto@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [possible PATCH] crypto: sahara - Use #ifdef DEBUG not IS_ENABLED(DEBUG)

On Fri, 22 Mar 2019 at 16:07, Joe Perches <joe@...ches.com> wrote:
>
> On Fri, 2019-03-22 at 15:29 +0100, Ard Biesheuvel wrote:
> > On Fri, 22 Mar 2019 at 13:43, Herbert Xu <herbert@...dor.apana.org.au> wrote:
> > > On Thu, Mar 07, 2019 at 04:15:55PM -0800, Joe Perches wrote:
> > > > Normal use of IS_ENABLED is with a CONFIG_<SYMBOL> and
> > > > there is no -DDEBUG in the Makefile here.
> > > >
> > > > Replace the IS_ENABLED(DEBUG) with #ifdef DEBUG/#endif
> > > > blocks.
> > > >
> > > > Miscellanea:
> > > >
> > > > o Move the sahara_state array into the function that uses it.
> > > >
> > > > Signed-off-by: Joe Perches <joe@...ches.com>
> > > > ---
> > > >  drivers/crypto/sahara.c | 20 +++++++++-----------
> > > >  1 file changed, 9 insertions(+), 11 deletions(-)
> > >
> > > Even if this is correct this is way too ugly.  The original code
> > > at least compiled everything regardless of macros.  Your new code
> > > won't detect compile errors in debugging code unless debugging is
> > > enabled.
> > >
> >
> > What's wrong with IS_ENABLED(DEBUG) anyway? It may not be 'normal use'
> > but it works fine.
>
> drivers/crypto/sahara.c is the only user in the kernel tree.
> So only it's abnormal use.  I rather like the concept actually.
>
> IS_ENABLED is almost exclusively used with CONFIG_<FOO> symbols
> and it could be useful to require it to be used with CONFIG_<FOO>
> symbols and use some other similar mechanism for DEBUG use.
>
> Maybe just adding a global #define in kernel.h like
>
> #define IS_DEBUG_ENABLED        IS_ENABLED(DEBUG)
>

__is_defined(DEBUG) seems to be the most appropriate here. I don't
feel strongly about whether we or not should wrap it in another macro.



> to isolate this in one place might be better.
>
> A good thing about using IS_ENABLED or the suggested IS_DEBUG_ENABLED
> would be that least gcc 5+ seems to automatically elide the uses of any
> unreferenced static const char * arrays like the sahara_state uses here.
>

Yes, that is kind of the point. If you use #ifdef, the compiler will
complain about unused static variables in this case.

> (I don't have gcc4 anymore so I couldn't check that version)
>
> So using 'if (IS_DEBUG_ENABLED)' could simplify some existing code like
> the many uses of
>
> #ifdef DEBUG
>         ...
> #endif
>
> or equivalent
>
>

My vote would be to use __is_defined(DEBUG) in place, but if others
prefer wrapping it in a macro, that is also fine with me.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ