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-next>] [day] [month] [year] [list]
Date:   Thu, 31 Aug 2017 09:11:16 -0500
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     x86@...nel.org
Cc:     linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        "H. Peter Anvin" <hpa@...or.com>,
        Andy Lutomirski <luto@...nel.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Alexander Potapenko <glider@...gle.com>,
        Dmitriy Vyukov <dvyukov@...gle.com>,
        Matthias Kaehlcke <mka@...omium.org>,
        Arnd Bergmann <arnd@...db.de>,
        Peter Zijlstra <peterz@...radead.org>
Subject: [RFC PATCH 0/4] x86/asm: Add ASM_CALL() macro for inline asms with call instructions

Making this RFC because I'm not sure if there's a better solution (like
maybe trying to convince the clang folks to support the undocumented GCC
syntax for this).  Opinions and better ideas welcome.


For inline asm statements which have a "call" instruction, we have to
set the stack pointer as a constraint to convince GCC to ensure the
frame pointer is set up first:

  register void *__sp asm(_ASM_SP);
  asm("call foo" : "+r" (__sp))

Clang doesn't have a known way to do the same thing.  Doing the sp
constraint thing causes it to corrupt the stack pointer.

Patch 4/4 adds a wrapper around such inline asm statements.

Before:
  register void *__sp asm(_ASM_SP);
  asm("call foo" : outputs, "+r" (__sp) : inputs : clobbers);

After:
  ASM_CALL("call foo", outputs, inputs, clobbers);


A limitation of the wrapper is that it doesn't support positional
operand names ("%0") and constraints ("0" (foo)).


The benefits of the wrapper are:

- Allows clang-built kernels to boot.

- Removes the stack pointer constraint with CONFIG_FRAME_POINTER=n
  (which may soon become the default).

- Will make it easy to handle if we ever get a documented way to do
  this.


NOTE: Patch 4/4 triggers a bug in the sparse preprocessor which causes
      the kbuild robot to complain.  I've reported the bug to the sparse
      mailing list.


Josh Poimboeuf (4):
  x86/paravirt: Fix output constraint macro names
  x86/asm: Convert some inline asm positional operands to named operands
  x86/asm: Make alternative macro interfaces more clear and consistent
  x86/asm: Use ASM_CALL() macro for inline asm statements with call
    instructions

 arch/x86/include/asm/alternative.h               |  72 ++++-------
 arch/x86/include/asm/apic.h                      |   7 +-
 arch/x86/include/asm/arch_hweight.h              |  14 +-
 arch/x86/include/asm/atomic64_32.h               | 101 +++++++++------
 arch/x86/include/asm/cmpxchg_32.h                |  20 +--
 arch/x86/include/asm/mshyperv.h                  |  51 ++++----
 arch/x86/include/asm/page_64.h                   |   6 +-
 arch/x86/include/asm/paravirt_types.h            |  86 ++++++-------
 arch/x86/include/asm/percpu.h                    |  13 +-
 arch/x86/include/asm/preempt.h                   |  15 +--
 arch/x86/include/asm/processor.h                 |  41 +++---
 arch/x86/include/asm/rwsem.h                     | 155 ++++++++++++-----------
 arch/x86/include/asm/special_insns.h             |   7 +-
 arch/x86/include/asm/uaccess.h                   |  24 ++--
 arch/x86/include/asm/uaccess_64.h                |  16 +--
 arch/x86/include/asm/xen/hypercall.h             |  59 +++++----
 arch/x86/kvm/emulate.c                           |   9 +-
 arch/x86/kvm/vmx.c                               |  17 +--
 arch/x86/mm/fault.c                              |  13 +-
 include/linux/compiler-clang.h                   |   2 +
 include/linux/compiler-gcc.h                     |  19 +++
 include/linux/compiler.h                         |  34 +++++
 tools/objtool/Documentation/stack-validation.txt |  19 +--
 23 files changed, 427 insertions(+), 373 deletions(-)

-- 
2.13.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ