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:   Tue, 1 Oct 2019 18:01:43 +0100
From:   Will Deacon <will@...nel.org>
To:     Nick Desaulniers <ndesaulniers@...gle.com>
Cc:     Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Nicolas Saenz Julienne <nsaenzjulienne@...e.de>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
        linux-arch <linux-arch@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Catalin Marinas <catalin.marinas@....com>,
        Russell King <rmk+kernel@....linux.org.uk>,
        Stefan Wahren <wahrenst@....net>,
        Kees Cook <keescook@...gle.com>
Subject: Re: [PATCH] compiler: enable CONFIG_OPTIMIZE_INLINING forcibly

On Tue, Oct 01, 2019 at 09:32:25AM -0700, Nick Desaulniers wrote:
> On Tue, Oct 1, 2019 at 2:28 AM Will Deacon <will@...nel.org> wrote:
> > On Mon, Sep 30, 2019 at 02:50:10PM -0700, Nick Desaulniers wrote:
> > > In this case, if there's a known codegen bug in a particular compiler
> > > or certain versions of it, I recommend the use of either the C
> > > preprocessor or __attribute__((no_inline)) to get the desired behavior
> > > localized to the function in question, and for us to proceed with
> > > Masahiro's cleanup.
> >
> > Hmm, I don't see how that would help. The problem occurs when things
> > are moved out of line by the compiler (see below).
> 
> It's being moved out of line because __attribute__((always_inline)) or
> just inline provide no guarantees that outlining does not occur.  It
> would help to make functions that need to be inlined macros, because
> the C preprocessor doesn't have that issue.

Hmm, let me try to put it another way: enabling CONFIG_OPTIMIZE_INLINING
has been shown to cause miscompilation with many versions of GCC on arm64
because the compiler moves things out of line that it otherwise doesn't
appear to do. I don't see how __attribute__((no_inline)) helps with that,
and replacing static functions with macros isn't great for type-checking
and argument evaluation.

> > > The comment above the use of CONFIG_OPTIMIZE_INLINING in
> > > include/linux/compiler_types.h says:
> > >   * Force always-inline if the user requests it so via the .config.
> > > Which makes me grimace (__attribute__((always_inline)) doesn't *force*
> > > anything as per above), and the idea that forcing things marked inline
> > > to also be __attribute__((always_inline)) is an "optimization" (re:
> > > the name of the config; CONFIG_OPTIMIZE_INLINING) is also highly
> > > suspect.  Aggressive inlining leads to image size bloat, instruction
> > > cache and register pressure; it is not exclusively an optimization.
> >
> > Agreed on all of this, but the fact remains that GCC has been shown to
> > *miscompile* the arm64 kernel with CONFIG_OPTIMIZE_INLINING=y. Please,
> > look at this thread:
> >
> >         https://www.spinics.net/lists/arm-kernel/msg730329.html
> >         https://www.spinics.net/lists/arm-kernel/msg730512.html
> >
> > GCC decides to pull an atomic operation out-of-line and, in doing so,
> 
> If the function is incorrect unless inlined, use a macro.

The function is correct per the GCC documentation regarding register
variables and inline asm.

> > Reducing the instruction cache footprint is great, but not if the
> > resulting code is broken!
> 
> You don't have to convince compiler folks about correctness. ;)
> Correctness trumps all, especially performance.

Then why is this conversation so difficult? :(

Will

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ